ReplayModel
Replay model that serves pre-recorded responses from a cassette.
Does not make any network calls. Returns recorded responses in order. Throws when all recorded interactions have been exhausted.
Example
Section titled “Example”const replay = await ReplayModel.fromFile("./fixtures/my-test.cassette.json")const agent = new Agent({ name: "test", model: replay, instructions: "test", defaults: false })const { text } = await agent.run("Hello").resultImplements
Section titled “Implements”LanguageModelV3
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:"replay"="replay"
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>
Returns the next recorded response. Throws if all responses are exhausted.
Parameters
Section titled “Parameters”_options
Section titled “_options”LanguageModelV3CallOptions
AI SDK call options (ignored — responses are pre-recorded)
Returns
Section titled “Returns”Promise<LanguageModelV3GenerateResult>
Pre-recorded generate result
Throws
Section titled “Throws”When all recorded interactions have been consumed
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 replay.
Implementation of
Section titled “Implementation of”LanguageModelV3.doStream
fromFile()
Section titled “fromFile()”
staticfromFile(path):Promise<ReplayModel>
Creates a ReplayModel from a cassette JSON file.
Parameters
Section titled “Parameters”string
Path to the cassette JSON file
Returns
Section titled “Returns”Promise<ReplayModel>
ReplayModel ready to serve recorded responses
fromJSON()
Section titled “fromJSON()”
staticfromJSON(data):ReplayModel
Creates a ReplayModel from parsed cassette JSON data.
Parameters
Section titled “Parameters”any
Parsed cassette object
Returns
Section titled “Returns”ReplayModel
ReplayModel ready to serve recorded responses