TestModel
Deterministic mock model for testing. Implements LanguageModelV3.
Three modes:
- No config: Auto-calls all available tools on first call, returns defaultText on second.
- responses[]: Returns pre-configured responses in order. Throws when exhausted.
- defaultText: Always returns the specified text (no tool calls).
Zero cost, zero latency, no network calls.
Example
Section titled “Example”const agent = new Agent({ name: "test", model: new TestModel({ defaultText: "Hello!" }), instructions: "test", defaults: false,})const { text } = await agent.run("Hi").result // "Hello!"Implements
Section titled “Implements”LanguageModelV3
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new TestModel(
opts?):TestModel
Parameters
Section titled “Parameters”Returns
Section titled “Returns”TestModel
Properties
Section titled “Properties”modelId
Section titled “modelId”
readonlymodelId:"test-model"="test-model"
Provider-specific model ID.
Implementation of
Section titled “Implementation of”LanguageModelV3.modelId
provider
Section titled “provider”
readonlyprovider:"test"="test"
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>
Generates a language model output (non-streaming).
Naming: “do” prefix to prevent accidental direct usage of the method by the user.
Parameters
Section titled “Parameters”options
Section titled “options”LanguageModelV3CallOptions
Returns
Section titled “Returns”Promise<LanguageModelV3GenerateResult>
Implementation of
Section titled “Implementation of”LanguageModelV3.doGenerate
doStream()
Section titled “doStream()”doStream():
Promise<never>
Generates a language model output (streaming).
Naming: “do” prefix to prevent accidental direct usage of the method by the user.
Returns
Section titled “Returns”Promise<never>
A stream of higher-level language model output parts.
Implementation of
Section titled “Implementation of”LanguageModelV3.doStream
reset()
Section titled “reset()”reset():
void
Reset call index for reuse across tests.
Returns
Section titled “Returns”void