ai 5.0.0-alpha.5 → 5.0.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { ToolResultContent, Schema, ToolCall, ToolResult, IdGenerator, FetchFunction, Validator, StandardSchemaV1 } from '@ai-sdk/provider-utils';
1
+ import { ToolResultContent, Schema, ToolCall, ToolResult, IdGenerator, Validator, StandardSchemaV1, FetchFunction } from '@ai-sdk/provider-utils';
2
2
  export { IdGenerator, Schema, ToolCall, ToolResult, asSchema, createIdGenerator, generateId, jsonSchema } from '@ai-sdk/provider-utils';
3
3
  import { AISDKError, SharedV2ProviderMetadata, SharedV2ProviderOptions, EmbeddingModelV2, EmbeddingModelV2Embedding, ImageModelV2, ImageModelV2CallWarning, ImageModelV2ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV2, LanguageModelV2FinishReason, LanguageModelV2CallWarning, LanguageModelV2Source, SpeechModelV1, SpeechModelV1CallWarning, TranscriptionModelV1, TranscriptionModelV1CallWarning, LanguageModelV2Usage, JSONObject, LanguageModelV2ToolCall, JSONSchema7, LanguageModelV2CallOptions, JSONParseError, TypeValidationError, LanguageModelV2Middleware, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
4
4
  export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, NoContentGeneratedError, NoSuchModelError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
5
+ import { GatewayModelId } from '@ai-sdk/gateway';
5
6
  import { z } from 'zod';
6
7
  import { ServerResponse } from 'node:http';
7
8
  import { AttributeValue, Tracer } from '@opentelemetry/api';
@@ -382,7 +383,7 @@ type JSONValue = JSONValue$1;
382
383
  /**
383
384
  Language model that is used by the AI SDK Core functions.
384
385
  */
385
- type LanguageModel = LanguageModelV2;
386
+ type LanguageModel = GatewayModelId | LanguageModelV2;
386
387
  /**
387
388
  Reason why a language model finished generating a response.
388
389
 
@@ -2114,13 +2115,10 @@ It is optional for backwards compatibility.
2114
2115
  */
2115
2116
  type ToolInvocation = ({
2116
2117
  state: 'partial-call';
2117
- step?: number;
2118
2118
  } & ToolCall<string, any>) | ({
2119
2119
  state: 'call';
2120
- step?: number;
2121
2120
  } & ToolCall<string, any>) | ({
2122
2121
  state: 'result';
2123
- step?: number;
2124
2122
  } & ToolResult<string, any, any>);
2125
2123
  /**
2126
2124
  The data types that can be used in the UI message for the UI message data parts.
@@ -2288,15 +2286,31 @@ declare function pipeTextStreamToResponse({ response, status, statusText, header
2288
2286
  textStream: ReadableStream<string>;
2289
2287
  } & ResponseInit): void;
2290
2288
 
2291
- /**
2292
- * Appends a client message to the messages array.
2293
- * If the last message in the array has the same id as the new message, it will be replaced.
2294
- * Otherwise, the new message will be appended.
2295
- */
2296
- declare function appendClientMessage({ messages, message, }: {
2297
- messages: UIMessage[];
2298
- message: UIMessage;
2299
- }): UIMessage<unknown, UIDataTypes>[];
2289
+ declare const getOriginalFetch: () => typeof fetch;
2290
+ declare function callCompletionApi({ api, prompt, credentials, headers, body, streamProtocol, setCompletion, setLoading, setError, setAbortController, onFinish, onError, fetch, }: {
2291
+ api: string;
2292
+ prompt: string;
2293
+ credentials: RequestCredentials | undefined;
2294
+ headers: HeadersInit | undefined;
2295
+ body: Record<string, any>;
2296
+ streamProtocol: 'data' | 'text' | undefined;
2297
+ setCompletion: (completion: string) => void;
2298
+ setLoading: (loading: boolean) => void;
2299
+ setError: (error: Error | undefined) => void;
2300
+ setAbortController: (abortController: AbortController | null) => void;
2301
+ onFinish: ((prompt: string, completion: string) => void) | undefined;
2302
+ onError: ((error: Error) => void) | undefined;
2303
+ fetch: ReturnType<typeof getOriginalFetch> | undefined;
2304
+ }): Promise<string | null | undefined>;
2305
+
2306
+ type Job = () => Promise<void>;
2307
+
2308
+ declare class SerialJobExecutor {
2309
+ private queue;
2310
+ private isProcessing;
2311
+ private processQueue;
2312
+ run(job: Job): Promise<void>;
2313
+ }
2300
2314
 
2301
2315
  /**
2302
2316
  The result of an `embed` call.
@@ -2708,14 +2722,12 @@ type PrepareStepFunction<TOOLS extends Record<string, Tool> = Record<string, Too
2708
2722
  steps: Array<StepResult<NoInfer<TOOLS>>>;
2709
2723
  stepNumber: number;
2710
2724
  model: LanguageModel;
2711
- }) => PromiseLike<{
2712
- model?: LanguageModel;
2713
- toolChoice?: ToolChoice<NoInfer<TOOLS>>;
2714
- activeTools?: Array<keyof NoInfer<TOOLS>>;
2715
- } | undefined> | {
2725
+ }) => PromiseLike<PrepareStepResult<TOOLS>> | PrepareStepResult<TOOLS>;
2726
+ type PrepareStepResult<TOOLS extends Record<string, Tool> = Record<string, Tool>> = {
2716
2727
  model?: LanguageModel;
2717
2728
  toolChoice?: ToolChoice<NoInfer<TOOLS>>;
2718
2729
  activeTools?: Array<keyof NoInfer<TOOLS>>;
2730
+ system?: string;
2719
2731
  } | undefined;
2720
2732
 
2721
2733
  type StopCondition<TOOLS extends ToolSet> = (options: {
@@ -2776,7 +2788,7 @@ If set and supported by the model, calls will generate deterministic results.
2776
2788
  @returns
2777
2789
  A result object that contains the generated text, the results of the tool calls, and additional information.
2778
2790
  */
2779
- declare function generateText<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never>({ model, tools, toolChoice, system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, headers, stopWhen, experimental_output: output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools, experimental_prepareStep, prepareStep, experimental_repairToolCall: repairToolCall, _internal: { generateId, currentDate, }, onStepFinish, ...settings }: CallSettings & Prompt & {
2791
+ declare function generateText<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never>({ model: modelArg, tools, toolChoice, system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, headers, stopWhen, experimental_output: output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools, experimental_prepareStep, prepareStep, experimental_repairToolCall: repairToolCall, _internal: { generateId, currentDate, }, onStepFinish, ...settings }: CallSettings & Prompt & {
2780
2792
  /**
2781
2793
  The language model to use.
2782
2794
  */
@@ -3696,15 +3708,6 @@ declare function parsePartialJson(jsonText: string | undefined): Promise<{
3696
3708
  state: 'undefined-input' | 'successful-parse' | 'repaired-parse' | 'failed-parse';
3697
3709
  }>;
3698
3710
 
3699
- type Job = () => Promise<void>;
3700
-
3701
- declare class SerialJobExecutor {
3702
- private queue;
3703
- private isProcessing;
3704
- private processQueue;
3705
- run(job: Job): Promise<void>;
3706
- }
3707
-
3708
3711
  /**
3709
3712
  * Creates a ReadableStream that emits the provided values with an optional delay between each value.
3710
3713
  *
@@ -4162,15 +4165,15 @@ declare const wrapLanguageModel: ({ model, middleware: middlewareArg, modelId, p
4162
4165
  *
4163
4166
  * @throws {NoSuchModelError} Throws when a requested model is not found and no fallback provider is available.
4164
4167
  */
4165
- declare function customProvider<LANGUAGE_MODELS extends Record<string, LanguageModel>, EMBEDDING_MODELS extends Record<string, EmbeddingModel<string>>, IMAGE_MODELS extends Record<string, ImageModel>>({ languageModels, textEmbeddingModels, imageModels, fallbackProvider, }: {
4168
+ declare function customProvider<LANGUAGE_MODELS extends Record<string, LanguageModelV2>, EMBEDDING_MODELS extends Record<string, EmbeddingModelV2<string>>, IMAGE_MODELS extends Record<string, ImageModelV2>>({ languageModels, textEmbeddingModels, imageModels, fallbackProvider, }: {
4166
4169
  languageModels?: LANGUAGE_MODELS;
4167
4170
  textEmbeddingModels?: EMBEDDING_MODELS;
4168
4171
  imageModels?: IMAGE_MODELS;
4169
4172
  fallbackProvider?: ProviderV2;
4170
- }): Provider & {
4171
- languageModel(modelId: ExtractModelId<LANGUAGE_MODELS>): LanguageModel;
4172
- textEmbeddingModel(modelId: ExtractModelId<EMBEDDING_MODELS>): EmbeddingModel<string>;
4173
- imageModel(modelId: ExtractModelId<IMAGE_MODELS>): ImageModel;
4173
+ }): ProviderV2 & {
4174
+ languageModel(modelId: ExtractModelId<LANGUAGE_MODELS>): LanguageModelV2;
4175
+ textEmbeddingModel(modelId: ExtractModelId<EMBEDDING_MODELS>): EmbeddingModelV2<string>;
4176
+ imageModel(modelId: ExtractModelId<IMAGE_MODELS>): ImageModelV2;
4174
4177
  };
4175
4178
  /**
4176
4179
  * @deprecated Use `customProvider` instead.
@@ -4195,12 +4198,12 @@ declare class NoSuchProviderError extends NoSuchModelError {
4195
4198
 
4196
4199
  type ExtractLiteralUnion<T> = T extends string ? string extends T ? never : T : never;
4197
4200
  interface ProviderRegistryProvider<PROVIDERS extends Record<string, ProviderV2> = Record<string, ProviderV2>, SEPARATOR extends string = ':'> {
4198
- languageModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${ExtractLiteralUnion<Parameters<NonNullable<PROVIDERS[KEY]['languageModel']>>[0]>}` : never): LanguageModel;
4199
- languageModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${string}` : never): LanguageModel;
4200
- textEmbeddingModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${ExtractLiteralUnion<Parameters<NonNullable<PROVIDERS[KEY]['textEmbeddingModel']>>[0]>}` : never): EmbeddingModel<string>;
4201
- textEmbeddingModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${string}` : never): EmbeddingModel<string>;
4202
- imageModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${ExtractLiteralUnion<Parameters<NonNullable<PROVIDERS[KEY]['imageModel']>>[0]>}` : never): ImageModel;
4203
- imageModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${string}` : never): ImageModel;
4201
+ languageModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${ExtractLiteralUnion<Parameters<NonNullable<PROVIDERS[KEY]['languageModel']>>[0]>}` : never): LanguageModelV2;
4202
+ languageModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${string}` : never): LanguageModelV2;
4203
+ textEmbeddingModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${ExtractLiteralUnion<Parameters<NonNullable<PROVIDERS[KEY]['textEmbeddingModel']>>[0]>}` : never): EmbeddingModelV2<string>;
4204
+ textEmbeddingModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${string}` : never): EmbeddingModelV2<string>;
4205
+ imageModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${ExtractLiteralUnion<Parameters<NonNullable<PROVIDERS[KEY]['imageModel']>>[0]>}` : never): ImageModelV2;
4206
+ imageModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${string}` : never): ImageModelV2;
4204
4207
  }
4205
4208
  /**
4206
4209
  * Creates a registry for the given providers.
@@ -4449,114 +4452,72 @@ interface ChatTransport<MESSAGE_METADATA, DATA_TYPES extends UIDataTypes> {
4449
4452
  requestType: 'generate' | 'resume';
4450
4453
  }) => Promise<ReadableStream<UIMessageStreamPart>>;
4451
4454
  }
4452
- declare class DefaultChatTransport<MESSAGE_METADATA, DATA_TYPES extends UIDataTypes> implements ChatTransport<MESSAGE_METADATA, DATA_TYPES> {
4453
- private api;
4454
- private credentials?;
4455
- private headers?;
4456
- private body?;
4457
- private fetch?;
4458
- private prepareRequestBody?;
4459
- constructor({ api, credentials, headers, body, fetch, prepareRequestBody, }: {
4460
- api: string;
4461
- /**
4462
- * The credentials mode to be used for the fetch request.
4463
- * Possible values are: 'omit', 'same-origin', 'include'.
4464
- * Defaults to 'same-origin'.
4465
- */
4466
- credentials?: RequestCredentials;
4467
- /**
4468
- * HTTP headers to be sent with the API request.
4469
- */
4470
- headers?: Record<string, string> | Headers;
4471
- /**
4472
- * Extra body object to be sent with the API request.
4473
- * @example
4474
- * Send a `sessionId` to the API along with the messages.
4475
- * ```js
4476
- * useChat({
4477
- * body: {
4478
- * sessionId: '123',
4479
- * }
4480
- * })
4481
- * ```
4482
- */
4483
- body?: object;
4484
- /**
4485
- Custom fetch implementation. You can use it as a middleware to intercept requests,
4486
- or to provide a custom fetch implementation for e.g. testing.
4487
- */
4488
- fetch?: FetchFunction;
4489
- /**
4490
- * When a function is provided, it will be used
4491
- * to prepare the request body for the chat API. This can be useful for
4492
- * customizing the request body based on the messages and data in the chat.
4493
- *
4494
- * @param id The id of the chat.
4495
- * @param messages The current messages in the chat.
4496
- * @param requestBody The request body object passed in the chat request.
4497
- */
4498
- prepareRequestBody?: (options: {
4499
- chatId: string;
4500
- messages: UIMessage<MESSAGE_METADATA, DATA_TYPES>[];
4501
- requestBody?: object;
4502
- }) => unknown;
4503
- });
4504
- submitMessages({ chatId, messages, abortController, body, headers, requestType, }: Parameters<ChatTransport<MESSAGE_METADATA, DATA_TYPES>['submitMessages']>[0]): Promise<ReadableStream<UIMessageStreamPart>>;
4505
- }
4506
- declare class TextStreamChatTransport<MESSAGE_METADATA, DATA_TYPES extends UIDataTypes> implements ChatTransport<MESSAGE_METADATA, DATA_TYPES> {
4507
- private api;
4508
- private credentials?;
4509
- private headers?;
4510
- private body?;
4511
- private fetch?;
4512
- private prepareRequestBody?;
4513
- constructor({ api, credentials, headers, body, fetch, prepareRequestBody, }: {
4514
- api: string;
4515
- /**
4516
- * The credentials mode to be used for the fetch request.
4517
- * Possible values are: 'omit', 'same-origin', 'include'.
4518
- * Defaults to 'same-origin'.
4519
- */
4520
- credentials?: RequestCredentials;
4521
- /**
4522
- * HTTP headers to be sent with the API request.
4523
- */
4524
- headers?: Record<string, string> | Headers;
4525
- /**
4526
- * Extra body object to be sent with the API request.
4527
- * @example
4528
- * Send a `sessionId` to the API along with the messages.
4529
- * ```js
4530
- * useChat({
4531
- * body: {
4532
- * sessionId: '123',
4533
- * }
4534
- * })
4535
- * ```
4536
- */
4537
- body?: object;
4538
- /**
4539
- Custom fetch implementation. You can use it as a middleware to intercept requests,
4540
- or to provide a custom fetch implementation for e.g. testing.
4541
- */
4542
- fetch?: FetchFunction;
4543
- /**
4544
- * When a function is provided, it will be used
4545
- * to prepare the request body for the chat API. This can be useful for
4546
- * customizing the request body based on the messages and data in the chat.
4547
- *
4548
- * @param id The id of the chat.
4549
- * @param messages The current messages in the chat.
4550
- * @param requestBody The request body object passed in the chat request.
4551
- */
4552
- prepareRequestBody?: (options: {
4553
- chatId: string;
4554
- messages: UIMessage<MESSAGE_METADATA, DATA_TYPES>[];
4555
- requestBody?: object;
4556
- }) => unknown;
4557
- });
4558
- submitMessages({ chatId, messages, abortController, body, headers, requestType, }: Parameters<ChatTransport<MESSAGE_METADATA, DATA_TYPES>['submitMessages']>[0]): Promise<ReadableStream<UIMessageStreamPart>>;
4559
- }
4455
+
4456
+ type ChatRequestOptions = {
4457
+ /**
4458
+ Additional headers that should be to be passed to the API endpoint.
4459
+ */
4460
+ headers?: Record<string, string> | Headers;
4461
+ /**
4462
+ Additional body JSON properties that should be sent to the API endpoint.
4463
+ */
4464
+ body?: object;
4465
+ };
4466
+ type UseChatOptions<MESSAGE_METADATA = unknown, DATA_TYPE_SCHEMAS extends UIDataPartSchemas = UIDataPartSchemas> = {
4467
+ /**
4468
+ * A unique identifier for the chat. If not provided, a random one will be
4469
+ * generated. When provided, the `useChat` hook with the same `id` will
4470
+ * have shared states across components.
4471
+ */
4472
+ chatId?: string;
4473
+ /**
4474
+ * Initial input of the chat.
4475
+ */
4476
+ initialInput?: string;
4477
+ /**
4478
+ Optional callback function that is invoked when a tool call is received.
4479
+ Intended for automatic client-side tool execution.
4480
+
4481
+ You can optionally return a result for the tool call,
4482
+ either synchronously or asynchronously.
4483
+ */
4484
+ onToolCall?: ({ toolCall, }: {
4485
+ toolCall: ToolCall<string, unknown>;
4486
+ }) => void | Promise<unknown> | unknown;
4487
+ /**
4488
+ * Optional callback function that is called when the assistant message is finished streaming.
4489
+ *
4490
+ * @param message The message that was streamed.
4491
+ */
4492
+ onFinish?: (options: {
4493
+ message: UIMessage<MESSAGE_METADATA, InferUIDataParts<DATA_TYPE_SCHEMAS>>;
4494
+ }) => void;
4495
+ /**
4496
+ * Callback function to be called when an error is encountered.
4497
+ */
4498
+ onError?: (error: Error) => void;
4499
+ /**
4500
+ * A way to provide a function that is going to be used for ids for messages and the chat.
4501
+ * If not provided the default AI SDK `generateId` is used.
4502
+ */
4503
+ generateId?: IdGenerator;
4504
+ /**
4505
+ * Chat store that should be used.
4506
+ * It must not change during the component lifecycle.
4507
+ *
4508
+ * When a ChatStore is provided, it will be used as is.
4509
+ * It should be stable and the stability is guaranteed by the user.
4510
+ *
4511
+ * When a function is provided, it will be called to create a new chat store.
4512
+ * The function will be called when the hook is mounted and the chat store will be
4513
+ * created.
4514
+ * The function will be called with the same arguments as the hook is called with.
4515
+ * The function should return a ChatStoreOptions object.
4516
+ *
4517
+ * When no value is provided, a default chat store will be created.
4518
+ */
4519
+ chatStore?: ChatStore<MESSAGE_METADATA, DATA_TYPE_SCHEMAS> | (() => ChatStoreOptions<MESSAGE_METADATA, DATA_TYPE_SCHEMAS>);
4520
+ };
4560
4521
 
4561
4522
  type StreamingUIMessageState<MESSAGE_METADATA = unknown, UI_DATA_PART_SCHEMAS extends UIDataPartSchemas = UIDataPartSchemas> = {
4562
4523
  message: UIMessage<MESSAGE_METADATA, InferUIDataParts<UI_DATA_PART_SCHEMAS>>;
@@ -4564,11 +4525,9 @@ type StreamingUIMessageState<MESSAGE_METADATA = unknown, UI_DATA_PART_SCHEMAS ex
4564
4525
  activeReasoningPart: ReasoningUIPart | undefined;
4565
4526
  partialToolCalls: Record<string, {
4566
4527
  text: string;
4567
- step: number;
4568
4528
  index: number;
4569
4529
  toolName: string;
4570
4530
  }>;
4571
- step: number;
4572
4531
  };
4573
4532
 
4574
4533
  interface ChatStoreSubscriber {
@@ -4704,123 +4663,42 @@ declare class ChatStore<MESSAGE_METADATA = unknown, UI_DATA_PART_SCHEMAS extends
4704
4663
  private triggerRequest;
4705
4664
  }
4706
4665
 
4707
- type ChatRequestOptions = {
4666
+ declare function convertFileListToFileUIParts(files: FileList | undefined): Promise<Array<FileUIPart>>;
4667
+
4668
+ /**
4669
+ Converts an array of messages from useChat into an array of CoreMessages that can be used
4670
+ with the AI core functions (e.g. `streamText`).
4671
+ */
4672
+ declare function convertToModelMessages<TOOLS extends ToolSet = never>(messages: Array<Omit<UIMessage, 'id'>>, options?: {
4673
+ tools?: TOOLS;
4674
+ }): ModelMessage[];
4675
+ /**
4676
+ @deprecated Use `convertToModelMessages` instead.
4677
+ */
4678
+ declare const convertToCoreMessages: typeof convertToModelMessages;
4679
+
4680
+ interface DefaultChatStoreOptions<MESSAGE_METADATA = unknown, UI_DATA_PART_SCHEMAS extends UIDataPartSchemas = UIDataPartSchemas> {
4708
4681
  /**
4709
- Additional headers that should be to be passed to the API endpoint.
4682
+ * Schema for the message metadata. Validates the message metadata.
4683
+ * Message metadata can be undefined or must match the schema.
4710
4684
  */
4711
- headers?: Record<string, string> | Headers;
4685
+ messageMetadataSchema?: Validator<MESSAGE_METADATA> | StandardSchemaV1<MESSAGE_METADATA>;
4712
4686
  /**
4713
- Additional body JSON properties that should be sent to the API endpoint.
4687
+ * Schema for the data types. Validates the data types.
4714
4688
  */
4715
- body?: object;
4716
- };
4717
- type UseChatOptions<MESSAGE_METADATA = unknown, DATA_TYPE_SCHEMAS extends UIDataPartSchemas = UIDataPartSchemas> = {
4689
+ dataPartSchemas?: UI_DATA_PART_SCHEMAS;
4718
4690
  /**
4719
- * A unique identifier for the chat. If not provided, a random one will be
4720
- * generated. When provided, the `useChat` hook with the same `id` will
4721
- * have shared states across components.
4691
+ * The API endpoint that accepts a `{ messages: Message[] }` object and returns
4692
+ * a stream of tokens of the AI chat response.
4693
+ *
4694
+ * Defaults to `/api/chat`
4722
4695
  */
4723
- chatId?: string;
4696
+ api?: string;
4724
4697
  /**
4725
- * Initial input of the chat.
4698
+ * A way to provide a function that is going to be used for ids for messages and the chat.
4699
+ * If not provided the default AI SDK `generateId` is used.
4726
4700
  */
4727
- initialInput?: string;
4728
- /**
4729
- Optional callback function that is invoked when a tool call is received.
4730
- Intended for automatic client-side tool execution.
4731
-
4732
- You can optionally return a result for the tool call,
4733
- either synchronously or asynchronously.
4734
- */
4735
- onToolCall?: ({ toolCall, }: {
4736
- toolCall: ToolCall<string, unknown>;
4737
- }) => void | Promise<unknown> | unknown;
4738
- /**
4739
- * Optional callback function that is called when the assistant message is finished streaming.
4740
- *
4741
- * @param message The message that was streamed.
4742
- */
4743
- onFinish?: (options: {
4744
- message: UIMessage<MESSAGE_METADATA, InferUIDataParts<DATA_TYPE_SCHEMAS>>;
4745
- }) => void;
4746
- /**
4747
- * Callback function to be called when an error is encountered.
4748
- */
4749
- onError?: (error: Error) => void;
4750
- /**
4751
- * A way to provide a function that is going to be used for ids for messages and the chat.
4752
- * If not provided the default AI SDK `generateId` is used.
4753
- */
4754
- generateId?: IdGenerator;
4755
- /**
4756
- * Chat store that should be used.
4757
- * It must not change during the component lifecycle.
4758
- *
4759
- * When a ChatStore is provided, it will be used as is.
4760
- * It should be stable and the stability is guaranteed by the user.
4761
- *
4762
- * When a function is provided, it will be called to create a new chat store.
4763
- * The function will be called when the hook is mounted and the chat store will be
4764
- * created.
4765
- * The function will be called with the same arguments as the hook is called with.
4766
- * The function should return a ChatStoreOptions object.
4767
- *
4768
- * When no value is provided, a default chat store will be created.
4769
- */
4770
- chatStore?: ChatStore<MESSAGE_METADATA, DATA_TYPE_SCHEMAS> | (() => ChatStoreOptions<MESSAGE_METADATA, DATA_TYPE_SCHEMAS>);
4771
- };
4772
- type OriginalUseChatOptions<MESSAGE_METADATA = unknown> = {
4773
- /**
4774
- * Schema for the message metadata. Validates the message metadata.
4775
- * Message metadata can be undefined or must match the schema.
4776
- */
4777
- messageMetadataSchema?: Schema<MESSAGE_METADATA>;
4778
- /**
4779
- * The API endpoint that accepts a `{ messages: Message[] }` object and returns
4780
- * a stream of tokens of the AI chat response. Defaults to `/api/chat`.
4781
- */
4782
- api?: string;
4783
- /**
4784
- * A unique identifier for the chat. If not provided, a random one will be
4785
- * generated. When provided, the `useChat` hook with the same `id` will
4786
- * have shared states across components.
4787
- */
4788
- chatId?: string;
4789
- /**
4790
- * Initial messages of the chat. Useful to load an existing chat history.
4791
- */
4792
- initialMessages?: UIMessage<NoInfer<MESSAGE_METADATA>>[];
4793
- /**
4794
- * Initial input of the chat.
4795
- */
4796
- initialInput?: string;
4797
- /**
4798
- Optional callback function that is invoked when a tool call is received.
4799
- Intended for automatic client-side tool execution.
4800
-
4801
- You can optionally return a result for the tool call,
4802
- either synchronously or asynchronously.
4803
- */
4804
- onToolCall?: ({ toolCall, }: {
4805
- toolCall: ToolCall<string, unknown>;
4806
- }) => void | Promise<unknown> | unknown;
4807
- /**
4808
- * Optional callback function that is called when the assistant message is finished streaming.
4809
- *
4810
- * @param message The message that was streamed.
4811
- */
4812
- onFinish?: (options: {
4813
- message: UIMessage<NoInfer<MESSAGE_METADATA>>;
4814
- }) => void;
4815
- /**
4816
- * Callback function to be called when an error is encountered.
4817
- */
4818
- onError?: (error: Error) => void;
4819
- /**
4820
- * A way to provide a function that is going to be used for ids for messages and the chat.
4821
- * If not provided the default AI SDK `generateId` is used.
4822
- */
4823
- generateId?: IdGenerator;
4701
+ generateId?: IdGenerator;
4824
4702
  /**
4825
4703
  * The credentials mode to be used for the fetch request.
4826
4704
  * Possible values are: 'omit', 'same-origin', 'include'.
@@ -4845,109 +4723,152 @@ type OriginalUseChatOptions<MESSAGE_METADATA = unknown> = {
4845
4723
  */
4846
4724
  body?: object;
4847
4725
  /**
4848
- Streaming protocol that is used. Defaults to `ui-message`.
4849
- */
4850
- streamProtocol?: 'ui-message' | 'text';
4851
- /**
4852
- Custom fetch implementation. You can use it as a middleware to intercept requests,
4853
- or to provide a custom fetch implementation for e.g. testing.
4854
- */
4726
+ Custom fetch implementation. You can use it as a middleware to intercept requests,
4727
+ or to provide a custom fetch implementation for e.g. testing.
4728
+ */
4855
4729
  fetch?: FetchFunction;
4856
4730
  /**
4857
- Maximum number of sequential LLM calls (steps), e.g. when you use tool calls.
4858
- Must be at least 1.
4731
+ Maximum number of sequential LLM calls (steps), e.g. when you use tool calls.
4732
+ Must be at least 1.
4859
4733
 
4860
- A maximum number is required to prevent infinite loops in the case of misconfigured tools.
4734
+ A maximum number is required to prevent infinite loops in the case of misconfigured tools.
4861
4735
 
4862
- By default, it's set to 1, which means that only a single LLM call is made.
4863
- */
4736
+ By default, it's set to 1, which means that only a single LLM call is made.
4737
+ */
4864
4738
  maxSteps?: number;
4865
- };
4866
-
4867
- declare const getOriginalFetch$1: () => typeof fetch;
4868
- declare function callChatApi<MESSAGE_METADATA>({ api, body, streamProtocol, credentials, headers, abortController, onUpdate, onFinish, onToolCall, generateId, fetch, lastMessage, requestType, messageMetadataSchema, }: {
4869
- api: string;
4870
- body: Record<string, any>;
4871
- streamProtocol: 'ui-message' | 'text' | undefined;
4872
- credentials: RequestCredentials | undefined;
4873
- headers: HeadersInit | undefined;
4874
- abortController: (() => AbortController | null) | undefined;
4875
- onUpdate: (options: {
4876
- message: UIMessage<MESSAGE_METADATA>;
4877
- }) => void;
4878
- onFinish: UseChatOptions<MESSAGE_METADATA>['onFinish'];
4879
- onToolCall: UseChatOptions<MESSAGE_METADATA>['onToolCall'];
4880
- generateId: IdGenerator;
4881
- fetch: ReturnType<typeof getOriginalFetch$1> | undefined;
4882
- lastMessage: UIMessage<MESSAGE_METADATA> | undefined;
4883
- requestType?: 'generate' | 'resume';
4884
- messageMetadataSchema?: Schema<MESSAGE_METADATA>;
4885
- }): Promise<void>;
4886
-
4887
- declare const getOriginalFetch: () => typeof fetch;
4888
- declare function callCompletionApi({ api, prompt, credentials, headers, body, streamProtocol, setCompletion, setLoading, setError, setAbortController, onFinish, onError, fetch, }: {
4889
- api: string;
4890
- prompt: string;
4891
- credentials: RequestCredentials | undefined;
4892
- headers: HeadersInit | undefined;
4893
- body: Record<string, any>;
4894
- streamProtocol: 'data' | 'text' | undefined;
4895
- setCompletion: (completion: string) => void;
4896
- setLoading: (loading: boolean) => void;
4897
- setError: (error: Error | undefined) => void;
4898
- setAbortController: (abortController: AbortController | null) => void;
4899
- onFinish: ((prompt: string, completion: string) => void) | undefined;
4900
- onError: ((error: Error) => void) | undefined;
4901
- fetch: ReturnType<typeof getOriginalFetch> | undefined;
4902
- }): Promise<string | null | undefined>;
4903
-
4904
- declare function convertFileListToFileUIParts(files: FileList | undefined): Promise<Array<FileUIPart>>;
4905
-
4906
- /**
4907
- Converts an array of messages from useChat into an array of CoreMessages that can be used
4908
- with the AI core functions (e.g. `streamText`).
4909
- */
4910
- declare function convertToModelMessages<TOOLS extends ToolSet = never>(messages: Array<Omit<UIMessage, 'id'>>, options?: {
4911
- tools?: TOOLS;
4912
- }): ModelMessage[];
4913
- /**
4914
- @deprecated Use `convertToModelMessages` instead.
4915
- */
4916
- declare const convertToCoreMessages: typeof convertToModelMessages;
4739
+ /**
4740
+ * When a function is provided, it will be used
4741
+ * to prepare the request body for the chat API. This can be useful for
4742
+ * customizing the request body based on the messages and data in the chat.
4743
+ *
4744
+ * @param chatId The id of the chat.
4745
+ * @param messages The current messages in the chat.
4746
+ * @param requestBody The request body object passed in the chat request.
4747
+ */
4748
+ prepareRequestBody?: (options: {
4749
+ chatId: string;
4750
+ messages: UIMessage<MESSAGE_METADATA, InferUIDataParts<UI_DATA_PART_SCHEMAS>>[];
4751
+ requestBody?: object;
4752
+ }) => unknown;
4753
+ chats?: {
4754
+ [id: string]: {
4755
+ messages: UIMessage<MESSAGE_METADATA, InferUIDataParts<UI_DATA_PART_SCHEMAS>>[];
4756
+ };
4757
+ };
4758
+ }
4759
+ declare function defaultChatStoreOptions<MESSAGE_METADATA = unknown, UI_DATA_PART_SCHEMAS extends UIDataPartSchemas = UIDataPartSchemas>({ api, fetch, credentials, headers, body, prepareRequestBody, generateId, messageMetadataSchema, maxSteps, dataPartSchemas, chats, }: DefaultChatStoreOptions<MESSAGE_METADATA, UI_DATA_PART_SCHEMAS>): () => ChatStoreOptions<MESSAGE_METADATA, UI_DATA_PART_SCHEMAS>;
4917
4760
 
4918
- declare function extractMaxToolInvocationStep(toolInvocations: ToolInvocation[] | undefined): number | undefined;
4761
+ declare class DefaultChatTransport<MESSAGE_METADATA, DATA_TYPES extends UIDataTypes> implements ChatTransport<MESSAGE_METADATA, DATA_TYPES> {
4762
+ private api;
4763
+ private credentials?;
4764
+ private headers?;
4765
+ private body?;
4766
+ private fetch?;
4767
+ private prepareRequestBody?;
4768
+ constructor({ api, credentials, headers, body, fetch, prepareRequestBody, }: {
4769
+ api: string;
4770
+ /**
4771
+ * The credentials mode to be used for the fetch request.
4772
+ * Possible values are: 'omit', 'same-origin', 'include'.
4773
+ * Defaults to 'same-origin'.
4774
+ */
4775
+ credentials?: RequestCredentials;
4776
+ /**
4777
+ * HTTP headers to be sent with the API request.
4778
+ */
4779
+ headers?: Record<string, string> | Headers;
4780
+ /**
4781
+ * Extra body object to be sent with the API request.
4782
+ * @example
4783
+ * Send a `sessionId` to the API along with the messages.
4784
+ * ```js
4785
+ * useChat({
4786
+ * body: {
4787
+ * sessionId: '123',
4788
+ * }
4789
+ * })
4790
+ * ```
4791
+ */
4792
+ body?: object;
4793
+ /**
4794
+ Custom fetch implementation. You can use it as a middleware to intercept requests,
4795
+ or to provide a custom fetch implementation for e.g. testing.
4796
+ */
4797
+ fetch?: FetchFunction;
4798
+ /**
4799
+ * When a function is provided, it will be used
4800
+ * to prepare the request body for the chat API. This can be useful for
4801
+ * customizing the request body based on the messages and data in the chat.
4802
+ *
4803
+ * @param id The id of the chat.
4804
+ * @param messages The current messages in the chat.
4805
+ * @param requestBody The request body object passed in the chat request.
4806
+ */
4807
+ prepareRequestBody?: (options: {
4808
+ chatId: string;
4809
+ messages: UIMessage<MESSAGE_METADATA, DATA_TYPES>[];
4810
+ requestBody?: object;
4811
+ }) => unknown;
4812
+ });
4813
+ submitMessages({ chatId, messages, abortController, body, headers, requestType, }: Parameters<ChatTransport<MESSAGE_METADATA, DATA_TYPES>['submitMessages']>[0]): Promise<ReadableStream<UIMessageStreamPart>>;
4814
+ }
4919
4815
 
4920
4816
  declare function getToolInvocations(message: UIMessage): ToolInvocation[];
4921
4817
 
4922
- declare function shouldResubmitMessages({ originalMaxToolInvocationStep, originalMessageCount, maxSteps, messages, }: {
4923
- originalMaxToolInvocationStep: number | undefined;
4924
- originalMessageCount: number;
4925
- maxSteps: number;
4926
- messages: UIMessage[];
4927
- }): boolean;
4928
- /**
4929
- Check if the message is an assistant message with completed tool calls.
4930
- The last step of the message must have at least one tool invocation and
4931
- all tool invocations must have a result.
4932
- */
4933
- declare function isAssistantMessageWithCompletedToolCalls(message: UIMessage): message is UIMessage & {
4934
- role: 'assistant';
4935
- };
4936
-
4937
- /**
4938
- * Updates the result of a specific tool invocation in the last message of the given messages array.
4939
- *
4940
- * @param {object} params - The parameters object.
4941
- * @param {UIMessage[]} params.messages - An array of messages, from which the last one is updated.
4942
- * @param {string} params.toolCallId - The unique identifier for the tool invocation to update.
4943
- * @param {unknown} params.toolResult - The result object to attach to the tool invocation.
4944
- * @returns {void} This function does not return anything.
4945
- */
4946
- declare function updateToolCallResult({ messages, toolCallId, toolResult: result, }: {
4947
- messages: UIMessage[];
4948
- toolCallId: string;
4949
- toolResult: unknown;
4950
- }): void;
4818
+ declare class TextStreamChatTransport<MESSAGE_METADATA, DATA_TYPES extends UIDataTypes> implements ChatTransport<MESSAGE_METADATA, DATA_TYPES> {
4819
+ private api;
4820
+ private credentials?;
4821
+ private headers?;
4822
+ private body?;
4823
+ private fetch?;
4824
+ private prepareRequestBody?;
4825
+ constructor({ api, credentials, headers, body, fetch, prepareRequestBody, }: {
4826
+ api: string;
4827
+ /**
4828
+ * The credentials mode to be used for the fetch request.
4829
+ * Possible values are: 'omit', 'same-origin', 'include'.
4830
+ * Defaults to 'same-origin'.
4831
+ */
4832
+ credentials?: RequestCredentials;
4833
+ /**
4834
+ * HTTP headers to be sent with the API request.
4835
+ */
4836
+ headers?: Record<string, string> | Headers;
4837
+ /**
4838
+ * Extra body object to be sent with the API request.
4839
+ * @example
4840
+ * Send a `sessionId` to the API along with the messages.
4841
+ * ```js
4842
+ * useChat({
4843
+ * body: {
4844
+ * sessionId: '123',
4845
+ * }
4846
+ * })
4847
+ * ```
4848
+ */
4849
+ body?: object;
4850
+ /**
4851
+ Custom fetch implementation. You can use it as a middleware to intercept requests,
4852
+ or to provide a custom fetch implementation for e.g. testing.
4853
+ */
4854
+ fetch?: FetchFunction;
4855
+ /**
4856
+ * When a function is provided, it will be used
4857
+ * to prepare the request body for the chat API. This can be useful for
4858
+ * customizing the request body based on the messages and data in the chat.
4859
+ *
4860
+ * @param id The id of the chat.
4861
+ * @param messages The current messages in the chat.
4862
+ * @param requestBody The request body object passed in the chat request.
4863
+ */
4864
+ prepareRequestBody?: (options: {
4865
+ chatId: string;
4866
+ messages: UIMessage<MESSAGE_METADATA, DATA_TYPES>[];
4867
+ requestBody?: object;
4868
+ }) => unknown;
4869
+ });
4870
+ submitMessages({ chatId, messages, abortController, body, headers, requestType, }: Parameters<ChatTransport<MESSAGE_METADATA, DATA_TYPES>['submitMessages']>[0]): Promise<ReadableStream<UIMessageStreamPart>>;
4871
+ }
4951
4872
 
4952
4873
  type CompletionRequestOptions = {
4953
4874
  /**
@@ -5021,85 +4942,4 @@ type UseCompletionOptions = {
5021
4942
  fetch?: FetchFunction;
5022
4943
  };
5023
4944
 
5024
- interface DefaultChatStoreOptions<MESSAGE_METADATA = unknown, UI_DATA_PART_SCHEMAS extends UIDataPartSchemas = UIDataPartSchemas> {
5025
- /**
5026
- * Schema for the message metadata. Validates the message metadata.
5027
- * Message metadata can be undefined or must match the schema.
5028
- */
5029
- messageMetadataSchema?: Validator<MESSAGE_METADATA> | StandardSchemaV1<MESSAGE_METADATA>;
5030
- /**
5031
- * Schema for the data types. Validates the data types.
5032
- */
5033
- dataPartSchemas?: UI_DATA_PART_SCHEMAS;
5034
- /**
5035
- * The API endpoint that accepts a `{ messages: Message[] }` object and returns
5036
- * a stream of tokens of the AI chat response.
5037
- *
5038
- * Defaults to `/api/chat`
5039
- */
5040
- api?: string;
5041
- /**
5042
- * A way to provide a function that is going to be used for ids for messages and the chat.
5043
- * If not provided the default AI SDK `generateId` is used.
5044
- */
5045
- generateId?: IdGenerator;
5046
- /**
5047
- * The credentials mode to be used for the fetch request.
5048
- * Possible values are: 'omit', 'same-origin', 'include'.
5049
- * Defaults to 'same-origin'.
5050
- */
5051
- credentials?: RequestCredentials;
5052
- /**
5053
- * HTTP headers to be sent with the API request.
5054
- */
5055
- headers?: Record<string, string> | Headers;
5056
- /**
5057
- * Extra body object to be sent with the API request.
5058
- * @example
5059
- * Send a `sessionId` to the API along with the messages.
5060
- * ```js
5061
- * useChat({
5062
- * body: {
5063
- * sessionId: '123',
5064
- * }
5065
- * })
5066
- * ```
5067
- */
5068
- body?: object;
5069
- /**
5070
- Custom fetch implementation. You can use it as a middleware to intercept requests,
5071
- or to provide a custom fetch implementation for e.g. testing.
5072
- */
5073
- fetch?: FetchFunction;
5074
- /**
5075
- Maximum number of sequential LLM calls (steps), e.g. when you use tool calls.
5076
- Must be at least 1.
5077
-
5078
- A maximum number is required to prevent infinite loops in the case of misconfigured tools.
5079
-
5080
- By default, it's set to 1, which means that only a single LLM call is made.
5081
- */
5082
- maxSteps?: number;
5083
- /**
5084
- * When a function is provided, it will be used
5085
- * to prepare the request body for the chat API. This can be useful for
5086
- * customizing the request body based on the messages and data in the chat.
5087
- *
5088
- * @param chatId The id of the chat.
5089
- * @param messages The current messages in the chat.
5090
- * @param requestBody The request body object passed in the chat request.
5091
- */
5092
- prepareRequestBody?: (options: {
5093
- chatId: string;
5094
- messages: UIMessage<MESSAGE_METADATA, InferUIDataParts<UI_DATA_PART_SCHEMAS>>[];
5095
- requestBody?: object;
5096
- }) => unknown;
5097
- chats?: {
5098
- [id: string]: {
5099
- messages: UIMessage<MESSAGE_METADATA, InferUIDataParts<UI_DATA_PART_SCHEMAS>>[];
5100
- };
5101
- };
5102
- }
5103
- declare function defaultChatStoreOptions<MESSAGE_METADATA = unknown, UI_DATA_PART_SCHEMAS extends UIDataPartSchemas = UIDataPartSchemas>({ api, fetch, credentials, headers, body, prepareRequestBody, generateId, messageMetadataSchema, maxSteps, dataPartSchemas, chats, }: DefaultChatStoreOptions<MESSAGE_METADATA, UI_DATA_PART_SCHEMAS>): () => ChatStoreOptions<MESSAGE_METADATA, UI_DATA_PART_SCHEMAS>;
5104
-
5105
- export { ActiveResponse, AssistantContent, AssistantModelMessage, CallSettings, CallWarning, Chat, ChatRequestOptions, ChatStatus, ChatStore, ChatStoreEvent, ChatStoreFactory, ChatStoreOptions, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataContent, DataUIPart, DeepPartial, DefaultChatStoreOptions, DefaultChatTransport, DownloadError, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FilePart, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, ImagePart, InferUIDataParts, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolArgumentsError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, ModelMessage, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, OriginalUseChatOptions, output as Output, PrepareStepFunction, Prompt, Provider, ProviderMetadata, ProviderOptions, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RetryError, SerialJobExecutor, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, SystemModelMessage, TelemetrySettings, TextPart, TextStreamChatTransport, TextStreamPart, TextUIPart, Tool, ToolCallPart, ToolCallRepairError, ToolCallRepairFunction, ToolCallUnion, ToolChoice, ToolContent, ToolExecutionError, ToolExecutionOptions, ToolInvocation, ToolInvocationUIPart, ToolModelMessage, ToolResultPart, ToolResultUnion, ToolSet, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessagePart, UIMessageStreamOptions, UIMessageStreamPart, UIMessageStreamWriter, UseChatOptions, UseCompletionOptions, UserContent, UserModelMessage, appendClientMessage, assistantModelMessageSchema, callChatApi, callCompletionApi, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultChatStoreOptions, defaultSettingsMiddleware, embed, embedMany, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractMaxToolInvocationStep, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolInvocations, hasToolCall, isAssistantMessageWithCompletedToolCalls, isDeepEqualData, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, shouldResubmitMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, tool, toolModelMessageSchema, updateToolCallResult, userModelMessageSchema, wrapLanguageModel };
4945
+ export { ActiveResponse, AssistantContent, AssistantModelMessage, CallSettings, CallWarning, Chat, ChatRequestOptions, ChatStatus, ChatStore, ChatStoreEvent, ChatStoreFactory, ChatStoreOptions, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataContent, DataUIPart, DeepPartial, DefaultChatStoreOptions, DefaultChatTransport, DownloadError, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FilePart, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, ImagePart, InferUIDataParts, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolArgumentsError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, ModelMessage, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderOptions, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RetryError, SerialJobExecutor, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, SystemModelMessage, TelemetrySettings, TextPart, TextStreamChatTransport, TextStreamPart, TextUIPart, Tool, ToolCallPart, ToolCallRepairError, ToolCallRepairFunction, ToolCallUnion, ToolChoice, ToolContent, ToolExecutionError, ToolExecutionOptions, ToolInvocation, ToolInvocationUIPart, ToolModelMessage, ToolResultPart, ToolResultUnion, ToolSet, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessagePart, UIMessageStreamOptions, UIMessageStreamPart, UIMessageStreamWriter, UseChatOptions, UseCompletionOptions, UserContent, UserModelMessage, assistantModelMessageSchema, callCompletionApi, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultChatStoreOptions, defaultSettingsMiddleware, embed, embedMany, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolInvocations, hasToolCall, isDeepEqualData, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, tool, toolModelMessageSchema, userModelMessageSchema, wrapLanguageModel };