Adapters
Adapter interfaces for connecting chat models, streaming responses, and model execution to assistant-ui runtimes.
API Reference
ChatModelAdapter
ChatModelAdapterrun: (options: ChatModelRunOptions) => Promise<ChatModelRunResult> | AsyncGenerator<ChatModelRunResult, void>ChatModelRunOptions
ChatModelRunOptionsmessages: readonly ThreadMessage[]runConfig: RunConfigcustom?: Record<string, unknown>abortSignal: AbortSignalaborted: booleanonabort: ((this:AbortSignal,ev:Event)=>any)|nullreason: anythrowIfAborted: () => voidaddEventListener: { <K>(type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; }removeEventListener: { <K>(type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | EventListenerOptions): void; (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; }dispatchEvent: (event: Event) => booleanThe **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent(). [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
context: ModelContextpriority?: numbersystem?: stringtools?: Record<string, Tool<any, any>>callSettings?: LanguageModelV1CallSettingsmaxTokens?: numbertemperature?: numbertopP?: numberpresencePenalty?: numberfrequencyPenalty?: numberseed?: numberheaders?: Record<string, string | undefined>config?: LanguageModelConfigapiKey?: stringbaseUrl?: stringmodelName?: stringunstable_assistantMessageIdunstable?: stringunstable_threadIdunstable?: stringunstable_parentIdunstable?: string | nullunstable_getMessageunstable: () => ThreadMessageChatModelRunResult
ChatModelRunResultcontent?: readonly ThreadAssistantMessagePart[]status?: MessageStatusmetadata?: ChatModelRunResult["metadata"]unstable_stateunstable?: ReadonlyJSONValueunstable_annotationsunstable?: readonly ReadonlyJSONValue[]unstable_dataunstable?: readonly ReadonlyJSONValue[]steps?: readonly ThreadStep[]timing?: MessageTimingstreamStartTime: numberfirstTokenTime?: numbertotalStreamTime?: numbertokenCount?: numbertokensPerSecond?: numbertotalChunks: numbertoolCallCount: numbercustom?: Record<string, unknown>ChatModelRunUpdate
ChatModelRunUpdatecontent: readonly ThreadAssistantMessagePart[]metadata?: Record<string, unknown>CreateResumeRunConfig
CreateResumeRunConfigparentId: string | nullsourceId?: string | nullrunConfig?: RunConfigcustom?: Record<string, unknown>stream?: (
options: ChatModelRunOptions,
) => AsyncGenerator<ChatModelRunResult, void, unknown>CreateStartRunConfig
CreateStartRunConfigparentId: string | nullsourceId?: string | nullrunConfig?: RunConfigcustom?: Record<string, unknown>LanguageModelConfig
LanguageModelConfigapiKey?: stringbaseUrl?: stringmodelName?: string