Class References
Function References
- text
- textOptions
- combineStrategies
- convertMessagesToModelMessages
- convertZodToJsonSchema
- createReplayStream
- embedding
- generateMessageId
- maxIterations
- messages
- modelMessageToUIMessage
- modelMessagesToUIMessages
- normalizeToUIMessage
- parsePartialJSON
- summarize
- toServerSentEventsStream
- toServerSentEventsResponse
- toolDefinition
- uiMessageToModelMessages
- realtimeToken
- untilFinishReason
Interface References
- AIAdapter
- AIAdapterConfig
- AgentLoopState
- AudioPart
- AudioVisualization
- BaseStreamChunk
- TextCompletionChunk
- TextOptions
- ChunkRecording
- ChunkStrategy
- ClientTool
- ContentPartSource
- ContentStreamChunk
- DefaultMessageMetadataByModality
- DocumentPart
- DoneStreamChunk
- EmbeddingOptions
- EmbeddingResult
- ErrorStreamChunk
- ImagePart
- InternalToolCallState
- JSONParser
- ModelMessage
- ProcessorResult
- ProcessorState
- RealtimeAdapter
- RealtimeClientOptions
- RealtimeConnection
- RealtimeMessage
- RealtimeSessionConfig
- RealtimeToken
- RealtimeTokenAdapter
- RealtimeTokenOptions
- ResponseFormat
- ServerTool
- StreamProcessorEvents
- StreamProcessorHandlers
- StreamProcessorOptions
- SummarizationOptions
- SummarizationResult
- TextPart
- ThinkingPart
- ThinkingStreamChunk
- Tool
- ToolCall
- ToolCallPart
- ToolCallStreamChunk
- ToolConfig
- ToolDefinition
- ToolDefinitionConfig
- ToolDefinitionInstance
- ToolInputAvailableStreamChunk
- ToolResultPart
- ToolResultStreamChunk
- UIMessage
- VideoPart
Type Alias References
- AgentLoopStrategy
- AnyClientTool
- TextStreamOptionsForModel
- TextStreamOptionsUnion
- ConstrainedContent
- ConstrainedModelMessage
- ContentPart
- ContentPartForModalities
- ExtractModalitiesForModel
- ExtractModelsFromAdapter
- InferToolInput
- InferToolName
- InferToolOutput
- MessagePart
- RealtimeEvent
- RealtimeMessagePart
- RealtimeMode
- RealtimeStatus
- ModalitiesArrayToUnion
- Modality
- StreamChunk
- ToolCallState
- ToolResultState
Variable References
createModel
Call Signature#
function createModel<TName, TInput>(name, input): ExtendedModelDef<TName, TInput>;Defined in: packages/ai/src/extend-adapter.ts:91
Creates a custom model definition for use with extendAdapter.
This is a helper function that provides proper type inference without requiring manual as const casts on individual properties.
Type Parameters#
TName#
TName extends string
The model name (inferred from argument)
TInput#
TInput extends readonly ("text" | "image" | "audio" | "video" | "document")[]
The input modalities array (inferred from argument)
Parameters#
name#
TName
The model name identifier (literal string)
input#
TInput
Array of supported input modalities
Returns#
ExtendedModelDef<TName, TInput>
A properly typed model definition for use with extendAdapter
Examples#
import { extendAdapter, createModel } from '@tanstack/ai'
import { openaiText } from '@tanstack/ai-openai'
// Define custom models with full type inference
const customModels = [
createModel('my-fine-tuned-gpt4', ['text', 'image']),
createModel('local-llama', ['text']),
] as const
const myOpenai = extendAdapter(openaiText, customModels)// Capabilities object form - declare features and provider tools
const reasoner = createModel('reasoner', {
input: ['text'],
features: ['reasoning', 'structured_outputs'],
tools: ['web_search'],
})Call Signature#
function createModel<TName, TCaps>(name, capabilities): ExtendedModelDef<TName, TCaps["input"] extends readonly ("text" | "image" | "audio" | "video" | "document")[] ? any[any] : readonly ("text" | "image" | "audio" | "video" | "document")[], TCaps["modelOptions"], TCaps["features"] extends readonly string[] ? any[any] : readonly string[], TCaps["tools"] extends readonly string[] ? any[any] : readonly string[]>;Defined in: packages/ai/src/extend-adapter.ts:96
Creates a custom model definition for use with extendAdapter.
This is a helper function that provides proper type inference without requiring manual as const casts on individual properties.
Type Parameters#
TName#
TName extends string
The model name (inferred from argument)
TCaps#
TCaps extends ModelCapabilities<readonly ("text" | "image" | "audio" | "video" | "document")[], readonly string[], readonly string[], unknown>
Parameters#
name#
TName
The model name identifier (literal string)
capabilities#
TCaps
Returns#
ExtendedModelDef<TName, TCaps["input"] extends readonly ("text" | "image" | "audio" | "video" | "document")[] ? any[any] : readonly ("text" | "image" | "audio" | "video" | "document")[], TCaps["modelOptions"], TCaps["features"] extends readonly string[] ? any[any] : readonly string[], TCaps["tools"] extends readonly string[] ? any[any] : readonly string[]>
A properly typed model definition for use with extendAdapter
Examples#
import { extendAdapter, createModel } from '@tanstack/ai'
import { openaiText } from '@tanstack/ai-openai'
// Define custom models with full type inference
const customModels = [
createModel('my-fine-tuned-gpt4', ['text', 'image']),
createModel('local-llama', ['text']),
] as const
const myOpenai = extendAdapter(openaiText, customModels)// Capabilities object form - declare features and provider tools
const reasoner = createModel('reasoner', {
input: ['text'],
features: ['reasoning', 'structured_outputs'],
tools: ['web_search'],
})