Skip to content

RecordModel

Recording model that wraps a real LanguageModelV3, forwarding all calls while capturing request/response pairs for later replay.

Use saveCassette(path) to write the recorded interactions to a JSON file. API key patterns are automatically scrubbed from the output.

const real = resolveModel("anthropic/claude-sonnet-4-6")
const recorder = new RecordModel(real)
// ... use recorder as the model in an Agent ...
await recorder.saveCassette("./fixtures/my-test.cassette.json")
  • LanguageModelV3

new RecordModel(inner): RecordModel

LanguageModelV3

RecordModel

readonly modelId: string

Provider-specific model ID.

LanguageModelV3.modelId


readonly provider: string

Provider ID.

LanguageModelV3.provider


readonly specificationVersion: "v3"

The language model must specify which language model interface version it implements.

LanguageModelV3.specificationVersion


readonly supportedUrls: object = {}

Supported URL patterns by media type for the provider.

The keys are media type patterns or full media types (e.g. */* for everything, audio/*, video/*, or application/pdf). and the values are arrays of regular expressions that match the URL paths.

The matching should be against lower-case URLs.

Matched URLs are supported natively by the model and are not downloaded.

A map of supported URL patterns by media type (as a promise or a plain object).

LanguageModelV3.supportedUrls

doGenerate(options): Promise<LanguageModelV3GenerateResult>

Forwards the call to the inner model and records the interaction.

LanguageModelV3CallOptions

AI SDK V3 call options

Promise<LanguageModelV3GenerateResult>

The inner model’s generate result

LanguageModelV3.doGenerate


doStream(): Promise<never>

Promise<never>

Always throws — streaming is not supported for recording.

LanguageModelV3.doStream


saveCassette(path): Promise<void>

Writes all recorded interactions to a JSON cassette file. Automatically scrubs common API key patterns from the output.

string

File path to write the cassette JSON

Promise<void>