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.
Example
Section titled “Example”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")Implements
Section titled “Implements”LanguageModelV3
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new RecordModel(
inner):RecordModel
Parameters
Section titled “Parameters”LanguageModelV3
Returns
Section titled “Returns”RecordModel
Properties
Section titled “Properties”modelId
Section titled “modelId”
readonlymodelId:string
Provider-specific model ID.
Implementation of
Section titled “Implementation of”LanguageModelV3.modelId
provider
Section titled “provider”
readonlyprovider:string
Provider ID.
Implementation of
Section titled “Implementation of”LanguageModelV3.provider
specificationVersion
Section titled “specificationVersion”
readonlyspecificationVersion:"v3"
The language model must specify which language model interface version it implements.
Implementation of
Section titled “Implementation of”LanguageModelV3.specificationVersion
supportedUrls
Section titled “supportedUrls”
readonlysupportedUrls: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.
Returns
Section titled “Returns”A map of supported URL patterns by media type (as a promise or a plain object).
Implementation of
Section titled “Implementation of”LanguageModelV3.supportedUrls
Methods
Section titled “Methods”doGenerate()
Section titled “doGenerate()”doGenerate(
options):Promise<LanguageModelV3GenerateResult>
Forwards the call to the inner model and records the interaction.
Parameters
Section titled “Parameters”options
Section titled “options”LanguageModelV3CallOptions
AI SDK V3 call options
Returns
Section titled “Returns”Promise<LanguageModelV3GenerateResult>
The inner model’s generate result
Implementation of
Section titled “Implementation of”LanguageModelV3.doGenerate
doStream()
Section titled “doStream()”doStream():
Promise<never>
Returns
Section titled “Returns”Promise<never>
Throws
Section titled “Throws”Always throws — streaming is not supported for recording.
Implementation of
Section titled “Implementation of”LanguageModelV3.doStream
saveCassette()
Section titled “saveCassette()”saveCassette(
path):Promise<void>
Writes all recorded interactions to a JSON cassette file. Automatically scrubs common API key patterns from the output.
Parameters
Section titled “Parameters”string
File path to write the cassette JSON
Returns
Section titled “Returns”Promise<void>