@mastra/schema-compat 1.2.4 → 1.2.5

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.
@@ -229,10 +229,30 @@ CALL_OPTIONS
229
229
  * Timeout in milliseconds. Can be specified as a number or as an object with `totalMs`.
230
230
  */
231
231
  timeout?: TimeoutConfiguration;
232
+ /**
233
+ * Callback that is called when the agent operation begins, before any LLM calls.
234
+ */
235
+ experimental_onStart?: ToolLoopAgentOnStartCallback<TOOLS>;
236
+ /**
237
+ * Callback that is called when a step (LLM call) begins, before the provider is called.
238
+ */
239
+ experimental_onStepStart?: ToolLoopAgentOnStepStartCallback<TOOLS>;
240
+ /**
241
+ * Callback that is called before each tool execution begins.
242
+ */
243
+ experimental_onToolCallStart?: ToolLoopAgentOnToolCallStartCallback<TOOLS>;
244
+ /**
245
+ * Callback that is called after each tool execution completes.
246
+ */
247
+ experimental_onToolCallFinish?: ToolLoopAgentOnToolCallFinishCallback<TOOLS>;
232
248
  /**
233
249
  * Callback that is called when each step (LLM call) is finished, including intermediate steps.
234
250
  */
235
251
  onStepFinish?: ToolLoopAgentOnStepFinishCallback<TOOLS>;
252
+ /**
253
+ * Callback that is called when all steps are finished and the response is complete.
254
+ */
255
+ onFinish?: ToolLoopAgentOnFinishCallback<TOOLS>;
236
256
  };
237
257
 
238
258
  /**
@@ -380,6 +400,7 @@ declare namespace _ai_sdk_provider_utils {
380
400
  EventSourceParserStream,
381
401
  AssistantContent,
382
402
  AssistantModelMessage,
403
+ DEFAULT_MAX_DOWNLOAD_SIZE,
383
404
  DataContent,
384
405
  DelayedPromise,
385
406
  DownloadError,
@@ -467,11 +488,14 @@ declare namespace _ai_sdk_provider_utils {
467
488
  postFormDataToApi,
468
489
  postJsonToApi,
469
490
  postToApi,
491
+ readResponseWithSizeLimit,
470
492
  removeUndefinedEntries,
471
493
  resolve,
472
494
  safeParseJSON,
473
495
  safeValidateTypes,
496
+ stripFileExtension,
474
497
  tool,
498
+ validateDownloadUrl,
475
499
  validateTypes,
476
500
  withUserAgentSuffix,
477
501
  withoutTrailingSlash,
@@ -593,6 +617,23 @@ declare type BaseToolCall = {
593
617
  providerMetadata?: ProviderMetadata;
594
618
  };
595
619
 
620
+ /**
621
+ * Wraps a telemetry integration with bound methods.
622
+ * Use this when creating class-based integrations to ensure methods
623
+ * work correctly when passed as callbacks.
624
+ */
625
+ export declare function bindTelemetryIntegration(integration: TelemetryIntegration): TelemetryIntegration;
626
+
627
+ /**
628
+ * Common model information used across callback events.
629
+ */
630
+ declare interface CallbackModelInfo {
631
+ /** The provider identifier (e.g., 'openai', 'anthropic'). */
632
+ readonly provider: string;
633
+ /** The specific model identifier (e.g., 'gpt-4o'). */
634
+ readonly modelId: string;
635
+ }
636
+
596
637
  export declare function callCompletionApi({ api, prompt, credentials, headers, body, streamProtocol, setCompletion, setLoading, setError, setAbortController, onFinish, onError, fetch, }: {
597
638
  api: string;
598
639
  prompt: string;
@@ -1115,6 +1156,23 @@ export declare function createAgentUIStreamResponse<CALL_OPTIONS = never, TOOLS
1115
1156
 
1116
1157
  declare const createBinaryResponseHandler: () => ResponseHandler<Uint8Array>;
1117
1158
 
1159
+ /**
1160
+ * Creates a download function with configurable options.
1161
+ *
1162
+ * @param options - Configuration options for the download function.
1163
+ * @param options.maxBytes - Maximum allowed download size in bytes. Default: 2 GiB.
1164
+ * @returns A download function that can be passed to `transcribe()` or `experimental_generateVideo()`.
1165
+ */
1166
+ export declare function createDownload(options?: {
1167
+ maxBytes?: number;
1168
+ }): ({ url, abortSignal }: {
1169
+ url: URL;
1170
+ abortSignal?: AbortSignal;
1171
+ }) => Promise<{
1172
+ data: Uint8Array<ArrayBufferLike>;
1173
+ mediaType: string | undefined;
1174
+ }>;
1175
+
1118
1176
  declare const createEventSourceResponseHandler: <T>(chunkSchema: FlexibleSchema<T>) => ResponseHandler<ReadableStream<ParseResult<T>>>;
1119
1177
 
1120
1178
  /**
@@ -1210,7 +1268,7 @@ export declare function createTextStreamResponse({ status, statusText, headers,
1210
1268
  * @param tools - Tools that were passed to the language model.
1211
1269
  * @param providerToolNames - Maps the provider tool ids to the provider tool names.
1212
1270
  */
1213
- declare function createToolNameMapping({ tools, providerToolNames, }: {
1271
+ declare function createToolNameMapping({ tools, providerToolNames, resolveProviderToolName, }: {
1214
1272
  /**
1215
1273
  * Tools that were passed to the language model.
1216
1274
  */
@@ -1219,6 +1277,11 @@ declare function createToolNameMapping({ tools, providerToolNames, }: {
1219
1277
  * Maps the provider tool ids to the provider tool names.
1220
1278
  */
1221
1279
  providerToolNames: Record<`${string}.${string}`, string>;
1280
+ /**
1281
+ * Optional resolver for provider tool names that cannot be represented as
1282
+ * static id -> name mappings (e.g. dynamic provider names).
1283
+ */
1284
+ resolveProviderToolName?: (tool: LanguageModelV3ProviderTool) => string | undefined;
1222
1285
  }): ToolNameMapping;
1223
1286
 
1224
1287
  export declare type CreateUIMessage<UI_MESSAGE extends UIMessage> = Omit<UI_MESSAGE, 'id' | 'role'> & {
@@ -1233,12 +1296,13 @@ export declare type CreateUIMessage<UI_MESSAGE extends UIMessage> = Omit<UI_MESS
1233
1296
  * @param options.onError - A function that extracts an error message from an error. Defaults to `getErrorMessage`.
1234
1297
  * @param options.originalMessages - The original messages. If provided, persistence mode is assumed
1235
1298
  * and a message ID is provided for the response message.
1299
+ * @param options.onStepFinish - A callback that is called when each step finishes. Useful for persisting intermediate messages.
1236
1300
  * @param options.onFinish - A callback that is called when the stream finishes.
1237
1301
  * @param options.generateId - A function that generates a unique ID. Defaults to the built-in ID generator.
1238
1302
  *
1239
1303
  * @returns A `ReadableStream` of UI message chunks.
1240
1304
  */
1241
- export declare function createUIMessageStream<UI_MESSAGE extends UIMessage>({ execute, onError, originalMessages, onFinish, generateId, }: {
1305
+ export declare function createUIMessageStream<UI_MESSAGE extends UIMessage>({ execute, onError, originalMessages, onStepFinish, onFinish, generateId, }: {
1242
1306
  execute: (options: {
1243
1307
  writer: UIMessageStreamWriter<UI_MESSAGE>;
1244
1308
  }) => Promise<void> | void;
@@ -1248,6 +1312,10 @@ export declare function createUIMessageStream<UI_MESSAGE extends UIMessage>({ ex
1248
1312
  * and a message ID is provided for the response message.
1249
1313
  */
1250
1314
  originalMessages?: UI_MESSAGE[];
1315
+ /**
1316
+ * Callback that is called when each step finishes during multi-step agent runs.
1317
+ */
1318
+ onStepFinish?: UIMessageStreamOnStepFinishCallback<UI_MESSAGE>;
1251
1319
  onFinish?: UIMessageStreamOnFinishCallback<UI_MESSAGE>;
1252
1320
  generateId?: IdGenerator;
1253
1321
  }): ReadableStream<InferUIMessageChunk<UI_MESSAGE>>;
@@ -1283,13 +1351,14 @@ export declare function createUIMessageStreamResponse({ status, statusText, head
1283
1351
  *
1284
1352
  * @throws {NoSuchModelError} Throws when a requested model is not found and no fallback provider is available.
1285
1353
  */
1286
- export declare function customProvider<LANGUAGE_MODELS extends Record<string, LanguageModelV3>, EMBEDDING_MODELS extends Record<string, EmbeddingModelV3>, IMAGE_MODELS extends Record<string, ImageModelV3>, TRANSCRIPTION_MODELS extends Record<string, TranscriptionModelV3>, SPEECH_MODELS extends Record<string, SpeechModelV3>, RERANKING_MODELS extends Record<string, RerankingModelV3>>({ languageModels, embeddingModels, imageModels, transcriptionModels, speechModels, rerankingModels, fallbackProvider: fallbackProviderArg, }: {
1354
+ export declare function customProvider<LANGUAGE_MODELS extends Record<string, LanguageModelV3>, EMBEDDING_MODELS extends Record<string, EmbeddingModelV3>, IMAGE_MODELS extends Record<string, ImageModelV3>, TRANSCRIPTION_MODELS extends Record<string, TranscriptionModelV3>, SPEECH_MODELS extends Record<string, SpeechModelV3>, RERANKING_MODELS extends Record<string, RerankingModelV3>, VIDEO_MODELS extends Record<string, VideoModelV3>>({ languageModels, embeddingModels, imageModels, transcriptionModels, speechModels, rerankingModels, videoModels, fallbackProvider: fallbackProviderArg, }: {
1287
1355
  languageModels?: LANGUAGE_MODELS;
1288
1356
  embeddingModels?: EMBEDDING_MODELS;
1289
1357
  imageModels?: IMAGE_MODELS;
1290
1358
  transcriptionModels?: TRANSCRIPTION_MODELS;
1291
1359
  speechModels?: SPEECH_MODELS;
1292
1360
  rerankingModels?: RERANKING_MODELS;
1361
+ videoModels?: VIDEO_MODELS;
1293
1362
  fallbackProvider?: ProviderV3 | ProviderV2;
1294
1363
  }): ProviderV3 & {
1295
1364
  languageModel(modelId: ExtractModelId<LANGUAGE_MODELS>): LanguageModelV3;
@@ -1298,6 +1367,7 @@ export declare function customProvider<LANGUAGE_MODELS extends Record<string, La
1298
1367
  transcriptionModel(modelId: ExtractModelId<TRANSCRIPTION_MODELS>): TranscriptionModelV3;
1299
1368
  rerankingModel(modelId: ExtractModelId<RERANKING_MODELS>): RerankingModelV3;
1300
1369
  speechModel(modelId: ExtractModelId<SPEECH_MODELS>): SpeechModelV3;
1370
+ videoModel(modelId: ExtractModelId<VIDEO_MODELS>): VideoModelV3;
1301
1371
  };
1302
1372
 
1303
1373
  /**
@@ -1333,6 +1403,19 @@ export declare type DeepPartial<T> = T extends FlexibleSchema ? DeepPartialInter
1333
1403
 
1334
1404
  declare type DeepPartialInternal<T> = T extends null | undefined | string | number | boolean | symbol | bigint | void | Date | RegExp | ((...arguments_: any[]) => unknown) | (new (...arguments_: any[]) => unknown) ? T : T extends Map<infer KeyType, infer ValueType> ? PartialMap<KeyType, ValueType> : T extends Set<infer ItemType> ? PartialSet<ItemType> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMap<KeyType, ValueType> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySet<ItemType> : T extends object ? T extends ReadonlyArray<infer ItemType> ? ItemType[] extends T ? readonly ItemType[] extends T ? ReadonlyArray<DeepPartialInternal<ItemType | undefined>> : Array<DeepPartialInternal<ItemType | undefined>> : PartialObject<T> : PartialObject<T> : unknown;
1335
1405
 
1406
+ /**
1407
+ * Default maximum download size: 2 GiB.
1408
+ *
1409
+ * `fetch().arrayBuffer()` has ~2x peak memory overhead (undici buffers the
1410
+ * body internally, then creates the JS ArrayBuffer), so very large downloads
1411
+ * risk exceeding the default V8 heap limit on 64-bit systems and terminating
1412
+ * the process with an out-of-memory error.
1413
+ *
1414
+ * Setting this limit converts an unrecoverable OOM crash into a catchable
1415
+ * `DownloadError`.
1416
+ */
1417
+ declare const DEFAULT_MAX_DOWNLOAD_SIZE: number;
1418
+
1336
1419
  export declare class DefaultChatTransport<UI_MESSAGE extends UIMessage> extends HttpChatTransport<UI_MESSAGE> {
1337
1420
  constructor(options?: HttpChatTransportInitOptions<UI_MESSAGE>);
1338
1421
  protected processResponseStream(stream: ReadableStream<Uint8Array<ArrayBufferLike>>): ReadableStream<UIMessageChunk>;
@@ -1461,11 +1544,17 @@ export declare type DirectChatTransportOptions<CALL_OPTIONS, TOOLS extends ToolS
1461
1544
  * Download a file from a URL and return it as a Blob.
1462
1545
  *
1463
1546
  * @param url - The URL to download from.
1547
+ * @param options - Optional settings for the download.
1548
+ * @param options.maxBytes - Maximum allowed download size in bytes. Defaults to 100 MiB.
1549
+ * @param options.abortSignal - An optional abort signal to cancel the download.
1464
1550
  * @returns A Promise that resolves to the downloaded Blob.
1465
1551
  *
1466
- * @throws DownloadError if the download fails.
1552
+ * @throws DownloadError if the download fails or exceeds maxBytes.
1467
1553
  */
1468
- declare function downloadBlob(url: string): Promise<Blob>;
1554
+ declare function downloadBlob(url: string, options?: {
1555
+ maxBytes?: number;
1556
+ abortSignal?: AbortSignal;
1557
+ }): Promise<Blob>;
1469
1558
 
1470
1559
  export declare class DownloadError extends AISDKError {
1471
1560
  private readonly [symbol];
@@ -2368,26 +2457,7 @@ export declare function experimental_generateSpeech({ model, text, voice, output
2368
2457
  headers?: Record<string, string>;
2369
2458
  }): Promise<Experimental_SpeechResult>;
2370
2459
 
2371
- /**
2372
- * Generates videos using a video model.
2373
- *
2374
- * @param model - The video model to use.
2375
- * @param prompt - The prompt that should be used to generate the video.
2376
- * @param n - Number of videos to generate. Default: 1.
2377
- * @param aspectRatio - Aspect ratio of the videos to generate. Must have the format `{width}:{height}`.
2378
- * @param resolution - Resolution of the videos to generate. Must have the format `{width}x{height}`.
2379
- * @param duration - Duration of the video in seconds.
2380
- * @param fps - Frames per second for the video.
2381
- * @param seed - Seed for the video generation.
2382
- * @param providerOptions - Additional provider-specific options that are passed through to the provider
2383
- * as body parameters.
2384
- * @param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
2385
- * @param abortSignal - An optional abort signal that can be used to cancel the call.
2386
- * @param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
2387
- *
2388
- * @returns A result object that contains the generated videos.
2389
- */
2390
- export declare function experimental_generateVideo({ model: modelArg, prompt: promptArg, n, maxVideosPerCall, aspectRatio, resolution, duration, fps, seed, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, }: {
2460
+ export declare function experimental_generateVideo({ model: modelArg, prompt: promptArg, n, maxVideosPerCall, aspectRatio, resolution, duration, fps, seed, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, download: downloadFn, }: {
2391
2461
  /**
2392
2462
  * The video model to use.
2393
2463
  */
@@ -2444,6 +2514,19 @@ export declare function experimental_generateVideo({ model: modelArg, prompt: pr
2444
2514
  * Only applicable for HTTP-based providers.
2445
2515
  */
2446
2516
  headers?: Record<string, string>;
2517
+ /**
2518
+ * Custom download function for fetching videos from URLs.
2519
+ * Use `createDownload()` from `ai` to create a download function with custom size limits.
2520
+ *
2521
+ * @default createDownload() (2 GiB limit)
2522
+ */
2523
+ download?: (options: {
2524
+ url: URL;
2525
+ abortSignal?: AbortSignal;
2526
+ }) => Promise<{
2527
+ data: Uint8Array;
2528
+ mediaType: string | undefined;
2529
+ }>;
2447
2530
  }): Promise<GenerateVideoResult>;
2448
2531
 
2449
2532
  /**
@@ -2469,20 +2552,7 @@ export declare interface Experimental_SpeechResult {
2469
2552
  readonly providerMetadata: Record<string, JSONObject>;
2470
2553
  }
2471
2554
 
2472
- /**
2473
- * Generates transcripts using a transcription model.
2474
- *
2475
- * @param model - The transcription model to use.
2476
- * @param audio - The audio data to transcribe as DataContent (string | Uint8Array | ArrayBuffer | Buffer) or a URL.
2477
- * @param providerOptions - Additional provider-specific options that are passed through to the provider
2478
- * as body parameters.
2479
- * @param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
2480
- * @param abortSignal - An optional abort signal that can be used to cancel the call.
2481
- * @param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
2482
- *
2483
- * @returns A result object that contains the generated transcript.
2484
- */
2485
- export declare function experimental_transcribe({ model, audio, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, }: {
2555
+ export declare function experimental_transcribe({ model, audio, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, download: downloadFn, }: {
2486
2556
  /**
2487
2557
  * The transcription model to use.
2488
2558
  */
@@ -2521,6 +2591,19 @@ export declare function experimental_transcribe({ model, audio, providerOptions,
2521
2591
  * Only applicable for HTTP-based providers.
2522
2592
  */
2523
2593
  headers?: Record<string, string>;
2594
+ /**
2595
+ * Custom download function for fetching audio from URLs.
2596
+ * Use `createDownload()` from `ai` to create a download function with custom size limits.
2597
+ *
2598
+ * @default createDownload() (2 GiB limit)
2599
+ */
2600
+ download?: (options: {
2601
+ url: URL;
2602
+ abortSignal?: AbortSignal;
2603
+ }) => Promise<{
2604
+ data: Uint8Array;
2605
+ mediaType: string | undefined;
2606
+ }>;
2524
2607
  }): Promise<Experimental_TranscriptionResult>;
2525
2608
 
2526
2609
  /**
@@ -2707,13 +2790,13 @@ declare interface GatewayCreditsResponse {
2707
2790
  totalUsed: string;
2708
2791
  }
2709
2792
 
2710
- declare type GatewayEmbeddingModelId = 'alibaba/qwen3-embedding-0.6b' | 'alibaba/qwen3-embedding-4b' | 'alibaba/qwen3-embedding-8b' | 'amazon/titan-embed-text-v2' | 'cohere/embed-v4.0' | 'google/gemini-embedding-001' | 'google/text-embedding-005' | 'google/text-multilingual-embedding-002' | 'mistral/codestral-embed' | 'mistral/mistral-embed' | 'openai/text-embedding-3-large' | 'openai/text-embedding-3-small' | 'openai/text-embedding-ada-002' | 'voyage/voyage-3-large' | 'voyage/voyage-3.5' | 'voyage/voyage-3.5-lite' | 'voyage/voyage-code-2' | 'voyage/voyage-code-3' | 'voyage/voyage-finance-2' | 'voyage/voyage-law-2' | (string & {});
2793
+ declare type GatewayEmbeddingModelId = 'alibaba/qwen3-embedding-0.6b' | 'alibaba/qwen3-embedding-4b' | 'alibaba/qwen3-embedding-8b' | 'amazon/titan-embed-text-v2' | 'cohere/embed-v4.0' | 'google/gemini-embedding-001' | 'google/text-embedding-005' | 'google/text-multilingual-embedding-002' | 'mistral/codestral-embed' | 'mistral/mistral-embed' | 'openai/text-embedding-3-large' | 'openai/text-embedding-3-small' | 'openai/text-embedding-ada-002' | 'voyage/voyage-3-large' | 'voyage/voyage-3.5' | 'voyage/voyage-3.5-lite' | 'voyage/voyage-4' | 'voyage/voyage-4-large' | 'voyage/voyage-4-lite' | 'voyage/voyage-code-2' | 'voyage/voyage-code-3' | 'voyage/voyage-finance-2' | 'voyage/voyage-law-2' | (string & {});
2711
2794
 
2712
2795
  declare interface GatewayFetchMetadataResponse {
2713
2796
  models: GatewayLanguageModelEntry[];
2714
2797
  }
2715
2798
 
2716
- declare type GatewayImageModelId = 'bfl/flux-kontext-max' | 'bfl/flux-kontext-pro' | 'bfl/flux-pro-1.0-fill' | 'bfl/flux-pro-1.1' | 'bfl/flux-pro-1.1-ultra' | 'google/imagen-4.0-fast-generate-001' | 'google/imagen-4.0-generate-001' | 'google/imagen-4.0-ultra-generate-001' | 'recraft/recraft-v2' | 'recraft/recraft-v3' | (string & {});
2799
+ declare type GatewayImageModelId = 'bfl/flux-kontext-max' | 'bfl/flux-kontext-pro' | 'bfl/flux-pro-1.0-fill' | 'bfl/flux-pro-1.1' | 'bfl/flux-pro-1.1-ultra' | 'google/imagen-4.0-fast-generate-001' | 'google/imagen-4.0-generate-001' | 'google/imagen-4.0-ultra-generate-001' | 'openai/gpt-image-1' | 'openai/gpt-image-1-mini' | 'openai/gpt-image-1.5' | 'recraft/recraft-v2' | 'recraft/recraft-v3' | 'recraft/recraft-v4' | 'recraft/recraft-v4-pro' | 'xai/grok-imagine-image' | 'xai/grok-imagine-image-pro' | (string & {});
2717
2800
 
2718
2801
  declare interface GatewayLanguageModelEntry {
2719
2802
  /**
@@ -2759,15 +2842,19 @@ declare interface GatewayLanguageModelEntry {
2759
2842
  /**
2760
2843
  * Optional field to differentiate between model types.
2761
2844
  */
2762
- modelType?: 'language' | 'embedding' | 'image' | null;
2845
+ modelType?: 'language' | 'embedding' | 'image' | 'video' | null;
2763
2846
  }
2764
2847
 
2765
2848
  declare type GatewayLanguageModelSpecification = Pick<LanguageModelV3, 'specificationVersion' | 'provider' | 'modelId'>;
2766
2849
 
2767
- export declare type GatewayModelId = 'alibaba/qwen-3-14b' | 'alibaba/qwen-3-235b' | 'alibaba/qwen-3-30b' | 'alibaba/qwen-3-32b' | 'alibaba/qwen3-235b-a22b-thinking' | 'alibaba/qwen3-coder' | 'alibaba/qwen3-coder-30b-a3b' | 'alibaba/qwen3-coder-plus' | 'alibaba/qwen3-max' | 'alibaba/qwen3-max-preview' | 'alibaba/qwen3-max-thinking' | 'alibaba/qwen3-next-80b-a3b-instruct' | 'alibaba/qwen3-next-80b-a3b-thinking' | 'alibaba/qwen3-vl-instruct' | 'alibaba/qwen3-vl-thinking' | 'amazon/nova-2-lite' | 'amazon/nova-lite' | 'amazon/nova-micro' | 'amazon/nova-pro' | 'anthropic/claude-3-haiku' | 'anthropic/claude-3-opus' | 'anthropic/claude-3.5-haiku' | 'anthropic/claude-3.5-sonnet' | 'anthropic/claude-3.5-sonnet-20240620' | 'anthropic/claude-3.7-sonnet' | 'anthropic/claude-haiku-4.5' | 'anthropic/claude-opus-4' | 'anthropic/claude-opus-4.1' | 'anthropic/claude-opus-4.5' | 'anthropic/claude-sonnet-4' | 'anthropic/claude-sonnet-4.5' | 'arcee-ai/trinity-large-preview' | 'arcee-ai/trinity-mini' | 'bytedance/seed-1.6' | 'bytedance/seed-1.8' | 'cohere/command-a' | 'deepseek/deepseek-r1' | 'deepseek/deepseek-v3' | 'deepseek/deepseek-v3.1' | 'deepseek/deepseek-v3.1-terminus' | 'deepseek/deepseek-v3.2' | 'deepseek/deepseek-v3.2-exp' | 'deepseek/deepseek-v3.2-thinking' | 'google/gemini-2.0-flash' | 'google/gemini-2.0-flash-lite' | 'google/gemini-2.5-flash' | 'google/gemini-2.5-flash-image' | 'google/gemini-2.5-flash-image-preview' | 'google/gemini-2.5-flash-lite' | 'google/gemini-2.5-flash-lite-preview-09-2025' | 'google/gemini-2.5-flash-preview-09-2025' | 'google/gemini-2.5-pro' | 'google/gemini-3-flash' | 'google/gemini-3-pro-image' | 'google/gemini-3-pro-preview' | 'inception/mercury-coder-small' | 'kwaipilot/kat-coder-pro-v1' | 'meituan/longcat-flash-chat' | 'meituan/longcat-flash-thinking' | 'meta/llama-3.1-70b' | 'meta/llama-3.1-8b' | 'meta/llama-3.2-11b' | 'meta/llama-3.2-1b' | 'meta/llama-3.2-3b' | 'meta/llama-3.2-90b' | 'meta/llama-3.3-70b' | 'meta/llama-4-maverick' | 'meta/llama-4-scout' | 'minimax/minimax-m2' | 'minimax/minimax-m2.1' | 'minimax/minimax-m2.1-lightning' | 'mistral/codestral' | 'mistral/devstral-2' | 'mistral/devstral-small' | 'mistral/devstral-small-2' | 'mistral/magistral-medium' | 'mistral/magistral-small' | 'mistral/ministral-14b' | 'mistral/ministral-3b' | 'mistral/ministral-8b' | 'mistral/mistral-large-3' | 'mistral/mistral-medium' | 'mistral/mistral-nemo' | 'mistral/mistral-small' | 'mistral/mixtral-8x22b-instruct' | 'mistral/pixtral-12b' | 'mistral/pixtral-large' | 'moonshotai/kimi-k2' | 'moonshotai/kimi-k2-0905' | 'moonshotai/kimi-k2-thinking' | 'moonshotai/kimi-k2-thinking-turbo' | 'moonshotai/kimi-k2-turbo' | 'moonshotai/kimi-k2.5' | 'morph/morph-v3-fast' | 'morph/morph-v3-large' | 'nvidia/nemotron-3-nano-30b-a3b' | 'nvidia/nemotron-nano-12b-v2-vl' | 'nvidia/nemotron-nano-9b-v2' | 'openai/codex-mini' | 'openai/gpt-3.5-turbo' | 'openai/gpt-3.5-turbo-instruct' | 'openai/gpt-4-turbo' | 'openai/gpt-4.1' | 'openai/gpt-4.1-mini' | 'openai/gpt-4.1-nano' | 'openai/gpt-4o' | 'openai/gpt-4o-mini' | 'openai/gpt-4o-mini-search-preview' | 'openai/gpt-5' | 'openai/gpt-5-chat' | 'openai/gpt-5-codex' | 'openai/gpt-5-mini' | 'openai/gpt-5-nano' | 'openai/gpt-5-pro' | 'openai/gpt-5.1-codex' | 'openai/gpt-5.1-codex-max' | 'openai/gpt-5.1-codex-mini' | 'openai/gpt-5.1-instant' | 'openai/gpt-5.1-thinking' | 'openai/gpt-5.2' | 'openai/gpt-5.2-chat' | 'openai/gpt-5.2-codex' | 'openai/gpt-5.2-pro' | 'openai/gpt-oss-120b' | 'openai/gpt-oss-20b' | 'openai/gpt-oss-safeguard-20b' | 'openai/o1' | 'openai/o3' | 'openai/o3-deep-research' | 'openai/o3-mini' | 'openai/o3-pro' | 'openai/o4-mini' | 'perplexity/sonar' | 'perplexity/sonar-pro' | 'perplexity/sonar-reasoning' | 'perplexity/sonar-reasoning-pro' | 'prime-intellect/intellect-3' | 'vercel/v0-1.0-md' | 'vercel/v0-1.5-md' | 'xai/grok-2-vision' | 'xai/grok-3' | 'xai/grok-3-fast' | 'xai/grok-3-mini' | 'xai/grok-3-mini-fast' | 'xai/grok-4' | 'xai/grok-4-fast-non-reasoning' | 'xai/grok-4-fast-reasoning' | 'xai/grok-4.1-fast-non-reasoning' | 'xai/grok-4.1-fast-reasoning' | 'xai/grok-code-fast-1' | 'xiaomi/mimo-v2-flash' | 'zai/glm-4.5' | 'zai/glm-4.5-air' | 'zai/glm-4.5v' | 'zai/glm-4.6' | 'zai/glm-4.6v' | 'zai/glm-4.6v-flash' | 'zai/glm-4.7' | 'zai/glm-4.7-flashx' | (string & {});
2850
+ export declare type GatewayModelId = 'alibaba/qwen-3-14b' | 'alibaba/qwen-3-235b' | 'alibaba/qwen-3-30b' | 'alibaba/qwen-3-32b' | 'alibaba/qwen3-235b-a22b-thinking' | 'alibaba/qwen3-coder' | 'alibaba/qwen3-coder-30b-a3b' | 'alibaba/qwen3-coder-next' | 'alibaba/qwen3-coder-plus' | 'alibaba/qwen3-max' | 'alibaba/qwen3-max-preview' | 'alibaba/qwen3-max-thinking' | 'alibaba/qwen3-next-80b-a3b-instruct' | 'alibaba/qwen3-next-80b-a3b-thinking' | 'alibaba/qwen3-vl-instruct' | 'alibaba/qwen3-vl-thinking' | 'alibaba/qwen3.5-flash' | 'alibaba/qwen3.5-plus' | 'amazon/nova-2-lite' | 'amazon/nova-lite' | 'amazon/nova-micro' | 'amazon/nova-pro' | 'anthropic/claude-3-haiku' | 'anthropic/claude-3-opus' | 'anthropic/claude-3.5-haiku' | 'anthropic/claude-3.5-sonnet' | 'anthropic/claude-3.5-sonnet-20240620' | 'anthropic/claude-3.7-sonnet' | 'anthropic/claude-haiku-4.5' | 'anthropic/claude-opus-4' | 'anthropic/claude-opus-4.1' | 'anthropic/claude-opus-4.5' | 'anthropic/claude-opus-4.6' | 'anthropic/claude-sonnet-4' | 'anthropic/claude-sonnet-4.5' | 'anthropic/claude-sonnet-4.6' | 'arcee-ai/trinity-large-preview' | 'arcee-ai/trinity-mini' | 'bytedance/seed-1.6' | 'bytedance/seed-1.8' | 'cohere/command-a' | 'deepseek/deepseek-r1' | 'deepseek/deepseek-v3' | 'deepseek/deepseek-v3.1' | 'deepseek/deepseek-v3.1-terminus' | 'deepseek/deepseek-v3.2' | 'deepseek/deepseek-v3.2-thinking' | 'google/gemini-2.0-flash' | 'google/gemini-2.0-flash-lite' | 'google/gemini-2.5-flash' | 'google/gemini-2.5-flash-image' | 'google/gemini-2.5-flash-lite' | 'google/gemini-2.5-flash-lite-preview-09-2025' | 'google/gemini-2.5-flash-preview-09-2025' | 'google/gemini-2.5-pro' | 'google/gemini-3-flash' | 'google/gemini-3-pro-image' | 'google/gemini-3-pro-preview' | 'google/gemini-3.1-flash-image-preview' | 'google/gemini-3.1-flash-lite-preview' | 'google/gemini-3.1-pro-preview' | 'inception/mercury-coder-small' | 'kwaipilot/kat-coder-pro-v1' | 'meituan/longcat-flash-chat' | 'meituan/longcat-flash-thinking' | 'meta/llama-3.1-70b' | 'meta/llama-3.1-8b' | 'meta/llama-3.2-11b' | 'meta/llama-3.2-1b' | 'meta/llama-3.2-3b' | 'meta/llama-3.2-90b' | 'meta/llama-3.3-70b' | 'meta/llama-4-maverick' | 'meta/llama-4-scout' | 'minimax/minimax-m2' | 'minimax/minimax-m2.1' | 'minimax/minimax-m2.1-lightning' | 'minimax/minimax-m2.5' | 'mistral/codestral' | 'mistral/devstral-2' | 'mistral/devstral-small' | 'mistral/devstral-small-2' | 'mistral/magistral-medium' | 'mistral/magistral-small' | 'mistral/ministral-14b' | 'mistral/ministral-3b' | 'mistral/ministral-8b' | 'mistral/mistral-large-3' | 'mistral/mistral-medium' | 'mistral/mistral-nemo' | 'mistral/mistral-small' | 'mistral/mixtral-8x22b-instruct' | 'mistral/pixtral-12b' | 'mistral/pixtral-large' | 'moonshotai/kimi-k2' | 'moonshotai/kimi-k2-0905' | 'moonshotai/kimi-k2-thinking' | 'moonshotai/kimi-k2-thinking-turbo' | 'moonshotai/kimi-k2-turbo' | 'moonshotai/kimi-k2.5' | 'morph/morph-v3-fast' | 'morph/morph-v3-large' | 'nvidia/nemotron-3-nano-30b-a3b' | 'nvidia/nemotron-nano-12b-v2-vl' | 'nvidia/nemotron-nano-9b-v2' | 'openai/codex-mini' | 'openai/gpt-3.5-turbo' | 'openai/gpt-3.5-turbo-instruct' | 'openai/gpt-4-turbo' | 'openai/gpt-4.1' | 'openai/gpt-4.1-mini' | 'openai/gpt-4.1-nano' | 'openai/gpt-4o' | 'openai/gpt-4o-mini' | 'openai/gpt-4o-mini-search-preview' | 'openai/gpt-5' | 'openai/gpt-5-chat' | 'openai/gpt-5-codex' | 'openai/gpt-5-mini' | 'openai/gpt-5-nano' | 'openai/gpt-5-pro' | 'openai/gpt-5.1-codex' | 'openai/gpt-5.1-codex-max' | 'openai/gpt-5.1-codex-mini' | 'openai/gpt-5.1-instant' | 'openai/gpt-5.1-thinking' | 'openai/gpt-5.2' | 'openai/gpt-5.2-chat' | 'openai/gpt-5.2-codex' | 'openai/gpt-5.2-pro' | 'openai/gpt-5.3-chat' | 'openai/gpt-5.3-codex' | 'openai/gpt-oss-120b' | 'openai/gpt-oss-20b' | 'openai/gpt-oss-safeguard-20b' | 'openai/o1' | 'openai/o3' | 'openai/o3-deep-research' | 'openai/o3-mini' | 'openai/o3-pro' | 'openai/o4-mini' | 'perplexity/sonar' | 'perplexity/sonar-pro' | 'perplexity/sonar-reasoning' | 'perplexity/sonar-reasoning-pro' | 'prime-intellect/intellect-3' | 'vercel/v0-1.0-md' | 'vercel/v0-1.5-md' | 'xai/grok-2-vision' | 'xai/grok-3' | 'xai/grok-3-fast' | 'xai/grok-3-mini' | 'xai/grok-3-mini-fast' | 'xai/grok-4' | 'xai/grok-4-fast-non-reasoning' | 'xai/grok-4-fast-reasoning' | 'xai/grok-4.1-fast-non-reasoning' | 'xai/grok-4.1-fast-reasoning' | 'xai/grok-code-fast-1' | 'xiaomi/mimo-v2-flash' | 'zai/glm-4.5' | 'zai/glm-4.5-air' | 'zai/glm-4.5v' | 'zai/glm-4.6' | 'zai/glm-4.6v' | 'zai/glm-4.6v-flash' | 'zai/glm-4.7' | 'zai/glm-4.7-flashx' | 'zai/glm-5' | (string & {});
2768
2851
 
2769
2852
  declare interface GatewayProvider extends ProviderV3 {
2770
2853
  (modelId: GatewayModelId): LanguageModelV3;
2854
+ /**
2855
+ * Creates a model for text generation.
2856
+ */
2857
+ chat(modelId: GatewayModelId): LanguageModelV3;
2771
2858
  /**
2772
2859
  * Creates a model for text generation.
2773
2860
  */
@@ -2780,6 +2867,10 @@ declare interface GatewayProvider extends ProviderV3 {
2780
2867
  * Returns credit information for the authenticated user.
2781
2868
  */
2782
2869
  getCredits(): Promise<GatewayCreditsResponse>;
2870
+ /**
2871
+ * Creates a model for generating text embeddings.
2872
+ */
2873
+ embedding(modelId: GatewayEmbeddingModelId): EmbeddingModelV3;
2783
2874
  /**
2784
2875
  * Creates a model for generating text embeddings.
2785
2876
  */
@@ -2788,10 +2879,22 @@ declare interface GatewayProvider extends ProviderV3 {
2788
2879
  * @deprecated Use `embeddingModel` instead.
2789
2880
  */
2790
2881
  textEmbeddingModel(modelId: GatewayEmbeddingModelId): EmbeddingModelV3;
2882
+ /**
2883
+ * Creates a model for generating images.
2884
+ */
2885
+ image(modelId: GatewayImageModelId): ImageModelV3;
2791
2886
  /**
2792
2887
  * Creates a model for generating images.
2793
2888
  */
2794
2889
  imageModel(modelId: GatewayImageModelId): ImageModelV3;
2890
+ /**
2891
+ * Creates a model for generating videos.
2892
+ */
2893
+ video(modelId: GatewayVideoModelId): VideoModelV3;
2894
+ /**
2895
+ * Creates a model for generating videos.
2896
+ */
2897
+ videoModel(modelId: GatewayVideoModelId): VideoModelV3;
2795
2898
  /**
2796
2899
  * Gateway-specific tools executed server-side.
2797
2900
  */
@@ -2845,6 +2948,8 @@ declare const gatewayTools: {
2845
2948
  perplexitySearch: (config?: PerplexitySearchConfig) => ReturnType<typeof perplexitySearchToolFactory>;
2846
2949
  };
2847
2950
 
2951
+ declare type GatewayVideoModelId = 'alibaba/wan-v2.5-t2v-preview' | 'alibaba/wan-v2.6-i2v' | 'alibaba/wan-v2.6-i2v-flash' | 'alibaba/wan-v2.6-r2v' | 'alibaba/wan-v2.6-r2v-flash' | 'alibaba/wan-v2.6-t2v' | 'bytedance/seedance-v1.0-lite-i2v' | 'bytedance/seedance-v1.0-lite-t2v' | 'bytedance/seedance-v1.0-pro' | 'bytedance/seedance-v1.0-pro-fast' | 'bytedance/seedance-v1.5-pro' | 'google/veo-3.0-fast-generate-001' | 'google/veo-3.0-generate-001' | 'google/veo-3.1-fast-generate-001' | 'google/veo-3.1-generate-001' | 'klingai/kling-v2.5-turbo-i2v' | 'klingai/kling-v2.5-turbo-t2v' | 'klingai/kling-v2.6-i2v' | 'klingai/kling-v2.6-motion-control' | 'klingai/kling-v2.6-t2v' | 'klingai/kling-v3.0-i2v' | 'klingai/kling-v3.0-t2v' | 'xai/grok-imagine-video' | (string & {});
2952
+
2848
2953
  /**
2849
2954
  * A generated audio file.
2850
2955
  */
@@ -3215,13 +3320,21 @@ export declare interface GenerateObjectResult<OBJECT> {
3215
3320
  * @param timeout - An optional timeout in milliseconds. The call will be aborted if it takes longer than the specified timeout.
3216
3321
  * @param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
3217
3322
  *
3323
+ * @param experimental_context - User-defined context object that flows through the entire generation lifecycle.
3324
+ * @param experimental_onStart - Callback invoked when generation begins, before any LLM calls.
3325
+ * @param experimental_onStepStart - Callback invoked when each step begins, before the provider is called.
3326
+ * Receives step number, messages (in ModelMessage format), tools, and context.
3327
+ * @param experimental_onToolCallStart - Callback invoked before each tool execution begins.
3328
+ * Receives tool name, call ID, input, and context.
3329
+ * @param experimental_onToolCallFinish - Callback invoked after each tool execution completes.
3330
+ * Uses a discriminated union: check `success` to determine if `output` or `error` is present.
3218
3331
  * @param onStepFinish - Callback that is called when each step (LLM call) is finished, including intermediate steps.
3219
3332
  * @param onFinish - Callback that is called when all steps are finished and the response is complete.
3220
3333
  *
3221
3334
  * @returns
3222
3335
  * A result object that contains the generated text, the results of the tool calls, and additional information.
3223
3336
  */
3224
- export declare function generateText<TOOLS extends ToolSet, OUTPUT extends Output_2 = Output_2<string, string>>({ model: modelArg, tools, toolChoice, system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools, experimental_prepareStep, prepareStep, experimental_repairToolCall: repairToolCall, experimental_download: download, experimental_context, experimental_include: include, _internal: { generateId }, onStepFinish, onFinish, ...settings }: CallSettings & Prompt & {
3337
+ export declare function generateText<TOOLS extends ToolSet, OUTPUT extends Output_2 = Output_2<string, string>>({ model: modelArg, tools, toolChoice, system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools, experimental_prepareStep, prepareStep, experimental_repairToolCall: repairToolCall, experimental_download: download, experimental_context, experimental_include: include, _internal: { generateId }, experimental_onStart: onStart, experimental_onStepStart: onStepStart, experimental_onToolCallStart: onToolCallStart, experimental_onToolCallFinish: onToolCallFinish, onStepFinish, onFinish, ...settings }: CallSettings & Prompt & {
3225
3338
  /**
3226
3339
  * The language model to use.
3227
3340
  */
@@ -3288,6 +3401,24 @@ export declare function generateText<TOOLS extends ToolSet, OUTPUT extends Outpu
3288
3401
  * A function that attempts to repair a tool call that failed to parse.
3289
3402
  */
3290
3403
  experimental_repairToolCall?: ToolCallRepairFunction<NoInfer<TOOLS>>;
3404
+ /**
3405
+ * Callback that is called when the generateText operation begins,
3406
+ * before any LLM calls are made.
3407
+ */
3408
+ experimental_onStart?: GenerateTextOnStartCallback<NoInfer<TOOLS>, OUTPUT>;
3409
+ /**
3410
+ * Callback that is called when a step (LLM call) begins,
3411
+ * before the provider is called.
3412
+ */
3413
+ experimental_onStepStart?: GenerateTextOnStepStartCallback<NoInfer<TOOLS>, OUTPUT>;
3414
+ /**
3415
+ * Callback that is called right before a tool's execute function runs.
3416
+ */
3417
+ experimental_onToolCallStart?: GenerateTextOnToolCallStartCallback<NoInfer<TOOLS>>;
3418
+ /**
3419
+ * Callback that is called right after a tool's execute function completes (or errors).
3420
+ */
3421
+ experimental_onToolCallFinish?: GenerateTextOnToolCallFinishCallback<NoInfer<TOOLS>>;
3291
3422
  /**
3292
3423
  * Callback that is called when each step (LLM call) is finished, including intermediate steps.
3293
3424
  */
@@ -3332,36 +3463,80 @@ export declare function generateText<TOOLS extends ToolSet, OUTPUT extends Outpu
3332
3463
  };
3333
3464
  }): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
3334
3465
 
3466
+ /**
3467
+ * Include settings for generateText (requestBody and responseBody).
3468
+ */
3469
+ declare type GenerateTextIncludeSettings = {
3470
+ requestBody?: boolean;
3471
+ responseBody?: boolean;
3472
+ };
3473
+
3335
3474
  /**
3336
3475
  * Callback that is set using the `onFinish` option.
3337
3476
  *
3338
- * @param event - The event that is passed to the callback.
3477
+ * Called when the entire generation completes (all steps finished).
3478
+ * The event includes the final step's result properties along with
3479
+ * aggregated data from all steps.
3480
+ *
3481
+ * @param event - The final result along with aggregated step data.
3339
3482
  */
3340
- export declare type GenerateTextOnFinishCallback<TOOLS extends ToolSet> = (event: StepResult<TOOLS> & {
3341
- /**
3342
- * Details for all steps.
3343
- */
3344
- readonly steps: StepResult<TOOLS>[];
3345
- /**
3346
- * Total usage for all steps. This is the sum of the usage of all steps.
3347
- */
3348
- readonly totalUsage: LanguageModelUsage;
3349
- /**
3350
- * Context that is passed into tool execution.
3351
- *
3352
- * Experimental (can break in patch releases).
3353
- *
3354
- * @default undefined
3355
- */
3356
- experimental_context: unknown;
3357
- }) => PromiseLike<void> | void;
3483
+ export declare type GenerateTextOnFinishCallback<TOOLS extends ToolSet> = (event: OnFinishEvent<TOOLS>) => PromiseLike<void> | void;
3484
+
3485
+ /**
3486
+ * Callback that is set using the `experimental_onStart` option.
3487
+ *
3488
+ * Called when the generateText operation begins, before any LLM calls.
3489
+ * Use this callback for logging, analytics, or initializing state at the
3490
+ * start of a generation.
3491
+ *
3492
+ * @param event - The event object containing generation configuration.
3493
+ */
3494
+ export declare type GenerateTextOnStartCallback<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output_2 = Output_2> = (event: OnStartEvent<TOOLS, OUTPUT, GenerateTextIncludeSettings>) => PromiseLike<void> | void;
3358
3495
 
3359
3496
  /**
3360
3497
  * Callback that is set using the `onStepFinish` option.
3361
3498
  *
3499
+ * Called when a step (LLM call) completes. The event includes all step result
3500
+ * properties (text, tool calls, usage, etc.) along with additional metadata.
3501
+ *
3362
3502
  * @param stepResult - The result of the step.
3363
3503
  */
3364
- export declare type GenerateTextOnStepFinishCallback<TOOLS extends ToolSet> = (stepResult: StepResult<TOOLS>) => Promise<void> | void;
3504
+ export declare type GenerateTextOnStepFinishCallback<TOOLS extends ToolSet> = (event: OnStepFinishEvent<TOOLS>) => Promise<void> | void;
3505
+
3506
+ /**
3507
+ * Callback that is set using the `experimental_onStepStart` option.
3508
+ *
3509
+ * Called when a step (LLM call) begins, before the provider is called.
3510
+ * Each step represents a single LLM invocation. Multiple steps occur when
3511
+ * using tool calls (the model may be called multiple times in a loop).
3512
+ *
3513
+ * @param event - The event object containing step configuration.
3514
+ */
3515
+ export declare type GenerateTextOnStepStartCallback<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output_2 = Output_2> = (event: OnStepStartEvent<TOOLS, OUTPUT, GenerateTextIncludeSettings>) => PromiseLike<void> | void;
3516
+
3517
+ /**
3518
+ * Callback that is set using the `experimental_onToolCallFinish` option.
3519
+ *
3520
+ * Called when a tool execution completes, either successfully or with an error.
3521
+ * Use this for logging tool results, tracking execution time, or error handling.
3522
+ *
3523
+ * The event uses a discriminated union on the `success` field:
3524
+ * - When `success: true`: `output` contains the tool result, `error` is never present.
3525
+ * - When `success: false`: `error` contains the error, `output` is never present.
3526
+ *
3527
+ * @param event - The event object containing tool call result information.
3528
+ */
3529
+ export declare type GenerateTextOnToolCallFinishCallback<TOOLS extends ToolSet = ToolSet> = (event: OnToolCallFinishEvent<TOOLS>) => PromiseLike<void> | void;
3530
+
3531
+ /**
3532
+ * Callback that is set using the `experimental_onToolCallStart` option.
3533
+ *
3534
+ * Called when a tool execution begins, before the tool's `execute` function is invoked.
3535
+ * Use this for logging tool invocations, tracking tool usage, or pre-execution validation.
3536
+ *
3537
+ * @param event - The event object containing tool call information.
3538
+ */
3539
+ export declare type GenerateTextOnToolCallStartCallback<TOOLS extends ToolSet = ToolSet> = (event: OnToolCallStartEvent<TOOLS>) => PromiseLike<void> | void;
3365
3540
 
3366
3541
  /**
3367
3542
  * The result of a `generateText` call.
@@ -6714,6 +6889,11 @@ declare interface Link {
6714
6889
  droppedAttributesCount?: number;
6715
6890
  }
6716
6891
 
6892
+ /**
6893
+ * A callback function that can be used to notify listeners.
6894
+ */
6895
+ declare type Listener<EVENT> = (event: EVENT) => PromiseLike<void> | void;
6896
+
6717
6897
  declare function loadApiKey({ apiKey, environmentVariableName, apiKeyParameterName, description, }: {
6718
6898
  apiKey: string | undefined;
6719
6899
  environmentVariableName: string;
@@ -6943,11 +7123,11 @@ export declare class NoSpeechGeneratedError extends AISDKError {
6943
7123
  export declare class NoSuchModelError extends AISDKError {
6944
7124
  private readonly [symbol$3];
6945
7125
  readonly modelId: string;
6946
- readonly modelType: 'languageModel' | 'embeddingModel' | 'imageModel' | 'transcriptionModel' | 'speechModel' | 'rerankingModel';
7126
+ readonly modelType: 'languageModel' | 'embeddingModel' | 'imageModel' | 'transcriptionModel' | 'speechModel' | 'rerankingModel' | 'videoModel';
6947
7127
  constructor({ errorName, modelId, modelType, message, }: {
6948
7128
  errorName?: string;
6949
7129
  modelId: string;
6950
- modelType: 'languageModel' | 'embeddingModel' | 'imageModel' | 'transcriptionModel' | 'speechModel' | 'rerankingModel';
7130
+ modelType: 'languageModel' | 'embeddingModel' | 'imageModel' | 'transcriptionModel' | 'speechModel' | 'rerankingModel' | 'videoModel';
6951
7131
  message?: string;
6952
7132
  });
6953
7133
  static isInstance(error: unknown): error is NoSuchModelError;
@@ -7033,6 +7213,240 @@ export declare type ObjectStreamPart<PARTIAL> = {
7033
7213
  providerMetadata?: ProviderMetadata;
7034
7214
  };
7035
7215
 
7216
+ /**
7217
+ * Event passed to the `onFinish` callback.
7218
+ *
7219
+ * Called when the entire generation completes (all steps finished).
7220
+ * Includes the final step's result along with aggregated data from all steps.
7221
+ */
7222
+ export declare type OnFinishEvent<TOOLS extends ToolSet = ToolSet> = StepResult<TOOLS> & {
7223
+ /** Array containing results from all steps in the generation. */
7224
+ readonly steps: StepResult<TOOLS>[];
7225
+ /** Aggregated token usage across all steps. */
7226
+ readonly totalUsage: LanguageModelUsage;
7227
+ /**
7228
+ * The final state of the user-defined context object.
7229
+ *
7230
+ * Experimental (can break in patch releases).
7231
+ *
7232
+ * @default undefined
7233
+ */
7234
+ experimental_context: unknown;
7235
+ /** Identifier from telemetry settings for grouping related operations. */
7236
+ readonly functionId: string | undefined;
7237
+ /** Additional metadata from telemetry settings. */
7238
+ readonly metadata: Record<string, unknown> | undefined;
7239
+ };
7240
+
7241
+ /**
7242
+ * Event passed to the `onStart` callback.
7243
+ *
7244
+ * Called when the generation operation begins, before any LLM calls.
7245
+ */
7246
+ export declare interface OnStartEvent<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output_2 = Output_2, INCLUDE = {
7247
+ requestBody?: boolean;
7248
+ responseBody?: boolean;
7249
+ }> {
7250
+ /** The model being used for generation. */
7251
+ readonly model: CallbackModelInfo;
7252
+ /** The system message(s) provided to the model. */
7253
+ readonly system: string | SystemModelMessage | Array<SystemModelMessage> | undefined;
7254
+ /** The prompt string or array of messages if using the prompt option. */
7255
+ readonly prompt: string | Array<ModelMessage> | undefined;
7256
+ /** The messages array if using the messages option. */
7257
+ readonly messages: Array<ModelMessage> | undefined;
7258
+ /** The tools available for this generation. */
7259
+ readonly tools: TOOLS | undefined;
7260
+ /** The tool choice strategy for this generation. */
7261
+ readonly toolChoice: ToolChoice<NoInfer<TOOLS>> | undefined;
7262
+ /** Limits which tools are available for the model to call. */
7263
+ readonly activeTools: Array<keyof TOOLS> | undefined;
7264
+ /** Maximum number of tokens to generate. */
7265
+ readonly maxOutputTokens: number | undefined;
7266
+ /** Sampling temperature for generation. */
7267
+ readonly temperature: number | undefined;
7268
+ /** Top-p (nucleus) sampling parameter. */
7269
+ readonly topP: number | undefined;
7270
+ /** Top-k sampling parameter. */
7271
+ readonly topK: number | undefined;
7272
+ /** Presence penalty for generation. */
7273
+ readonly presencePenalty: number | undefined;
7274
+ /** Frequency penalty for generation. */
7275
+ readonly frequencyPenalty: number | undefined;
7276
+ /** Sequences that will stop generation. */
7277
+ readonly stopSequences: string[] | undefined;
7278
+ /** Random seed for reproducible generation. */
7279
+ readonly seed: number | undefined;
7280
+ /** Maximum number of retries for failed requests. */
7281
+ readonly maxRetries: number;
7282
+ /**
7283
+ * Timeout configuration for the generation.
7284
+ * Can be a number (milliseconds) or an object with totalMs, stepMs, chunkMs.
7285
+ */
7286
+ readonly timeout: TimeoutConfiguration | undefined;
7287
+ /** Additional HTTP headers sent with the request. */
7288
+ readonly headers: Record<string, string | undefined> | undefined;
7289
+ /** Additional provider-specific options. */
7290
+ readonly providerOptions: ProviderOptions | undefined;
7291
+ /**
7292
+ * Condition(s) for stopping the generation.
7293
+ * When the condition is an array, any of the conditions can be met to stop.
7294
+ */
7295
+ readonly stopWhen: StopCondition<TOOLS> | Array<StopCondition<TOOLS>> | undefined;
7296
+ /** The output specification for structured outputs, if configured. */
7297
+ readonly output: OUTPUT | undefined;
7298
+ /** Abort signal for cancelling the operation. */
7299
+ readonly abortSignal: AbortSignal | undefined;
7300
+ /**
7301
+ * Settings for controlling what data is included in step results.
7302
+ */
7303
+ readonly include: INCLUDE | undefined;
7304
+ /** Identifier from telemetry settings for grouping related operations. */
7305
+ readonly functionId: string | undefined;
7306
+ /** Additional metadata passed to the generation. */
7307
+ readonly metadata: Record<string, unknown> | undefined;
7308
+ /**
7309
+ * User-defined context object that flows through the entire generation lifecycle.
7310
+ * Can be accessed and modified in `prepareStep` and tool `execute` functions.
7311
+ */
7312
+ readonly experimental_context: unknown;
7313
+ }
7314
+
7315
+ /**
7316
+ * Event passed to the `onStepFinish` callback.
7317
+ *
7318
+ * Called when a step (LLM call) completes.
7319
+ * This is simply the StepResult for that step.
7320
+ */
7321
+ export declare type OnStepFinishEvent<TOOLS extends ToolSet = ToolSet> = StepResult<TOOLS>;
7322
+
7323
+ /**
7324
+ * Event passed to the `onStepStart` callback.
7325
+ *
7326
+ * Called when a step (LLM call) begins, before the provider is called.
7327
+ * Each step represents a single LLM invocation.
7328
+ */
7329
+ export declare interface OnStepStartEvent<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output_2 = Output_2, INCLUDE = {
7330
+ requestBody?: boolean;
7331
+ responseBody?: boolean;
7332
+ }> {
7333
+ /** Zero-based index of the current step. */
7334
+ readonly stepNumber: number;
7335
+ /** The model being used for this step. */
7336
+ readonly model: CallbackModelInfo;
7337
+ /**
7338
+ * The system message for this step.
7339
+ */
7340
+ readonly system: string | SystemModelMessage | Array<SystemModelMessage> | undefined;
7341
+ /**
7342
+ * The messages that will be sent to the model for this step.
7343
+ * Uses the user-facing `ModelMessage` format.
7344
+ * May be overridden by prepareStep.
7345
+ */
7346
+ readonly messages: Array<ModelMessage>;
7347
+ /** The tools available for this generation. */
7348
+ readonly tools: TOOLS | undefined;
7349
+ /** The tool choice configuration for this step. */
7350
+ readonly toolChoice: LanguageModelV3ToolChoice | undefined;
7351
+ /** Limits which tools are available for this step. */
7352
+ readonly activeTools: Array<keyof TOOLS> | undefined;
7353
+ /** Array of results from previous steps (empty for first step). */
7354
+ readonly steps: ReadonlyArray<StepResult<TOOLS>>;
7355
+ /** Additional provider-specific options for this step. */
7356
+ readonly providerOptions: ProviderOptions | undefined;
7357
+ /**
7358
+ * Timeout configuration for the generation.
7359
+ * Can be a number (milliseconds) or an object with totalMs, stepMs, chunkMs.
7360
+ */
7361
+ readonly timeout: TimeoutConfiguration | undefined;
7362
+ /** Additional HTTP headers sent with the request. */
7363
+ readonly headers: Record<string, string | undefined> | undefined;
7364
+ /**
7365
+ * Condition(s) for stopping the generation.
7366
+ * When the condition is an array, any of the conditions can be met to stop.
7367
+ */
7368
+ readonly stopWhen: StopCondition<TOOLS> | Array<StopCondition<TOOLS>> | undefined;
7369
+ /** The output specification for structured outputs, if configured. */
7370
+ readonly output: OUTPUT | undefined;
7371
+ /** Abort signal for cancelling the operation. */
7372
+ readonly abortSignal: AbortSignal | undefined;
7373
+ /**
7374
+ * Settings for controlling what data is included in step results.
7375
+ */
7376
+ readonly include: INCLUDE | undefined;
7377
+ /** Identifier from telemetry settings for grouping related operations. */
7378
+ readonly functionId: string | undefined;
7379
+ /** Additional metadata from telemetry settings. */
7380
+ readonly metadata: Record<string, unknown> | undefined;
7381
+ /**
7382
+ * User-defined context object. May be updated from `prepareStep` between steps.
7383
+ */
7384
+ readonly experimental_context: unknown;
7385
+ }
7386
+
7387
+ /**
7388
+ * Event passed to the `onToolCallFinish` callback.
7389
+ *
7390
+ * Called when a tool execution completes, either successfully or with an error.
7391
+ * Uses a discriminated union on the `success` field.
7392
+ */
7393
+ export declare type OnToolCallFinishEvent<TOOLS extends ToolSet = ToolSet> = {
7394
+ /** Zero-based index of the current step where this tool call occurred. */
7395
+ readonly stepNumber: number | undefined;
7396
+ /** The model being used for this step. */
7397
+ readonly model: CallbackModelInfo | undefined;
7398
+ /** The full tool call object. */
7399
+ readonly toolCall: TypedToolCall<TOOLS>;
7400
+ /** The conversation messages available at tool execution time. */
7401
+ readonly messages: Array<ModelMessage>;
7402
+ /** Signal for cancelling the operation. */
7403
+ readonly abortSignal: AbortSignal | undefined;
7404
+ /** Execution time of the tool call in milliseconds. */
7405
+ readonly durationMs: number;
7406
+ /** Identifier from telemetry settings for grouping related operations. */
7407
+ readonly functionId: string | undefined;
7408
+ /** Additional metadata from telemetry settings. */
7409
+ readonly metadata: Record<string, unknown> | undefined;
7410
+ /** User-defined context object flowing through the generation. */
7411
+ readonly experimental_context: unknown;
7412
+ } & ({
7413
+ /** Indicates the tool call succeeded. */
7414
+ readonly success: true;
7415
+ /** The tool's return value. */
7416
+ readonly output: unknown;
7417
+ readonly error?: never;
7418
+ } | {
7419
+ /** Indicates the tool call failed. */
7420
+ readonly success: false;
7421
+ readonly output?: never;
7422
+ /** The error that occurred during tool execution. */
7423
+ readonly error: unknown;
7424
+ });
7425
+
7426
+ /**
7427
+ * Event passed to the `onToolCallStart` callback.
7428
+ *
7429
+ * Called when a tool execution begins, before the tool's `execute` function is invoked.
7430
+ */
7431
+ export declare interface OnToolCallStartEvent<TOOLS extends ToolSet = ToolSet> {
7432
+ /** Zero-based index of the current step where this tool call occurs. */
7433
+ readonly stepNumber: number | undefined;
7434
+ /** The model being used for this step. */
7435
+ readonly model: CallbackModelInfo | undefined;
7436
+ /** The full tool call object. */
7437
+ readonly toolCall: TypedToolCall<TOOLS>;
7438
+ /** The conversation messages available at tool execution time. */
7439
+ readonly messages: Array<ModelMessage>;
7440
+ /** Signal for cancelling the operation. */
7441
+ readonly abortSignal: AbortSignal | undefined;
7442
+ /** Identifier from telemetry settings for grouping related operations. */
7443
+ readonly functionId: string | undefined;
7444
+ /** Additional metadata from telemetry settings. */
7445
+ readonly metadata: Record<string, unknown> | undefined;
7446
+ /** User-defined context object flowing through the generation. */
7447
+ readonly experimental_context: unknown;
7448
+ }
7449
+
7036
7450
  export declare namespace Output {
7037
7451
  export {
7038
7452
  output_Output as Output,
@@ -7931,6 +8345,25 @@ export declare function pruneMessages({ messages, reasoning, toolCalls, emptyMes
7931
8345
  emptyMessages?: 'keep' | 'remove';
7932
8346
  }): ModelMessage[];
7933
8347
 
8348
+ /**
8349
+ * Reads a fetch Response body with a size limit to prevent memory exhaustion.
8350
+ *
8351
+ * Checks the Content-Length header for early rejection, then reads the body
8352
+ * incrementally via ReadableStream and aborts with a DownloadError when the
8353
+ * limit is exceeded.
8354
+ *
8355
+ * @param response - The fetch Response to read.
8356
+ * @param url - The URL being downloaded (used in error messages).
8357
+ * @param maxBytes - Maximum allowed bytes. Defaults to DEFAULT_MAX_DOWNLOAD_SIZE.
8358
+ * @returns A Uint8Array containing the response body.
8359
+ * @throws DownloadError if the response exceeds maxBytes.
8360
+ */
8361
+ declare function readResponseWithSizeLimit({ response, url, maxBytes, }: {
8362
+ response: Response;
8363
+ url: string;
8364
+ maxBytes?: number;
8365
+ }): Promise<Uint8Array>;
8366
+
7934
8367
  /**
7935
8368
  * Transforms a stream of `UIMessageChunk`s into an `AsyncIterableStream` of `UIMessage`s.
7936
8369
  *
@@ -8002,6 +8435,11 @@ export declare type ReasoningUIPart = {
8002
8435
  providerMetadata?: ProviderMetadata;
8003
8436
  };
8004
8437
 
8438
+ /**
8439
+ * Registers a telemetry integration globally.
8440
+ */
8441
+ export declare function registerTelemetryIntegration(integration: TelemetryIntegration): void;
8442
+
8005
8443
  /**
8006
8444
  * Removes entries from a record where the value is null or undefined.
8007
8445
  * @param record - The input object whose entries may be null or undefined.
@@ -8607,6 +9045,7 @@ declare type SingleRequestTextStreamPart<TOOLS extends ToolSet> = {
8607
9045
  } & Source) | {
8608
9046
  type: 'file';
8609
9047
  file: GeneratedFile;
9048
+ providerMetadata?: ProviderMetadata;
8610
9049
  } | ({
8611
9050
  type: 'tool-call';
8612
9051
  } & TypedToolCall<TOOLS>) | ({
@@ -8614,9 +9053,6 @@ declare type SingleRequestTextStreamPart<TOOLS extends ToolSet> = {
8614
9053
  } & TypedToolResult<TOOLS>) | ({
8615
9054
  type: 'tool-error';
8616
9055
  } & TypedToolError<TOOLS>) | {
8617
- type: 'file';
8618
- file: GeneratedFile;
8619
- } | {
8620
9056
  type: 'stream-start';
8621
9057
  warnings: SharedV3Warning[];
8622
9058
  } | {
@@ -9412,6 +9848,33 @@ export declare function stepCountIs(stepCount: number): StopCondition<any>;
9412
9848
  * The result of a single step in the generation process.
9413
9849
  */
9414
9850
  export declare type StepResult<TOOLS extends ToolSet> = {
9851
+ /**
9852
+ * Zero-based index of this step.
9853
+ */
9854
+ readonly stepNumber: number;
9855
+ /**
9856
+ * Information about the model that produced this step.
9857
+ */
9858
+ readonly model: {
9859
+ /** The provider of the model. */
9860
+ readonly provider: string;
9861
+ /** The ID of the model. */
9862
+ readonly modelId: string;
9863
+ };
9864
+ /**
9865
+ * Identifier from telemetry settings for grouping related operations.
9866
+ */
9867
+ readonly functionId: string | undefined;
9868
+ /**
9869
+ * Additional metadata from telemetry settings.
9870
+ */
9871
+ readonly metadata: Record<string, unknown> | undefined;
9872
+ /**
9873
+ * User-defined context object flowing through the generation.
9874
+ *
9875
+ * Experimental (can break in patch releases).
9876
+ */
9877
+ readonly experimental_context: unknown;
9415
9878
  /**
9416
9879
  * The content that was generated in the last step.
9417
9880
  */
@@ -9842,7 +10305,7 @@ declare interface StreamOptions {
9842
10305
  * @returns
9843
10306
  * A result object for accessing different stream types and additional information.
9844
10307
  */
9845
- export declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output_2 = Output_2<string, string, never>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, prepareStep, providerOptions, experimental_activeTools, activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, experimental_download: download, includeRawChunks, onChunk, onError, onFinish, onAbort, onStepFinish, experimental_context, experimental_include: include, _internal: { now, generateId }, ...settings }: CallSettings & Prompt & {
10308
+ export declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output_2 = Output_2<string, string, never>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, prepareStep, providerOptions, experimental_activeTools, activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, experimental_download: download, includeRawChunks, onChunk, onError, onFinish, onAbort, onStepFinish, experimental_onStart: onStart, experimental_onStepStart: onStepStart, experimental_onToolCallStart: onToolCallStart, experimental_onToolCallFinish: onToolCallFinish, experimental_context, experimental_include: include, _internal: { now, generateId }, ...settings }: CallSettings & Prompt & {
9846
10309
  /**
9847
10310
  * The language model to use.
9848
10311
  */
@@ -9949,6 +10412,24 @@ export declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output_
9949
10412
  * Callback that is called when each step (LLM call) is finished, including intermediate steps.
9950
10413
  */
9951
10414
  onStepFinish?: StreamTextOnStepFinishCallback<TOOLS>;
10415
+ /**
10416
+ * Callback that is called when the streamText operation begins,
10417
+ * before any LLM calls are made.
10418
+ */
10419
+ experimental_onStart?: StreamTextOnStartCallback<NoInfer<TOOLS>, OUTPUT>;
10420
+ /**
10421
+ * Callback that is called when a step (LLM call) begins,
10422
+ * before the provider is called.
10423
+ */
10424
+ experimental_onStepStart?: StreamTextOnStepStartCallback<NoInfer<TOOLS>, OUTPUT>;
10425
+ /**
10426
+ * Callback that is called right before a tool's execute function runs.
10427
+ */
10428
+ experimental_onToolCallStart?: StreamTextOnToolCallStartCallback<NoInfer<TOOLS>>;
10429
+ /**
10430
+ * Callback that is called right after a tool's execute function completes (or errors).
10431
+ */
10432
+ experimental_onToolCallFinish?: StreamTextOnToolCallFinishCallback<NoInfer<TOOLS>>;
9952
10433
  /**
9953
10434
  * Context that is passed into tool execution.
9954
10435
  *
@@ -9981,6 +10462,13 @@ export declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output_
9981
10462
  };
9982
10463
  }): StreamTextResult<TOOLS, OUTPUT>;
9983
10464
 
10465
+ /**
10466
+ * Include settings for streamText (requestBody only).
10467
+ */
10468
+ declare type StreamTextIncludeSettings = {
10469
+ requestBody?: boolean;
10470
+ };
10471
+
9984
10472
  /**
9985
10473
  * Callback that is set using the `onAbort` option.
9986
10474
  *
@@ -10018,31 +10506,40 @@ export declare type StreamTextOnErrorCallback = (event: {
10018
10506
  *
10019
10507
  * @param event - The event that is passed to the callback.
10020
10508
  */
10021
- export declare type StreamTextOnFinishCallback<TOOLS extends ToolSet> = (event: StepResult<TOOLS> & {
10022
- /**
10023
- * Details for all steps.
10024
- */
10025
- readonly steps: StepResult<TOOLS>[];
10026
- /**
10027
- * Total usage for all steps. This is the sum of the usage of all steps.
10028
- */
10029
- readonly totalUsage: LanguageModelUsage;
10030
- /**
10031
- * Context that is passed into tool execution.
10032
- *
10033
- * Experimental (can break in patch releases).
10034
- *
10035
- * @default undefined
10036
- */
10037
- experimental_context: unknown;
10038
- }) => PromiseLike<void> | void;
10509
+ export declare type StreamTextOnFinishCallback<TOOLS extends ToolSet> = (event: OnFinishEvent<TOOLS>) => PromiseLike<void> | void;
10510
+
10511
+ /**
10512
+ * Callback that is set using the `experimental_onStart` option.
10513
+ *
10514
+ * Called when the streamText operation begins, before any LLM calls.
10515
+ * Use this callback for logging, analytics, or initializing state at the
10516
+ * start of a generation.
10517
+ *
10518
+ * @param event - The event object containing generation configuration.
10519
+ */
10520
+ export declare type StreamTextOnStartCallback<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output_2 = Output_2> = (event: OnStartEvent<TOOLS, OUTPUT, StreamTextIncludeSettings>) => PromiseLike<void> | void;
10039
10521
 
10040
10522
  /**
10041
10523
  * Callback that is set using the `onStepFinish` option.
10042
10524
  *
10043
10525
  * @param stepResult - The result of the step.
10044
10526
  */
10045
- export declare type StreamTextOnStepFinishCallback<TOOLS extends ToolSet> = (stepResult: StepResult<TOOLS>) => PromiseLike<void> | void;
10527
+ export declare type StreamTextOnStepFinishCallback<TOOLS extends ToolSet> = (event: OnStepFinishEvent<TOOLS>) => PromiseLike<void> | void;
10528
+
10529
+ /**
10530
+ * Callback that is set using the `experimental_onStepStart` option.
10531
+ *
10532
+ * Called when a step (LLM call) begins, before the provider is called.
10533
+ * Each step represents a single LLM invocation. Multiple steps occur when
10534
+ * using tool calls (the model may be called multiple times in a loop).
10535
+ *
10536
+ * @param event - The event object containing step configuration.
10537
+ */
10538
+ export declare type StreamTextOnStepStartCallback<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output_2 = Output_2> = (event: OnStepStartEvent<TOOLS, OUTPUT, StreamTextIncludeSettings>) => PromiseLike<void> | void;
10539
+
10540
+ export declare type StreamTextOnToolCallFinishCallback<TOOLS extends ToolSet = ToolSet> = (event: OnToolCallFinishEvent<TOOLS>) => PromiseLike<void> | void;
10541
+
10542
+ export declare type StreamTextOnToolCallStartCallback<TOOLS extends ToolSet = ToolSet> = (event: OnToolCallStartEvent<TOOLS>) => PromiseLike<void> | void;
10046
10543
 
10047
10544
  /**
10048
10545
  * A result object for accessing different stream types and additional information.
@@ -10273,6 +10770,16 @@ export declare type StreamTextTransform<TOOLS extends ToolSet> = (options: {
10273
10770
  stopStream: () => void;
10274
10771
  }) => TransformStream<TextStreamPart<TOOLS>, TextStreamPart<TOOLS>>;
10275
10772
 
10773
+ /**
10774
+ * Strips file extension segments from a filename.
10775
+ *
10776
+ * Examples:
10777
+ * - "report.pdf" -> "report"
10778
+ * - "archive.tar.gz" -> "archive"
10779
+ * - "filename" -> "filename"
10780
+ */
10781
+ declare function stripFileExtension(filename: string): string;
10782
+
10276
10783
  declare const symbol$1: unique symbol;
10277
10784
 
10278
10785
  declare const symbol$1_2: unique symbol;
@@ -10363,6 +10870,19 @@ export declare type SystemModelMessage = {
10363
10870
 
10364
10871
  export declare const systemModelMessageSchema: z.ZodType<SystemModelMessage>;
10365
10872
 
10873
+ /**
10874
+ * Implement this interface to create custom telemetry integrations.
10875
+ * Methods can be sync or return a PromiseLike.
10876
+ */
10877
+ export declare interface TelemetryIntegration {
10878
+ onStart?: Listener<OnStartEvent<ToolSet, Output_2>>;
10879
+ onStepStart?: Listener<OnStepStartEvent<ToolSet, Output_2>>;
10880
+ onToolCallStart?: Listener<OnToolCallStartEvent<ToolSet>>;
10881
+ onToolCallFinish?: Listener<OnToolCallFinishEvent<ToolSet>>;
10882
+ onStepFinish?: Listener<OnStepFinishEvent<ToolSet>>;
10883
+ onFinish?: Listener<OnFinishEvent<ToolSet>>;
10884
+ }
10885
+
10366
10886
  /**
10367
10887
  * Telemetry configuration.
10368
10888
  */
@@ -10397,6 +10917,13 @@ export declare type TelemetrySettings = {
10397
10917
  * A custom tracer to use for the telemetry data.
10398
10918
  */
10399
10919
  tracer?: Tracer;
10920
+ /**
10921
+ * Per-call telemetry integrations that receive lifecycle events during generation.
10922
+ *
10923
+ * These integrations run after any globally registered integrations
10924
+ * (see `registerTelemetryIntegration`).
10925
+ */
10926
+ integrations?: TelemetryIntegration | TelemetryIntegration[];
10400
10927
  };
10401
10928
 
10402
10929
  /**
@@ -10469,6 +10996,7 @@ export declare type TextStreamPart<TOOLS extends ToolSet> = {
10469
10996
  } & Source) | {
10470
10997
  type: 'file';
10471
10998
  file: GeneratedFile;
10999
+ providerMetadata?: ProviderMetadata;
10472
11000
  } | ({
10473
11001
  type: 'tool-call';
10474
11002
  } & TypedToolCall<TOOLS>) | ({
@@ -10925,49 +11453,30 @@ declare class ToolLoopAgent<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, OU
10925
11453
  */
10926
11454
  get tools(): TOOLS;
10927
11455
  private prepareCall;
10928
- private mergeOnStepFinishCallbacks;
11456
+ private mergeCallbacks;
10929
11457
  /**
10930
11458
  * Generates an output from the agent (non-streaming).
10931
11459
  */
10932
- generate({ abortSignal, timeout, onStepFinish, ...options }: AgentCallParameters<CALL_OPTIONS, TOOLS>): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
11460
+ generate({ abortSignal, timeout, experimental_onStart, experimental_onStepStart, experimental_onToolCallStart, experimental_onToolCallFinish, onStepFinish, onFinish, ...options }: AgentCallParameters<CALL_OPTIONS, TOOLS>): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
10933
11461
  /**
10934
11462
  * Streams an output from the agent (streaming).
10935
11463
  */
10936
- stream({ abortSignal, timeout, experimental_transform, onStepFinish, ...options }: AgentStreamParameters<CALL_OPTIONS, TOOLS>): Promise<StreamTextResult<TOOLS, OUTPUT>>;
11464
+ stream({ abortSignal, timeout, experimental_transform, experimental_onStart, experimental_onStepStart, experimental_onToolCallStart, experimental_onToolCallFinish, onStepFinish, onFinish, ...options }: AgentStreamParameters<CALL_OPTIONS, TOOLS>): Promise<StreamTextResult<TOOLS, OUTPUT>>;
10937
11465
  }
10938
11466
  export { ToolLoopAgent as Experimental_Agent }
10939
11467
  export { ToolLoopAgent }
10940
11468
 
10941
- /**
10942
- * Callback that is set using the `onFinish` option.
10943
- *
10944
- * @param event - The event that is passed to the callback.
10945
- */
10946
- export declare type ToolLoopAgentOnFinishCallback<TOOLS extends ToolSet = {}> = (event: StepResult<TOOLS> & {
10947
- /**
10948
- * Details for all steps.
10949
- */
10950
- readonly steps: StepResult<TOOLS>[];
10951
- /**
10952
- * Total usage for all steps. This is the sum of the usage of all steps.
10953
- */
10954
- readonly totalUsage: LanguageModelUsage;
10955
- /**
10956
- * Context that is passed into tool calls.
10957
- *
10958
- * Experimental (can break in patch releases).
10959
- *
10960
- * @default undefined
10961
- */
10962
- experimental_context?: unknown;
10963
- }) => PromiseLike<void> | void;
11469
+ export declare type ToolLoopAgentOnFinishCallback<TOOLS extends ToolSet = {}> = (event: OnFinishEvent<TOOLS>) => PromiseLike<void> | void;
10964
11470
 
10965
- /**
10966
- * Callback that is set using the `onStepFinish` option.
10967
- *
10968
- * @param stepResult - The result of the step.
10969
- */
10970
- export declare type ToolLoopAgentOnStepFinishCallback<TOOLS extends ToolSet = {}> = (stepResult: StepResult<TOOLS>) => Promise<void> | void;
11471
+ export declare type ToolLoopAgentOnStartCallback<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output_2 = Output_2> = (event: OnStartEvent<TOOLS, OUTPUT>) => PromiseLike<void> | void;
11472
+
11473
+ export declare type ToolLoopAgentOnStepFinishCallback<TOOLS extends ToolSet = {}> = (stepResult: OnStepFinishEvent<TOOLS>) => Promise<void> | void;
11474
+
11475
+ export declare type ToolLoopAgentOnStepStartCallback<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output_2 = Output_2> = (event: OnStepStartEvent<TOOLS, OUTPUT>) => PromiseLike<void> | void;
11476
+
11477
+ export declare type ToolLoopAgentOnToolCallFinishCallback<TOOLS extends ToolSet = ToolSet> = (event: OnToolCallFinishEvent<TOOLS>) => PromiseLike<void> | void;
11478
+
11479
+ export declare type ToolLoopAgentOnToolCallStartCallback<TOOLS extends ToolSet = ToolSet> = (event: OnToolCallStartEvent<TOOLS>) => PromiseLike<void> | void;
10971
11480
 
10972
11481
  /**
10973
11482
  * Configuration options for an agent.
@@ -11023,6 +11532,22 @@ declare type ToolLoopAgentSettings<CALL_OPTIONS = never, TOOLS extends ToolSet =
11023
11532
  * A function that attempts to repair a tool call that failed to parse.
11024
11533
  */
11025
11534
  experimental_repairToolCall?: ToolCallRepairFunction<NoInfer<TOOLS>>;
11535
+ /**
11536
+ * Callback that is called when the agent operation begins, before any LLM calls.
11537
+ */
11538
+ experimental_onStart?: ToolLoopAgentOnStartCallback<NoInfer<TOOLS>, OUTPUT>;
11539
+ /**
11540
+ * Callback that is called when a step (LLM call) begins, before the provider is called.
11541
+ */
11542
+ experimental_onStepStart?: ToolLoopAgentOnStepStartCallback<NoInfer<TOOLS>, OUTPUT>;
11543
+ /**
11544
+ * Callback that is called before each tool execution begins.
11545
+ */
11546
+ experimental_onToolCallStart?: ToolLoopAgentOnToolCallStartCallback<NoInfer<TOOLS>>;
11547
+ /**
11548
+ * Callback that is called after each tool execution completes.
11549
+ */
11550
+ experimental_onToolCallFinish?: ToolLoopAgentOnToolCallFinishCallback<NoInfer<TOOLS>>;
11026
11551
  /**
11027
11552
  * Callback that is called when each step (LLM call) is finished, including intermediate steps.
11028
11553
  */
@@ -12207,6 +12732,27 @@ export declare type UIMessageStreamOnFinishCallback<UI_MESSAGE extends UIMessage
12207
12732
  finishReason?: FinishReason;
12208
12733
  }) => PromiseLike<void> | void;
12209
12734
 
12735
+ /**
12736
+ * Callback that is called when a step finishes during streaming.
12737
+ * This is useful for persisting intermediate UI messages during multi-step agent runs.
12738
+ */
12739
+ export declare type UIMessageStreamOnStepFinishCallback<UI_MESSAGE extends UIMessage> = (event: {
12740
+ /**
12741
+ * The updated list of UI messages at the end of this step.
12742
+ */
12743
+ messages: UI_MESSAGE[];
12744
+ /**
12745
+ * Indicates whether the response message is a continuation of the last original message,
12746
+ * or if a new message was created.
12747
+ */
12748
+ isContinuation: boolean;
12749
+ /**
12750
+ * The message that was sent to the client as a response
12751
+ * (including the original message if it was extended).
12752
+ */
12753
+ responseMessage: UI_MESSAGE;
12754
+ }) => PromiseLike<void> | void;
12755
+
12210
12756
  export declare type UIMessageStreamOptions<UI_MESSAGE extends UIMessage> = {
12211
12757
  /**
12212
12758
  * The original messages. If they are provided, persistence mode is assumed,
@@ -12495,6 +13041,15 @@ export declare type UserModelMessage = {
12495
13041
 
12496
13042
  export declare const userModelMessageSchema: z.ZodType<UserModelMessage>;
12497
13043
 
13044
+ /**
13045
+ * Validates that a URL is safe to download from, blocking private/internal addresses
13046
+ * to prevent SSRF attacks.
13047
+ *
13048
+ * @param url - The URL string to validate.
13049
+ * @throws DownloadError if the URL is unsafe.
13050
+ */
13051
+ declare function validateDownloadUrl(url: string): void;
13052
+
12498
13053
  /**
12499
13054
  * Validates the types of an unknown object using a schema and
12500
13055
  * return a strongly-typed object.
@@ -12934,5 +13489,5 @@ export declare function zodSchema<OBJECT>(zodSchema: z4.core.$ZodType<OBJECT, an
12934
13489
  }): Schema<OBJECT>;
12935
13490
 
12936
13491
  export { }
12937
- export { GatewayProviderSettings as GatewayProviderSettings, GatewayProvider as GatewayProvider, LazySchema as LazySchema, ZodSchema as ZodSchema, StandardSchema as StandardSchema, ValidationResult as ValidationResult, ParseResult as ParseResult, ProviderOptions as ProviderOptions, ReasoningPart as ReasoningPart, ToolOutputProperties as ToolOutputProperties, ToolResultOutput as ToolResultOutput, ToolNeedsApprovalFunction as ToolNeedsApprovalFunction, TypeValidationContext as TypeValidationContext, JSONSchema7Version as JSONSchema7Version, JSONSchema7Definition as JSONSchema7Definition, JSONSchema7TypeName as JSONSchema7TypeName, JSONSchema7Type as JSONSchema7Type, EmbeddingModelV2 as EmbeddingModelV2, EmbeddingModelV3Embedding as EmbeddingModelV3Embedding, EmbeddingModelV3Middleware as EmbeddingModelV3Middleware, ImageModelV2 as ImageModelV2, ImageModelV3ProviderMetadata as ImageModelV3ProviderMetadata, ImageModelV2ProviderMetadata as ImageModelV2ProviderMetadata, ImageModelV3Middleware as ImageModelV3Middleware, GlobalProviderModelId as GlobalProviderModelId, LanguageModelV2 as LanguageModelV2, SharedV3Warning as SharedV3Warning, LanguageModelV3Middleware as LanguageModelV3Middleware, SharedV3ProviderMetadata as SharedV3ProviderMetadata, SpeechModelV2 as SpeechModelV2, TranscriptionModelV2 as TranscriptionModelV2, ImageModelV3Usage as ImageModelV3Usage, BaseToolCall as BaseToolCall, Source as Source, DeepPartialInternal as DeepPartialInternal, AttributeValue as AttributeValue, Tracer as Tracer, LanguageModelV3ToolCall as LanguageModelV3ToolCall, ValueOf as ValueOf, asUITool as asUITool, _ai_sdk_provider_utils as _ai_sdk_provider_utils, _ai_sdk_provider as _ai_sdk_provider, DataUIMessageChunk as DataUIMessageChunk, InferElementOutput as InferElementOutput, ConsumeStreamOptions as ConsumeStreamOptions, StreamTextOnAbortCallback as StreamTextOnAbortCallback, ResponseMessage as ResponseMessage, Output_2 as Output_2, MaybePromiseLike as MaybePromiseLike, InferAgentTools as InferAgentTools, UIMessageStreamResponseInit as UIMessageStreamResponseInit, getOriginalFetch as getOriginalFetch, InferUIMessageToolCall as InferUIMessageToolCall, UIDataTypesToSchemas as UIDataTypesToSchemas, InferUIMessageData as InferUIMessageData, InferUIMessageMetadata as InferUIMessageMetadata, InferUIMessageTools as InferUIMessageTools, Resolvable as Resolvable, FetchFunction as FetchFunction, SingleRequestTextStreamPart as SingleRequestTextStreamPart, RetryErrorReason as RetryErrorReason, GenerateImagePrompt as GenerateImagePrompt, JSONValue_2 as JSONValue_2, Job as Job, StreamObjectOnErrorCallback as StreamObjectOnErrorCallback, VideoModelResponseMetadata as VideoModelResponseMetadata, VideoModelProviderMetadata as VideoModelProviderMetadata, VideoModel as VideoModel, EmbeddingModelV3CallOptions as EmbeddingModelV3CallOptions, LanguageModelV3CallOptions as LanguageModelV3CallOptions, JSONObject as JSONObject, LanguageModelV3 as LanguageModelV3, EmbeddingModelV3 as EmbeddingModelV3, ImageModelV3 as ImageModelV3, TranscriptionModelV3 as TranscriptionModelV3, SpeechModelV3 as SpeechModelV3, RerankingModelV3 as RerankingModelV3, ProviderV2 as ProviderV2, ExtractModelId as ExtractModelId, ExtractLiteralUnion as ExtractLiteralUnion, ProviderV3 as ProviderV3 };
13492
+ export { GatewayProviderSettings as GatewayProviderSettings, GatewayProvider as GatewayProvider, LazySchema as LazySchema, ZodSchema as ZodSchema, StandardSchema as StandardSchema, ValidationResult as ValidationResult, ParseResult as ParseResult, ProviderOptions as ProviderOptions, ReasoningPart as ReasoningPart, ToolOutputProperties as ToolOutputProperties, ToolResultOutput as ToolResultOutput, ToolNeedsApprovalFunction as ToolNeedsApprovalFunction, TypeValidationContext as TypeValidationContext, JSONSchema7Version as JSONSchema7Version, JSONSchema7Definition as JSONSchema7Definition, JSONSchema7TypeName as JSONSchema7TypeName, JSONSchema7Type as JSONSchema7Type, EmbeddingModelV2 as EmbeddingModelV2, EmbeddingModelV3Embedding as EmbeddingModelV3Embedding, EmbeddingModelV3Middleware as EmbeddingModelV3Middleware, ImageModelV2 as ImageModelV2, ImageModelV3ProviderMetadata as ImageModelV3ProviderMetadata, ImageModelV2ProviderMetadata as ImageModelV2ProviderMetadata, ImageModelV3Middleware as ImageModelV3Middleware, GlobalProviderModelId as GlobalProviderModelId, LanguageModelV2 as LanguageModelV2, SharedV3Warning as SharedV3Warning, LanguageModelV3Middleware as LanguageModelV3Middleware, SharedV3ProviderMetadata as SharedV3ProviderMetadata, SpeechModelV2 as SpeechModelV2, TranscriptionModelV2 as TranscriptionModelV2, ImageModelV3Usage as ImageModelV3Usage, BaseToolCall as BaseToolCall, Source as Source, DeepPartialInternal as DeepPartialInternal, CallbackModelInfo as CallbackModelInfo, LanguageModelV3ToolChoice as LanguageModelV3ToolChoice, Listener as Listener, AttributeValue as AttributeValue, Tracer as Tracer, LanguageModelV3ToolCall as LanguageModelV3ToolCall, GenerateTextIncludeSettings as GenerateTextIncludeSettings, ValueOf as ValueOf, asUITool as asUITool, _ai_sdk_provider_utils as _ai_sdk_provider_utils, _ai_sdk_provider as _ai_sdk_provider, DataUIMessageChunk as DataUIMessageChunk, InferElementOutput as InferElementOutput, ConsumeStreamOptions as ConsumeStreamOptions, StreamTextIncludeSettings as StreamTextIncludeSettings, StreamTextOnAbortCallback as StreamTextOnAbortCallback, ResponseMessage as ResponseMessage, MaybePromiseLike as MaybePromiseLike, Output_2 as Output_2, InferAgentTools as InferAgentTools, UIMessageStreamResponseInit as UIMessageStreamResponseInit, getOriginalFetch as getOriginalFetch, InferUIMessageToolCall as InferUIMessageToolCall, UIDataTypesToSchemas as UIDataTypesToSchemas, InferUIMessageData as InferUIMessageData, InferUIMessageMetadata as InferUIMessageMetadata, InferUIMessageTools as InferUIMessageTools, Resolvable as Resolvable, FetchFunction as FetchFunction, SingleRequestTextStreamPart as SingleRequestTextStreamPart, RetryErrorReason as RetryErrorReason, GenerateImagePrompt as GenerateImagePrompt, JSONValue_2 as JSONValue_2, Job as Job, StreamObjectOnErrorCallback as StreamObjectOnErrorCallback, VideoModelResponseMetadata as VideoModelResponseMetadata, VideoModelProviderMetadata as VideoModelProviderMetadata, VideoModel as VideoModel, EmbeddingModelV3CallOptions as EmbeddingModelV3CallOptions, LanguageModelV3CallOptions as LanguageModelV3CallOptions, JSONObject as JSONObject, LanguageModelV3 as LanguageModelV3, EmbeddingModelV3 as EmbeddingModelV3, ImageModelV3 as ImageModelV3, TranscriptionModelV3 as TranscriptionModelV3, SpeechModelV3 as SpeechModelV3, RerankingModelV3 as RerankingModelV3, VideoModelV3 as VideoModelV3, ProviderV2 as ProviderV2, ExtractModelId as ExtractModelId, ExtractLiteralUnion as ExtractLiteralUnion, ProviderV3 as ProviderV3 };
12938
13493
  export { schemaSymbol, symbol$1, symbol$1_2, symbol$2, symbol$2_2, symbol$3, symbol$3_2, symbol$4, symbol$4_2, symbol$5, symbol$5_2, symbol$6, symbol$6_2, symbol$7, symbol$7_2, symbol$8, symbol$8_2, symbol$9, symbol$9_2, symbol$a, symbol$a_2, symbol$b, symbol$b_2, symbol$c, symbol$c_2, symbol$d, symbol$d_2, symbol$e, symbol$f, symbol$g, symbol$h, symbol$i, symbol$j, symbol, symbol_2, symbol_3 };