Skip to content

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.

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").result
  • LanguageModelV3

readonly modelId: string

Provider-specific model ID.

LanguageModelV3.modelId


readonly provider: "replay" = "replay"

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>

Returns the next recorded response. Throws if all responses are exhausted.

LanguageModelV3CallOptions

AI SDK call options (ignored — responses are pre-recorded)

Promise<LanguageModelV3GenerateResult>

Pre-recorded generate result

When all recorded interactions have been consumed

LanguageModelV3.doGenerate


doStream(): Promise<never>

Promise<never>

Always throws — streaming is not supported for replay.

LanguageModelV3.doStream


static fromFile(path): Promise<ReplayModel>

Creates a ReplayModel from a cassette JSON file.

string

Path to the cassette JSON file

Promise<ReplayModel>

ReplayModel ready to serve recorded responses


static fromJSON(data): ReplayModel

Creates a ReplayModel from parsed cassette JSON data.

any

Parsed cassette object

ReplayModel

ReplayModel ready to serve recorded responses