Interface: TextAdapter<TModel, TProviderOptions, TInputModalities, TMessageMetadataByModality, TToolCapabilities, TToolCallMetadata, TSystemPromptMetadata>#
Defined in: packages/typescript/ai/src/activities/chat/adapter.ts:63
Text adapter interface with pre-resolved generics.
An adapter is created by a provider function: provider('model') → adapter
All type resolution happens at the provider call site, not in this interface.
Generic parameters:
- TModel: The specific model name (e.g., 'gpt-4o')
- TProviderOptions: Provider-specific options for this model (already resolved)
- TInputModalities: Supported input modalities for this model (already resolved)
- TMessageMetadata: Metadata types for content parts (already resolved)
- TToolCapabilities: Tuple of tool-kind strings supported by this model, resolved from
supports.tools - TToolCallMetadata: Metadata type that round-trips with tool calls (e.g. Gemini's
thoughtSignature) - TSystemPromptMetadata: Provider-typed metadata accepted on each
systemPrompts[i]entry (e.g. Anthropiccache_control). Defaults tonever— adapters without per-prompt metadata reject themetadatafield at the call site.
Type Parameters#
TModel#
TModel extends string
TProviderOptions#
TProviderOptions extends Record<string, any>
TInputModalities#
TInputModalities extends ReadonlyArray<Modality>
TMessageMetadataByModality#
TMessageMetadataByModality extends DefaultMessageMetadataByModality
TToolCapabilities#
TToolCapabilities extends ReadonlyArray<string> = ReadonlyArray<string>
TToolCallMetadata#
TToolCallMetadata = unknown
TSystemPromptMetadata#
TSystemPromptMetadata = never
Properties#
~types#
~types: object;
Defined in: packages/typescript/ai/src/activities/chat/adapter.ts:82
Internal
Type-only properties for inference. Not assigned at runtime.
inputModalities#
inputModalities: TInputModalities;
messageMetadataByModality#
messageMetadataByModality: TMessageMetadataByModality;
providerOptions#
providerOptions: TProviderOptions;
systemPromptMetadata#
systemPromptMetadata: TSystemPromptMetadata;
toolCallMetadata#
toolCallMetadata: TToolCallMetadata;
toolCapabilities#
toolCapabilities: TToolCapabilities;
chatStream()#
chatStream: (options) => AsyncIterable<AGUIEvent>;
Defined in: packages/typescript/ai/src/activities/chat/adapter.ts:94
Stream text completions from the model
Parameters#
options#
TextOptions<TProviderOptions>
Returns#
AsyncIterable<AGUIEvent>
kind#
readonly kind: "text";
Defined in: packages/typescript/ai/src/activities/chat/adapter.ts:73
Discriminator for adapter kind
model#
readonly model: TModel;
Defined in: packages/typescript/ai/src/activities/chat/adapter.ts:77
The model this adapter is configured for
name#
readonly name: string;
Defined in: packages/typescript/ai/src/activities/chat/adapter.ts:75
Provider name identifier (e.g., 'openai', 'anthropic')
structuredOutput()#
structuredOutput: (options) => Promise<StructuredOutputResult<unknown>>;
Defined in: packages/typescript/ai/src/activities/chat/adapter.ts:106
Generate structured output using the provider's native structured output API. This method uses stream: false and sends the JSON schema to the provider to ensure the response conforms to the expected structure.
Parameters#
options#
StructuredOutputOptions<TProviderOptions>
Structured output options containing chat options and JSON schema
Returns#
Promise<StructuredOutputResult<unknown>>
Promise with the raw data (validation is done in the chat function)
structuredOutputStream()?#
optional structuredOutputStream: (options) => AsyncIterable<AGUIEvent>;
Defined in: packages/typescript/ai/src/activities/chat/adapter.ts:123
Stream structured output using the provider's native streaming structured output API (stream + response_format json_schema in a single request).
Optional — adapters without native streaming JSON omit this method and the
activity layer synthesizes a stream around the non-streaming
structuredOutput call.
Implementations must emit standard AG-UI lifecycle events (RUN_STARTED,
TEXT_MESSAGE_*, RUN_FINISHED) carrying raw JSON text deltas, plus a final
CUSTOM event named structured-output.complete whose value is
{ object, raw, reasoning? }.
Parameters#
options#
StructuredOutputOptions<TProviderOptions>
Returns#
AsyncIterable<AGUIEvent>