@ai-sdk/provider 3.0.0-beta.8 → 3.0.0

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.mts CHANGED
@@ -9,7 +9,7 @@ JSON values can be serialized and deserialized by the JSON.stringify and JSON.pa
9
9
  */
10
10
  type JSONValue = null | string | number | boolean | JSONObject | JSONArray;
11
11
  type JSONObject = {
12
- [key: string]: JSONValue;
12
+ [key: string]: JSONValue | undefined;
13
13
  };
14
14
  type JSONArray = JSONValue[];
15
15
 
@@ -34,7 +34,7 @@ type JSONArray = JSONValue[];
34
34
  * }
35
35
  * ```
36
36
  */
37
- type SharedV3ProviderMetadata = Record<string, Record<string, JSONValue>>;
37
+ type SharedV3ProviderMetadata = Record<string, JSONObject>;
38
38
 
39
39
  /**
40
40
  * Additional provider-specific options.
@@ -57,7 +57,50 @@ type SharedV3ProviderMetadata = Record<string, Record<string, JSONValue>>;
57
57
  * }
58
58
  * ```
59
59
  */
60
- type SharedV3ProviderOptions = Record<string, Record<string, JSONValue>>;
60
+ type SharedV3ProviderOptions = Record<string, JSONObject>;
61
+
62
+ /**
63
+ * Warning from the model.
64
+ *
65
+ * For example, that certain features are unsupported or compatibility
66
+ * functionality is used (which might lead to suboptimal results).
67
+ */
68
+ type SharedV3Warning = {
69
+ /**
70
+ * A feature is not supported by the model.
71
+ */
72
+ type: 'unsupported';
73
+ /**
74
+ * The feature that is not supported.
75
+ */
76
+ feature: string;
77
+ /**
78
+ * Additional details about the warning.
79
+ */
80
+ details?: string;
81
+ } | {
82
+ /**
83
+ * A compatibility feature is used that might lead to suboptimal results.
84
+ */
85
+ type: 'compatibility';
86
+ /**
87
+ * The feature that is used in a compatibility mode.
88
+ */
89
+ feature: string;
90
+ /**
91
+ * Additional details about the warning.
92
+ */
93
+ details?: string;
94
+ } | {
95
+ /**
96
+ * Other warning.
97
+ */
98
+ type: 'other';
99
+ /**
100
+ * The message of the warning.
101
+ */
102
+ message: string;
103
+ };
61
104
 
62
105
  type SharedV2Headers = Record<string, string>;
63
106
 
@@ -107,21 +150,80 @@ type SharedV2ProviderMetadata = Record<string, Record<string, JSONValue>>;
107
150
  */
108
151
  type SharedV2ProviderOptions = Record<string, Record<string, JSONValue>>;
109
152
 
153
+ type EmbeddingModelV3CallOptions = {
154
+ /**
155
+ List of text values to generate embeddings for.
156
+ */
157
+ values: Array<string>;
158
+ /**
159
+ Abort signal for cancelling the operation.
160
+ */
161
+ abortSignal?: AbortSignal;
162
+ /**
163
+ Additional provider-specific options. They are passed through
164
+ to the provider from the AI SDK and enable provider-specific
165
+ functionality that can be fully encapsulated in the provider.
166
+ */
167
+ providerOptions?: SharedV3ProviderOptions;
168
+ /**
169
+ Additional HTTP headers to be sent with the request.
170
+ Only applicable for HTTP-based providers.
171
+ */
172
+ headers?: SharedV3Headers;
173
+ };
174
+
110
175
  /**
111
176
  An embedding is a vector, i.e. an array of numbers.
112
177
  It is e.g. used to represent a text as a vector of word embeddings.
113
178
  */
114
179
  type EmbeddingModelV3Embedding = Array<number>;
115
180
 
181
+ /**
182
+ * The result of a embedding model doEmbed call.
183
+ */
184
+ type EmbeddingModelV3Result = {
185
+ /**
186
+ * Generated embeddings. They are in the same order as the input values.
187
+ */
188
+ embeddings: Array<EmbeddingModelV3Embedding>;
189
+ /**
190
+ * Token usage. We only have input tokens for embeddings.
191
+ */
192
+ usage?: {
193
+ tokens: number;
194
+ };
195
+ /**
196
+ * Additional provider-specific metadata. They are passed through
197
+ * from the provider to the AI SDK and enable provider-specific
198
+ * results that can be fully encapsulated in the provider.
199
+ */
200
+ providerMetadata?: SharedV3ProviderMetadata;
201
+ /**
202
+ * Optional response information for debugging purposes.
203
+ */
204
+ response?: {
205
+ /**
206
+ * Response headers.
207
+ */
208
+ headers?: SharedV3Headers;
209
+ /**
210
+ The response body.
211
+ */
212
+ body?: unknown;
213
+ };
214
+ /**
215
+ * Warnings for the call, e.g. unsupported settings.
216
+ */
217
+ warnings: Array<SharedV3Warning>;
218
+ };
219
+
116
220
  /**
117
221
  Specification for an embedding model that implements the embedding model
118
- interface version 1.
222
+ interface version 3.
119
223
 
120
- VALUE is the type of the values that the model can embed.
121
- This will allow us to go beyond text embeddings in the future,
122
- e.g. to support image embeddings
224
+ It is specific to text embeddings.
123
225
  */
124
- type EmbeddingModelV3<VALUE> = {
226
+ type EmbeddingModelV3 = {
125
227
  /**
126
228
  The embedding model must specify which embedding model interface
127
229
  version it implements. This will allow us to evolve the embedding
@@ -154,57 +256,7 @@ type EmbeddingModelV3<VALUE> = {
154
256
  Naming: "do" prefix to prevent accidental direct usage of the method
155
257
  by the user.
156
258
  */
157
- doEmbed(options: {
158
- /**
159
- List of values to embed.
160
- */
161
- values: Array<VALUE>;
162
- /**
163
- Abort signal for cancelling the operation.
164
- */
165
- abortSignal?: AbortSignal;
166
- /**
167
- Additional provider-specific options. They are passed through
168
- to the provider from the AI SDK and enable provider-specific
169
- functionality that can be fully encapsulated in the provider.
170
- */
171
- providerOptions?: SharedV3ProviderOptions;
172
- /**
173
- Additional HTTP headers to be sent with the request.
174
- Only applicable for HTTP-based providers.
175
- */
176
- headers?: Record<string, string | undefined>;
177
- }): PromiseLike<{
178
- /**
179
- Generated embeddings. They are in the same order as the input values.
180
- */
181
- embeddings: Array<EmbeddingModelV3Embedding>;
182
- /**
183
- Token usage. We only have input tokens for embeddings.
184
- */
185
- usage?: {
186
- tokens: number;
187
- };
188
- /**
189
- Additional provider-specific metadata. They are passed through
190
- from the provider to the AI SDK and enable provider-specific
191
- results that can be fully encapsulated in the provider.
192
- */
193
- providerMetadata?: SharedV3ProviderMetadata;
194
- /**
195
- Optional response information for debugging purposes.
196
- */
197
- response?: {
198
- /**
199
- Response headers.
200
- */
201
- headers?: SharedV3Headers;
202
- /**
203
- The response body.
204
- */
205
- body?: unknown;
206
- };
207
- }>;
259
+ doEmbed(options: EmbeddingModelV3CallOptions): PromiseLike<EmbeddingModelV3Result>;
208
260
  };
209
261
 
210
262
  /**
@@ -467,11 +519,11 @@ declare const symbol$3: unique symbol;
467
519
  declare class NoSuchModelError extends AISDKError {
468
520
  private readonly [symbol$3];
469
521
  readonly modelId: string;
470
- readonly modelType: 'languageModel' | 'textEmbeddingModel' | 'imageModel' | 'transcriptionModel' | 'speechModel';
522
+ readonly modelType: 'languageModel' | 'embeddingModel' | 'imageModel' | 'transcriptionModel' | 'speechModel' | 'rerankingModel';
471
523
  constructor({ errorName, modelId, modelType, message, }: {
472
524
  errorName?: string;
473
525
  modelId: string;
474
- modelType: 'languageModel' | 'textEmbeddingModel' | 'imageModel' | 'transcriptionModel' | 'speechModel';
526
+ modelType: 'languageModel' | 'embeddingModel' | 'imageModel' | 'transcriptionModel' | 'speechModel' | 'rerankingModel';
475
527
  message?: string;
476
528
  });
477
529
  static isInstance(error: unknown): error is NoSuchModelError;
@@ -533,71 +585,123 @@ declare function isJSONValue(value: unknown): value is JSONValue;
533
585
  declare function isJSONArray(value: unknown): value is JSONArray;
534
586
  declare function isJSONObject(value: unknown): value is JSONObject;
535
587
 
588
+ /**
589
+ Usage information for an image model call.
590
+ */
591
+ type ImageModelV3Usage = {
592
+ /**
593
+ The number of input (prompt) tokens used.
594
+ */
595
+ inputTokens: number | undefined;
596
+ /**
597
+ The number of output tokens used, if reported by the provider.
598
+ */
599
+ outputTokens: number | undefined;
600
+ /**
601
+ The total number of tokens as reported by the provider.
602
+ */
603
+ totalTokens: number | undefined;
604
+ };
605
+
606
+ /**
607
+ * An image file that can be used for image editing or variation generation.
608
+ */
609
+ type ImageModelV3File = {
610
+ type: 'file';
611
+ /**
612
+ * The IANA media type of the file, e.g. `image/png`. Any string is supported.
613
+ *
614
+ * @see https://www.iana.org/assignments/media-types/media-types.xhtml
615
+ */
616
+ mediaType: string;
617
+ /**
618
+ * Generated file data as base64 encoded strings or binary data.
619
+ *
620
+ * The file data should be returned without any unnecessary conversion.
621
+ * If the API returns base64 encoded strings, the file data should be returned
622
+ * as base64 encoded strings. If the API returns binary data, the file data should
623
+ * be returned as binary data.
624
+ */
625
+ data: string | Uint8Array;
626
+ /**
627
+ * Optional provider-specific metadata for the file part.
628
+ */
629
+ providerOptions?: SharedV3ProviderMetadata;
630
+ } | {
631
+ type: 'url';
632
+ /**
633
+ * The URL of the image file.
634
+ */
635
+ url: string;
636
+ /**
637
+ * Optional provider-specific metadata for the file part.
638
+ */
639
+ providerOptions?: SharedV3ProviderMetadata;
640
+ };
641
+
536
642
  type ImageModelV3CallOptions = {
537
643
  /**
538
- Prompt for the image generation.
539
- */
540
- prompt: string;
644
+ * Prompt for the image generation. Some operations, like upscaling, may not require a prompt.
645
+ */
646
+ prompt: string | undefined;
541
647
  /**
542
- Number of images to generate.
543
- */
648
+ * Number of images to generate.
649
+ */
544
650
  n: number;
545
651
  /**
546
- Size of the images to generate.
547
- Must have the format `{width}x{height}`.
548
- `undefined` will use the provider's default size.
549
- */
652
+ * Size of the images to generate.
653
+ * Must have the format `{width}x{height}`.
654
+ * `undefined` will use the provider's default size.
655
+ */
550
656
  size: `${number}x${number}` | undefined;
551
657
  /**
552
- Aspect ratio of the images to generate.
553
- Must have the format `{width}:{height}`.
554
- `undefined` will use the provider's default aspect ratio.
555
- */
658
+ * Aspect ratio of the images to generate.
659
+ * Must have the format `{width}:{height}`.
660
+ * `undefined` will use the provider's default aspect ratio.
661
+ */
556
662
  aspectRatio: `${number}:${number}` | undefined;
557
663
  /**
558
- Seed for the image generation.
559
- `undefined` will use the provider's default seed.
560
- */
664
+ * Seed for the image generation.
665
+ * `undefined` will use the provider's default seed.
666
+ */
561
667
  seed: number | undefined;
562
668
  /**
563
- Additional provider-specific options that are passed through to the provider
564
- as body parameters.
565
-
566
- The outer record is keyed by the provider name, and the inner
567
- record is keyed by the provider-specific metadata key.
568
- ```ts
569
- {
570
- "openai": {
571
- "style": "vivid"
572
- }
573
- }
574
- ```
575
- */
669
+ * Array of images for image editing or variation generation.
670
+ * The images should be provided as base64 encoded strings or binary data.
671
+ */
672
+ files: ImageModelV3File[] | undefined;
673
+ /**
674
+ * Mask image for inpainting operations.
675
+ * The mask should be provided as base64 encoded strings or binary data.
676
+ */
677
+ mask: ImageModelV3File | undefined;
678
+ /**
679
+ * Additional provider-specific options that are passed through to the provider
680
+ * as body parameters.
681
+ *
682
+ * The outer record is keyed by the provider name, and the inner
683
+ * record is keyed by the provider-specific metadata key.
684
+ *
685
+ * ```ts
686
+ * {
687
+ * "openai": {
688
+ * "style": "vivid"
689
+ * }
690
+ * }
691
+ * ```
692
+ */
576
693
  providerOptions: SharedV3ProviderOptions;
577
694
  /**
578
- Abort signal for cancelling the operation.
579
- */
695
+ * Abort signal for cancelling the operation.
696
+ */
580
697
  abortSignal?: AbortSignal;
581
698
  /**
582
- Additional HTTP headers to be sent with the request.
583
- Only applicable for HTTP-based providers.
584
- */
699
+ * Additional HTTP headers to be sent with the request.
700
+ * Only applicable for HTTP-based providers.
701
+ */
585
702
  headers?: Record<string, string | undefined>;
586
703
  };
587
704
 
588
- /**
589
- Warning from the model provider for this call. The call will proceed, but e.g.
590
- some settings might not be supported, which can lead to suboptimal results.
591
- */
592
- type ImageModelV3CallWarning = {
593
- type: 'unsupported-setting';
594
- setting: keyof ImageModelV3CallOptions;
595
- details?: string;
596
- } | {
597
- type: 'other';
598
- message: string;
599
- };
600
-
601
705
  type ImageModelV3ProviderMetadata = Record<string, {
602
706
  images: JSONArray;
603
707
  } & JSONValue>;
@@ -644,9 +748,9 @@ type ImageModelV3 = {
644
748
  */
645
749
  images: Array<string> | Array<Uint8Array>;
646
750
  /**
647
- Warnings for the call, e.g. unsupported settings.
751
+ Warnings for the call, e.g. unsupported features.
648
752
  */
649
- warnings: Array<ImageModelV3CallWarning>;
753
+ warnings: Array<SharedV3Warning>;
650
754
  /**
651
755
  Additional provider-specific metadata. They are passed through
652
756
  from the provider to the AI SDK and enable provider-specific
@@ -682,6 +786,10 @@ type ImageModelV3 = {
682
786
  */
683
787
  headers: Record<string, string> | undefined;
684
788
  };
789
+ /**
790
+ Optional token usage for the image generation call (if the provider reports it).
791
+ */
792
+ usage?: ImageModelV3Usage;
685
793
  }>;
686
794
  };
687
795
 
@@ -863,6 +971,21 @@ type LanguageModelV3FunctionTool = {
863
971
  */
864
972
  inputSchema: JSONSchema7;
865
973
  /**
974
+ * An optional list of input examples that show the language
975
+ * model what the input should look like.
976
+ */
977
+ inputExamples?: Array<{
978
+ input: JSONObject;
979
+ }>;
980
+ /**
981
+ * Strict mode setting for the tool.
982
+ *
983
+ * Providers that support strict mode will use this setting to determine
984
+ * how the input should be generated. Strict mode will always produce
985
+ * valid inputs, but it might limit what input schemas are supported.
986
+ */
987
+ strict?: boolean;
988
+ /**
866
989
  The provider-specific options for the tool.
867
990
  */
868
991
  providerOptions?: SharedV3ProviderOptions;
@@ -894,7 +1017,7 @@ type LanguageModelV3Message = ({
894
1017
  content: Array<LanguageModelV3TextPart | LanguageModelV3FilePart | LanguageModelV3ReasoningPart | LanguageModelV3ToolCallPart | LanguageModelV3ToolResultPart>;
895
1018
  } | {
896
1019
  role: 'tool';
897
- content: Array<LanguageModelV3ToolResultPart>;
1020
+ content: Array<LanguageModelV3ToolResultPart | LanguageModelV3ToolApprovalResponsePart>;
898
1021
  }) & {
899
1022
  /**
900
1023
  * Additional provider-specific options. They are passed through
@@ -1016,6 +1139,31 @@ interface LanguageModelV3ToolResultPart {
1016
1139
  */
1017
1140
  providerOptions?: SharedV3ProviderOptions;
1018
1141
  }
1142
+ /**
1143
+ * Tool approval response content part of a prompt. It contains the user's
1144
+ * decision to approve or deny a provider-executed tool call.
1145
+ */
1146
+ interface LanguageModelV3ToolApprovalResponsePart {
1147
+ type: 'tool-approval-response';
1148
+ /**
1149
+ * ID of the approval request that this response refers to.
1150
+ */
1151
+ approvalId: string;
1152
+ /**
1153
+ * Whether the approval was granted (true) or denied (false).
1154
+ */
1155
+ approved: boolean;
1156
+ /**
1157
+ * Optional reason for approval or denial.
1158
+ */
1159
+ reason?: string;
1160
+ /**
1161
+ * Additional provider-specific options. They are passed through
1162
+ * to the provider from the AI SDK and enable provider-specific
1163
+ * functionality that can be fully encapsulated in the provider.
1164
+ */
1165
+ providerOptions?: SharedV3ProviderOptions;
1166
+ }
1019
1167
  /**
1020
1168
  * Result of a tool call.
1021
1169
  */
@@ -1182,19 +1330,23 @@ IANA media type.
1182
1330
  };
1183
1331
 
1184
1332
  /**
1185
- * The configuration of a tool that is defined by the provider.
1333
+ * The configuration of a provider tool.
1334
+ *
1335
+ * Provider tools are tools that are specific to a certain provider.
1336
+ * The input and output schemas are defined be the provider, and
1337
+ * some of the tools are also executed on the provider systems.
1186
1338
  */
1187
- type LanguageModelV3ProviderDefinedTool = {
1339
+ type LanguageModelV3ProviderTool = {
1188
1340
  /**
1189
- * The type of the tool (always 'provider-defined').
1341
+ * The type of the tool (always 'provider').
1190
1342
  */
1191
- type: 'provider-defined';
1343
+ type: 'provider';
1192
1344
  /**
1193
1345
  * The ID of the tool. Should follow the format `<provider-id>.<unique-tool-name>`.
1194
1346
  */
1195
1347
  id: `${string}.${string}`;
1196
1348
  /**
1197
- * The name of the tool that the user must use in the tool set.
1349
+ * The name of the tool. Unique within this model call.
1198
1350
  */
1199
1351
  name: string;
1200
1352
  /**
@@ -1289,7 +1441,7 @@ type LanguageModelV3CallOptions = {
1289
1441
  /**
1290
1442
  The tools that are available for the model.
1291
1443
  */
1292
- tools?: Array<LanguageModelV3FunctionTool | LanguageModelV3ProviderDefinedTool>;
1444
+ tools?: Array<LanguageModelV3FunctionTool | LanguageModelV3ProviderTool>;
1293
1445
  /**
1294
1446
  Specifies how the tool should be selected. Defaults to 'auto'.
1295
1447
  */
@@ -1315,23 +1467,6 @@ type LanguageModelV3CallOptions = {
1315
1467
  providerOptions?: SharedV3ProviderOptions;
1316
1468
  };
1317
1469
 
1318
- /**
1319
- Warning from the model provider for this call. The call will proceed, but e.g.
1320
- some settings might not be supported, which can lead to suboptimal results.
1321
- */
1322
- type LanguageModelV3CallWarning = {
1323
- type: 'unsupported-setting';
1324
- setting: Omit<keyof LanguageModelV3CallOptions, 'prompt'>;
1325
- details?: string;
1326
- } | {
1327
- type: 'unsupported-tool';
1328
- tool: LanguageModelV3FunctionTool | LanguageModelV3ProviderDefinedTool;
1329
- details?: string;
1330
- } | {
1331
- type: 'other';
1332
- message: string;
1333
- };
1334
-
1335
1470
  /**
1336
1471
  A file that has been generated by the model.
1337
1472
  Generated files as base64 encoded strings or binary data.
@@ -1354,6 +1489,10 @@ type LanguageModelV3File = {
1354
1489
  be returned as binary data.
1355
1490
  */
1356
1491
  data: string | Uint8Array;
1492
+ /**
1493
+ * Optional provider-specific metadata for the file part.
1494
+ */
1495
+ providerMetadata?: SharedV3ProviderMetadata;
1357
1496
  };
1358
1497
 
1359
1498
  /**
@@ -1433,6 +1572,29 @@ type LanguageModelV3Text = {
1433
1572
  providerMetadata?: SharedV3ProviderMetadata;
1434
1573
  };
1435
1574
 
1575
+ /**
1576
+ * Tool approval request emitted by a provider for a provider-executed tool call.
1577
+ *
1578
+ * This is used for flows where the provider executes the tool (e.g. MCP tools)
1579
+ * but requires an explicit user approval before continuing.
1580
+ */
1581
+ type LanguageModelV3ToolApprovalRequest = {
1582
+ type: 'tool-approval-request';
1583
+ /**
1584
+ * ID of the approval request. This ID is referenced by the subsequent
1585
+ * tool-approval-response (tool message) to approve or deny execution.
1586
+ */
1587
+ approvalId: string;
1588
+ /**
1589
+ * The tool call ID that this approval request is for.
1590
+ */
1591
+ toolCallId: string;
1592
+ /**
1593
+ * Additional provider-specific metadata for the approval request.
1594
+ */
1595
+ providerMetadata?: SharedV3ProviderMetadata;
1596
+ };
1597
+
1436
1598
  /**
1437
1599
  * Tool calls that the model has generated.
1438
1600
  */
@@ -1483,18 +1645,11 @@ type LanguageModelV3ToolResult = {
1483
1645
  /**
1484
1646
  * Result of the tool call. This is a JSON-serializable object.
1485
1647
  */
1486
- result: unknown;
1648
+ result: NonNullable<JSONValue>;
1487
1649
  /**
1488
1650
  * Optional flag if the result is an error or an error message.
1489
1651
  */
1490
1652
  isError?: boolean;
1491
- /**
1492
- * Whether the tool result was generated by the provider.
1493
- *
1494
- * If this flag is set to true, the tool result was generated by the provider.
1495
- * If this flag is not set or is false, the tool result was generated by the client.
1496
- */
1497
- providerExecuted?: boolean;
1498
1653
  /**
1499
1654
  * Whether the tool result is preliminary.
1500
1655
  *
@@ -1516,21 +1671,34 @@ type LanguageModelV3ToolResult = {
1516
1671
  providerMetadata?: SharedV3ProviderMetadata;
1517
1672
  };
1518
1673
 
1519
- type LanguageModelV3Content = LanguageModelV3Text | LanguageModelV3Reasoning | LanguageModelV3File | LanguageModelV3Source | LanguageModelV3ToolCall | LanguageModelV3ToolResult;
1674
+ type LanguageModelV3Content = LanguageModelV3Text | LanguageModelV3Reasoning | LanguageModelV3File | LanguageModelV3ToolApprovalRequest | LanguageModelV3Source | LanguageModelV3ToolCall | LanguageModelV3ToolResult;
1520
1675
 
1521
1676
  /**
1522
- Reason why a language model finished generating a response.
1523
-
1524
- Can be one of the following:
1525
- - `stop`: model generated stop sequence
1526
- - `length`: model generated maximum number of tokens
1527
- - `content-filter`: content filter violation stopped the model
1528
- - `tool-calls`: model triggered tool calls
1529
- - `error`: model stopped because of an error
1530
- - `other`: model stopped for other reasons
1531
- - `unknown`: the model has not transmitted a finish reason
1677
+ * Reason why a language model finished generating a response.
1678
+ *
1679
+ * Contains both a unified finish reason and a raw finish reason from the provider.
1680
+ * The unified finish reason is used to provide a consistent finish reason across different providers.
1681
+ * The raw finish reason is used to provide the original finish reason from the provider.
1532
1682
  */
1533
- type LanguageModelV3FinishReason = 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other' | 'unknown';
1683
+ type LanguageModelV3FinishReason = {
1684
+ /**
1685
+ * Unified finish reason. This enables using the same finish reason across different providers.
1686
+ *
1687
+ * Can be one of the following:
1688
+ * - `stop`: model generated stop sequence
1689
+ * - `length`: model generated maximum number of tokens
1690
+ * - `content-filter`: content filter violation stopped the model
1691
+ * - `tool-calls`: model triggered tool calls
1692
+ * - `error`: model stopped because of an error
1693
+ * - `other`: model stopped for other reasons
1694
+ */
1695
+ unified: 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other';
1696
+ /**
1697
+ * Raw finish reason from the provider.
1698
+ * This is the original finish reason from the provider.
1699
+ */
1700
+ raw: string | undefined;
1701
+ };
1534
1702
 
1535
1703
  interface LanguageModelV3ResponseMetadata {
1536
1704
  /**
@@ -1548,34 +1716,104 @@ interface LanguageModelV3ResponseMetadata {
1548
1716
  }
1549
1717
 
1550
1718
  /**
1551
- Usage information for a language model call.
1552
-
1553
- If your API return additional usage information, you can add it to the
1554
- provider metadata under your provider's key.
1719
+ * Usage information for a language model call.
1555
1720
  */
1556
1721
  type LanguageModelV3Usage = {
1557
1722
  /**
1558
- The number of input (prompt) tokens used.
1723
+ * Information about the input tokens.
1559
1724
  */
1560
- inputTokens: number | undefined;
1725
+ inputTokens: {
1726
+ /**
1727
+ *The total number of input (prompt) tokens used.
1728
+ */
1729
+ total: number | undefined;
1730
+ /**
1731
+ * The number of non-cached input (prompt) tokens used.
1732
+ */
1733
+ noCache: number | undefined;
1734
+ /**
1735
+ * The number of cached input (prompt) tokens read.
1736
+ */
1737
+ cacheRead: number | undefined;
1738
+ /**
1739
+ * The number of cached input (prompt) tokens written.
1740
+ */
1741
+ cacheWrite: number | undefined;
1742
+ };
1561
1743
  /**
1562
- The number of output (completion) tokens used.
1744
+ * Information about the output tokens.
1563
1745
  */
1564
- outputTokens: number | undefined;
1746
+ outputTokens: {
1747
+ /**
1748
+ * The total number of output (completion) tokens used.
1749
+ */
1750
+ total: number | undefined;
1751
+ /**
1752
+ * The number of text tokens used.
1753
+ */
1754
+ text: number | undefined;
1755
+ /**
1756
+ * The number of reasoning tokens used.
1757
+ */
1758
+ reasoning: number | undefined;
1759
+ };
1565
1760
  /**
1566
- The total number of tokens as reported by the provider.
1567
- This number might be different from the sum of `inputTokens` and `outputTokens`
1568
- and e.g. include reasoning tokens or other overhead.
1761
+ * Raw usage information from the provider.
1762
+ *
1763
+ * This is the usage information in the shape that the provider returns.
1764
+ * It can include additional information that is not part of the standard usage information.
1569
1765
  */
1570
- totalTokens: number | undefined;
1766
+ raw?: JSONObject;
1767
+ };
1768
+
1769
+ /**
1770
+ * The result of a language model doGenerate call.
1771
+ */
1772
+ type LanguageModelV3GenerateResult = {
1571
1773
  /**
1572
- The number of reasoning tokens used.
1774
+ * Ordered content that the model has generated.
1573
1775
  */
1574
- reasoningTokens?: number | undefined;
1776
+ content: Array<LanguageModelV3Content>;
1777
+ /**
1778
+ * The finish reason.
1779
+ */
1780
+ finishReason: LanguageModelV3FinishReason;
1781
+ /**
1782
+ * The usage information.
1783
+ */
1784
+ usage: LanguageModelV3Usage;
1785
+ /**
1786
+ * Additional provider-specific metadata. They are passed through
1787
+ * from the provider to the AI SDK and enable provider-specific
1788
+ * results that can be fully encapsulated in the provider.
1789
+ */
1790
+ providerMetadata?: SharedV3ProviderMetadata;
1791
+ /**
1792
+ * Optional request information for telemetry and debugging purposes.
1793
+ */
1794
+ request?: {
1795
+ /**
1796
+ * Request HTTP body that was sent to the provider API.
1797
+ */
1798
+ body?: unknown;
1799
+ };
1800
+ /**
1801
+ * Optional response information for telemetry and debugging purposes.
1802
+ */
1803
+ response?: LanguageModelV3ResponseMetadata & {
1804
+ /**
1805
+ * Response headers.
1806
+ */
1807
+ headers?: SharedV3Headers;
1808
+ /**
1809
+ * Response HTTP body.
1810
+ */
1811
+ body?: unknown;
1812
+ };
1575
1813
  /**
1576
- The number of cached input tokens.
1814
+ * Warnings for the call, e.g. unsupported settings.
1577
1815
  */
1578
- cachedInputTokens?: number | undefined;
1816
+ warnings: Array<SharedV3Warning>;
1579
1817
  };
1580
1818
 
1581
1819
  type LanguageModelV3StreamPart = {
@@ -1611,6 +1849,7 @@ type LanguageModelV3StreamPart = {
1611
1849
  providerMetadata?: SharedV3ProviderMetadata;
1612
1850
  providerExecuted?: boolean;
1613
1851
  dynamic?: boolean;
1852
+ title?: string;
1614
1853
  } | {
1615
1854
  type: 'tool-input-delta';
1616
1855
  id: string;
@@ -1620,9 +1859,9 @@ type LanguageModelV3StreamPart = {
1620
1859
  type: 'tool-input-end';
1621
1860
  id: string;
1622
1861
  providerMetadata?: SharedV3ProviderMetadata;
1623
- } | LanguageModelV3ToolCall | LanguageModelV3ToolResult | LanguageModelV3File | LanguageModelV3Source | {
1862
+ } | LanguageModelV3ToolApprovalRequest | LanguageModelV3ToolCall | LanguageModelV3ToolResult | LanguageModelV3File | LanguageModelV3Source | {
1624
1863
  type: 'stream-start';
1625
- warnings: Array<LanguageModelV3CallWarning>;
1864
+ warnings: Array<SharedV3Warning>;
1626
1865
  } | ({
1627
1866
  type: 'response-metadata';
1628
1867
  } & LanguageModelV3ResponseMetadata) | {
@@ -1639,115 +1878,78 @@ type LanguageModelV3StreamPart = {
1639
1878
  };
1640
1879
 
1641
1880
  /**
1642
- Specification for a language model that implements the language model interface version 3.
1881
+ * The result of a language model doStream call.
1882
+ */
1883
+ type LanguageModelV3StreamResult = {
1884
+ /**
1885
+ * The stream.
1886
+ */
1887
+ stream: ReadableStream<LanguageModelV3StreamPart>;
1888
+ /**
1889
+ * Optional request information for telemetry and debugging purposes.
1890
+ */
1891
+ request?: {
1892
+ /**
1893
+ * Request HTTP body that was sent to the provider API.
1894
+ */
1895
+ body?: unknown;
1896
+ };
1897
+ /**
1898
+ * Optional response data.
1899
+ */
1900
+ response?: {
1901
+ /**
1902
+ * Response headers.
1903
+ */
1904
+ headers?: SharedV3Headers;
1905
+ };
1906
+ };
1907
+
1908
+ /**
1909
+ * Specification for a language model that implements the language model interface version 3.
1643
1910
  */
1644
1911
  type LanguageModelV3 = {
1645
1912
  /**
1646
- The language model must specify which language model interface version it implements.
1913
+ * The language model must specify which language model interface version it implements.
1647
1914
  */
1648
1915
  readonly specificationVersion: 'v3';
1649
1916
  /**
1650
- Provider ID.
1917
+ * Provider ID.
1651
1918
  */
1652
1919
  readonly provider: string;
1653
1920
  /**
1654
- Provider-specific model ID.
1921
+ * Provider-specific model ID.
1655
1922
  */
1656
1923
  readonly modelId: string;
1657
1924
  /**
1658
- Supported URL patterns by media type for the provider.
1659
-
1660
- The keys are media type patterns or full media types (e.g. `*\/*` for everything, `audio/*`, `video/*`, or `application/pdf`).
1661
- and the values are arrays of regular expressions that match the URL paths.
1662
-
1663
- The matching should be against lower-case URLs.
1664
-
1665
- Matched URLs are supported natively by the model and are not downloaded.
1666
-
1667
- @returns A map of supported URL patterns by media type (as a promise or a plain object).
1925
+ * Supported URL patterns by media type for the provider.
1926
+ *
1927
+ * The keys are media type patterns or full media types (e.g. `*\/*` for everything, `audio/*`, `video/*`, or `application/pdf`).
1928
+ * and the values are arrays of regular expressions that match the URL paths.
1929
+ *
1930
+ * The matching should be against lower-case URLs.
1931
+ *
1932
+ * Matched URLs are supported natively by the model and are not downloaded.
1933
+ *
1934
+ * @returns A map of supported URL patterns by media type (as a promise or a plain object).
1668
1935
  */
1669
1936
  supportedUrls: PromiseLike<Record<string, RegExp[]>> | Record<string, RegExp[]>;
1670
1937
  /**
1671
- Generates a language model output (non-streaming).
1938
+ * Generates a language model output (non-streaming).
1672
1939
 
1673
- Naming: "do" prefix to prevent accidental direct usage of the method
1674
- by the user.
1940
+ * Naming: "do" prefix to prevent accidental direct usage of the method
1941
+ * by the user.
1675
1942
  */
1676
- doGenerate(options: LanguageModelV3CallOptions): PromiseLike<{
1677
- /**
1678
- Ordered content that the model has generated.
1679
- */
1680
- content: Array<LanguageModelV3Content>;
1681
- /**
1682
- Finish reason.
1683
- */
1684
- finishReason: LanguageModelV3FinishReason;
1685
- /**
1686
- Usage information.
1687
- */
1688
- usage: LanguageModelV3Usage;
1689
- /**
1690
- Additional provider-specific metadata. They are passed through
1691
- from the provider to the AI SDK and enable provider-specific
1692
- results that can be fully encapsulated in the provider.
1693
- */
1694
- providerMetadata?: SharedV3ProviderMetadata;
1695
- /**
1696
- Optional request information for telemetry and debugging purposes.
1697
- */
1698
- request?: {
1699
- /**
1700
- Request HTTP body that was sent to the provider API.
1701
- */
1702
- body?: unknown;
1703
- };
1704
- /**
1705
- Optional response information for telemetry and debugging purposes.
1706
- */
1707
- response?: LanguageModelV3ResponseMetadata & {
1708
- /**
1709
- Response headers.
1710
- */
1711
- headers?: SharedV3Headers;
1712
- /**
1713
- Response HTTP body.
1714
- */
1715
- body?: unknown;
1716
- };
1717
- /**
1718
- Warnings for the call, e.g. unsupported settings.
1719
- */
1720
- warnings: Array<LanguageModelV3CallWarning>;
1721
- }>;
1943
+ doGenerate(options: LanguageModelV3CallOptions): PromiseLike<LanguageModelV3GenerateResult>;
1722
1944
  /**
1723
- Generates a language model output (streaming).
1724
-
1725
- Naming: "do" prefix to prevent accidental direct usage of the method
1726
- by the user.
1945
+ * Generates a language model output (streaming).
1727
1946
  *
1728
- @return A stream of higher-level language model output parts.
1947
+ * Naming: "do" prefix to prevent accidental direct usage of the method
1948
+ * by the user.
1949
+ *
1950
+ * @return A stream of higher-level language model output parts.
1729
1951
  */
1730
- doStream(options: LanguageModelV3CallOptions): PromiseLike<{
1731
- stream: ReadableStream<LanguageModelV3StreamPart>;
1732
- /**
1733
- Optional request information for telemetry and debugging purposes.
1734
- */
1735
- request?: {
1736
- /**
1737
- Request HTTP body that was sent to the provider API.
1738
- */
1739
- body?: unknown;
1740
- };
1741
- /**
1742
- Optional response data.
1743
- */
1744
- response?: {
1745
- /**
1746
- Response headers.
1747
- */
1748
- headers?: SharedV3Headers;
1749
- };
1750
- }>;
1952
+ doStream(options: LanguageModelV3CallOptions): PromiseLike<LanguageModelV3StreamResult>;
1751
1953
  };
1752
1954
 
1753
1955
  /**
@@ -1759,7 +1961,7 @@ type LanguageModelV3Middleware = {
1759
1961
  /**
1760
1962
  * Middleware specification version. Use `v3` for the current version.
1761
1963
  */
1762
- middlewareVersion?: 'v3' | undefined;
1964
+ readonly specificationVersion: 'v3';
1763
1965
  /**
1764
1966
  * Override the provider name if desired.
1765
1967
  * @param options.model - The language model instance.
@@ -1804,11 +2006,11 @@ type LanguageModelV3Middleware = {
1804
2006
  * @returns A promise that resolves to the result of the generate operation.
1805
2007
  */
1806
2008
  wrapGenerate?: (options: {
1807
- doGenerate: () => ReturnType<LanguageModelV3['doGenerate']>;
1808
- doStream: () => ReturnType<LanguageModelV3['doStream']>;
2009
+ doGenerate: () => PromiseLike<LanguageModelV3GenerateResult>;
2010
+ doStream: () => PromiseLike<LanguageModelV3StreamResult>;
1809
2011
  params: LanguageModelV3CallOptions;
1810
2012
  model: LanguageModelV3;
1811
- }) => Promise<Awaited<ReturnType<LanguageModelV3['doGenerate']>>>;
2013
+ }) => PromiseLike<LanguageModelV3GenerateResult>;
1812
2014
  /**
1813
2015
  * Wraps the stream operation of the language model.
1814
2016
  *
@@ -1821,11 +2023,11 @@ type LanguageModelV3Middleware = {
1821
2023
  * @returns A promise that resolves to the result of the stream operation.
1822
2024
  */
1823
2025
  wrapStream?: (options: {
1824
- doGenerate: () => ReturnType<LanguageModelV3['doGenerate']>;
1825
- doStream: () => ReturnType<LanguageModelV3['doStream']>;
2026
+ doGenerate: () => PromiseLike<LanguageModelV3GenerateResult>;
2027
+ doStream: () => PromiseLike<LanguageModelV3StreamResult>;
1826
2028
  params: LanguageModelV3CallOptions;
1827
2029
  model: LanguageModelV3;
1828
- }) => PromiseLike<Awaited<ReturnType<LanguageModelV3['doStream']>>>;
2030
+ }) => PromiseLike<LanguageModelV3StreamResult>;
1829
2031
  };
1830
2032
 
1831
2033
  /**
@@ -2044,11 +2246,11 @@ IANA media type.
2044
2246
  /**
2045
2247
  The configuration of a tool that is defined by the provider.
2046
2248
  */
2047
- type LanguageModelV2ProviderDefinedTool = {
2249
+ type LanguageModelV2ProviderTool = {
2048
2250
  /**
2049
- The type of the tool (always 'provider-defined').
2251
+ The type of the tool (always 'provider').
2050
2252
  */
2051
- type: 'provider-defined';
2253
+ type: 'provider';
2052
2254
  /**
2053
2255
  The ID of the tool. Should follow the format `<provider-name>.<unique-tool-name>`.
2054
2256
  */
@@ -2149,7 +2351,7 @@ type LanguageModelV2CallOptions = {
2149
2351
  /**
2150
2352
  The tools that are available for the model.
2151
2353
  */
2152
- tools?: Array<LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool>;
2354
+ tools?: Array<LanguageModelV2FunctionTool | LanguageModelV2ProviderTool>;
2153
2355
  /**
2154
2356
  Specifies how the tool should be selected. Defaults to 'auto'.
2155
2357
  */
@@ -2185,7 +2387,7 @@ type LanguageModelV2CallWarning = {
2185
2387
  details?: string;
2186
2388
  } | {
2187
2389
  type: 'unsupported-tool';
2188
- tool: LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool;
2390
+ tool: LanguageModelV2FunctionTool | LanguageModelV2ProviderTool;
2189
2391
  details?: string;
2190
2392
  } | {
2191
2393
  type: 'other';
@@ -2666,7 +2868,181 @@ type LanguageModelV2Middleware = {
2666
2868
  }) => PromiseLike<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
2667
2869
  };
2668
2870
 
2669
- type SpeechModelV3ProviderOptions = Record<string, Record<string, JSONValue>>;
2871
+ /**
2872
+ * Middleware for EmbeddingModelV3.
2873
+ * This type defines the structure for middleware that can be used to modify
2874
+ * the behavior of EmbeddingModelV3 operations.
2875
+ */
2876
+ type EmbeddingModelV3Middleware = {
2877
+ /**
2878
+ * Middleware specification version. Use `v3` for the current version.
2879
+ */
2880
+ readonly specificationVersion: 'v3';
2881
+ /**
2882
+ * Override the provider name if desired.
2883
+ * @param options.model - The embedding model instance.
2884
+ */
2885
+ overrideProvider?: (options: {
2886
+ model: EmbeddingModelV3;
2887
+ }) => string;
2888
+ /**
2889
+ * Override the model ID if desired.
2890
+ * @param options.model - The embedding model instance.
2891
+ */
2892
+ overrideModelId?: (options: {
2893
+ model: EmbeddingModelV3;
2894
+ }) => string;
2895
+ /**
2896
+ * Override the limit of how many embeddings can be generated in a single API call if desired.
2897
+ * @param options.model - The embedding model instance.
2898
+ */
2899
+ overrideMaxEmbeddingsPerCall?: (options: {
2900
+ model: EmbeddingModelV3;
2901
+ }) => PromiseLike<number | undefined> | number | undefined;
2902
+ /**
2903
+ * Override support for handling multiple embedding calls in parallel, if desired..
2904
+ * @param options.model - The embedding model instance.
2905
+ */
2906
+ overrideSupportsParallelCalls?: (options: {
2907
+ model: EmbeddingModelV3;
2908
+ }) => PromiseLike<boolean> | boolean;
2909
+ /**
2910
+ * Transforms the parameters before they are passed to the embed model.
2911
+ * @param options - Object containing the type of operation and the parameters.
2912
+ * @param options.params - The original parameters for the embedding model call.
2913
+ * @returns A promise that resolves to the transformed parameters.
2914
+ */
2915
+ transformParams?: (options: {
2916
+ params: EmbeddingModelV3CallOptions;
2917
+ model: EmbeddingModelV3;
2918
+ }) => PromiseLike<EmbeddingModelV3CallOptions>;
2919
+ /**
2920
+ * Wraps the embed operation of the embedding model.
2921
+ *
2922
+ * @param options - Object containing the embed function, parameters, and model.
2923
+ * @param options.doEmbed - The original embed function.
2924
+ * @param options.params - The parameters for the embed call. If the
2925
+ * `transformParams` middleware is used, this will be the transformed parameters.
2926
+ * @param options.model - The embedding model instance.
2927
+ * @returns A promise that resolves to the result of the generate operation.
2928
+ */
2929
+ wrapEmbed?: (options: {
2930
+ doEmbed: () => ReturnType<EmbeddingModelV3['doEmbed']>;
2931
+ params: EmbeddingModelV3CallOptions;
2932
+ model: EmbeddingModelV3;
2933
+ }) => Promise<Awaited<ReturnType<EmbeddingModelV3['doEmbed']>>>;
2934
+ };
2935
+
2936
+ type RerankingModelV3CallOptions = {
2937
+ /**
2938
+ * Documents to rerank.
2939
+ * Either a list of texts or a list of JSON objects.
2940
+ */
2941
+ documents: {
2942
+ type: 'text';
2943
+ values: string[];
2944
+ } | {
2945
+ type: 'object';
2946
+ values: JSONObject[];
2947
+ };
2948
+ /**
2949
+ * The query is a string that represents the query to rerank the documents against.
2950
+ */
2951
+ query: string;
2952
+ /**
2953
+ * Optional limit returned documents to the top n documents.
2954
+ */
2955
+ topN?: number;
2956
+ /**
2957
+ * Abort signal for cancelling the operation.
2958
+ */
2959
+ abortSignal?: AbortSignal;
2960
+ /**
2961
+ * Additional provider-specific options. They are passed through
2962
+ * to the provider from the AI SDK and enable provider-specific
2963
+ * functionality that can be fully encapsulated in the provider.
2964
+ */
2965
+ providerOptions?: SharedV3ProviderOptions;
2966
+ /**
2967
+ * Additional HTTP headers to be sent with the request.
2968
+ * Only applicable for HTTP-based providers.
2969
+ */
2970
+ headers?: SharedV3Headers;
2971
+ };
2972
+
2973
+ /**
2974
+ * Specification for a reranking model that implements the reranking model interface version 3.
2975
+ */
2976
+ type RerankingModelV3 = {
2977
+ /**
2978
+ * The reranking model must specify which reranking model interface version it implements.
2979
+ */
2980
+ readonly specificationVersion: 'v3';
2981
+ /**
2982
+ * Provider ID.
2983
+ */
2984
+ readonly provider: string;
2985
+ /**
2986
+ * Provider-specific model ID.
2987
+ */
2988
+ readonly modelId: string;
2989
+ /**
2990
+ * Reranking a list of documents using the query.
2991
+ */
2992
+ doRerank(options: RerankingModelV3CallOptions): PromiseLike<{
2993
+ /**
2994
+ * Ordered list of reranked documents (via index before reranking).
2995
+ * The documents are sorted by the descending order of relevance scores.
2996
+ */
2997
+ ranking: Array<{
2998
+ /**
2999
+ * The index of the document in the original list of documents before reranking.
3000
+ */
3001
+ index: number;
3002
+ /**
3003
+ * The relevance score of the document after reranking.
3004
+ */
3005
+ relevanceScore: number;
3006
+ }>;
3007
+ /**
3008
+ * Additional provider-specific metadata. They are passed through
3009
+ * to the provider from the AI SDK and enable provider-specific
3010
+ * functionality that can be fully encapsulated in the provider.
3011
+ */
3012
+ providerMetadata?: SharedV3ProviderMetadata;
3013
+ /**
3014
+ * Warnings for the call, e.g. unsupported settings.
3015
+ */
3016
+ warnings?: Array<SharedV3Warning>;
3017
+ /**
3018
+ * Optional response information for debugging purposes.
3019
+ */
3020
+ response?: {
3021
+ /**
3022
+ * ID for the generated response, if the provider sends one.
3023
+ */
3024
+ id?: string;
3025
+ /**
3026
+ * Timestamp for the start of the generated response, if the provider sends one.
3027
+ */
3028
+ timestamp?: Date;
3029
+ /**
3030
+ * The ID of the response model that was used to generate the response, if the provider sends one.
3031
+ */
3032
+ modelId?: string;
3033
+ /**
3034
+ * Response headers.
3035
+ */
3036
+ headers?: SharedV3Headers;
3037
+ /**
3038
+ * Response body.
3039
+ */
3040
+ body?: unknown;
3041
+ };
3042
+ }>;
3043
+ };
3044
+
3045
+ type SpeechModelV3ProviderOptions = Record<string, JSONObject>;
2670
3046
  type SpeechModelV3CallOptions = {
2671
3047
  /**
2672
3048
  * Text to convert to speech.
@@ -2718,19 +3094,6 @@ type SpeechModelV3CallOptions = {
2718
3094
  headers?: Record<string, string | undefined>;
2719
3095
  };
2720
3096
 
2721
- /**
2722
- * Warning from the model provider for this call. The call will proceed, but e.g.
2723
- * some settings might not be supported, which can lead to suboptimal results.
2724
- */
2725
- type SpeechModelV3CallWarning = {
2726
- type: 'unsupported-setting';
2727
- setting: keyof SpeechModelV3CallOptions;
2728
- details?: string;
2729
- } | {
2730
- type: 'other';
2731
- message: string;
2732
- };
2733
-
2734
3097
  /**
2735
3098
  * Speech model specification version 3.
2736
3099
  */
@@ -2766,7 +3129,7 @@ type SpeechModelV3 = {
2766
3129
  /**
2767
3130
  * Warnings for the call, e.g. unsupported settings.
2768
3131
  */
2769
- warnings: Array<SpeechModelV3CallWarning>;
3132
+ warnings: Array<SharedV3Warning>;
2770
3133
  /**
2771
3134
  * Optional request information for telemetry and debugging purposes.
2772
3135
  */
@@ -2802,11 +3165,11 @@ type SpeechModelV3 = {
2802
3165
  * from the provider to the AI SDK and enable provider-specific
2803
3166
  * results that can be fully encapsulated in the provider.
2804
3167
  */
2805
- providerMetadata?: Record<string, Record<string, JSONValue>>;
3168
+ providerMetadata?: Record<string, JSONObject>;
2806
3169
  }>;
2807
3170
  };
2808
3171
 
2809
- type TranscriptionModelV3ProviderOptions = Record<string, Record<string, JSONValue>>;
3172
+ type TranscriptionModelV3ProviderOptions = Record<string, JSONObject>;
2810
3173
  type TranscriptionModelV3CallOptions = {
2811
3174
  /**
2812
3175
  Audio data to transcribe.
@@ -2845,19 +3208,6 @@ type TranscriptionModelV3CallOptions = {
2845
3208
  headers?: Record<string, string | undefined>;
2846
3209
  };
2847
3210
 
2848
- /**
2849
- Warning from the model provider for this call. The call will proceed, but e.g.
2850
- some settings might not be supported, which can lead to suboptimal results.
2851
- */
2852
- type TranscriptionModelV3CallWarning = {
2853
- type: 'unsupported-setting';
2854
- setting: keyof TranscriptionModelV3CallOptions;
2855
- details?: string;
2856
- } | {
2857
- type: 'other';
2858
- message: string;
2859
- };
2860
-
2861
3211
  /**
2862
3212
  Transcription model specification version 3.
2863
3213
  */
@@ -2917,7 +3267,7 @@ type TranscriptionModelV3 = {
2917
3267
  /**
2918
3268
  Warnings for the call, e.g. unsupported settings.
2919
3269
  */
2920
- warnings: Array<TranscriptionModelV3CallWarning>;
3270
+ warnings: Array<SharedV3Warning>;
2921
3271
  /**
2922
3272
  Optional request information for telemetry and debugging purposes.
2923
3273
  */
@@ -2954,7 +3304,7 @@ type TranscriptionModelV3 = {
2954
3304
  from the provider to the AI SDK and enable provider-specific
2955
3305
  results that can be fully encapsulated in the provider.
2956
3306
  */
2957
- providerMetadata?: Record<string, Record<string, JSONValue>>;
3307
+ providerMetadata?: Record<string, JSONObject>;
2958
3308
  }>;
2959
3309
  };
2960
3310
 
@@ -2962,6 +3312,7 @@ type TranscriptionModelV3 = {
2962
3312
  * Provider for language, text embedding, and image generation models.
2963
3313
  */
2964
3314
  interface ProviderV3 {
3315
+ readonly specificationVersion: 'v3';
2965
3316
  /**
2966
3317
  Returns the language model with the given id.
2967
3318
  The model id is then passed to the provider function to get the model.
@@ -2983,7 +3334,20 @@ interface ProviderV3 {
2983
3334
 
2984
3335
  @throws {NoSuchModelError} If no such model exists.
2985
3336
  */
2986
- textEmbeddingModel(modelId: string): EmbeddingModelV3<string>;
3337
+ embeddingModel(modelId: string): EmbeddingModelV3;
3338
+ /**
3339
+ Returns the text embedding model with the given id.
3340
+ The model id is then passed to the provider function to get the model.
3341
+
3342
+ @param {string} modelId - The id of the model to return.
3343
+
3344
+ @returns {EmbeddingModel} The embedding model associated with the id
3345
+
3346
+ @throws {NoSuchModelError} If no such model exists.
3347
+
3348
+ @deprecated Use `embeddingModel` instead.
3349
+ */
3350
+ textEmbeddingModel?(modelId: string): EmbeddingModelV3;
2987
3351
  /**
2988
3352
  Returns the image model with the given id.
2989
3353
  The model id is then passed to the provider function to get the model.
@@ -3011,6 +3375,17 @@ interface ProviderV3 {
3011
3375
  @returns {SpeechModel} The speech model associated with the id
3012
3376
  */
3013
3377
  speechModel?(modelId: string): SpeechModelV3;
3378
+ /**
3379
+ Returns the reranking model with the given id.
3380
+ The model id is then passed to the provider function to get the model.
3381
+
3382
+ @param {string} modelId - The id of the model to return.
3383
+
3384
+ @returns {RerankingModel} The reranking model associated with the id
3385
+
3386
+ @throws {NoSuchModelError} If no such model exists.
3387
+ */
3388
+ rerankingModel?(modelId: string): RerankingModelV3;
3014
3389
  }
3015
3390
 
3016
3391
  type SpeechModelV2ProviderOptions = Record<string, Record<string, JSONValue>>;
@@ -3360,4 +3735,4 @@ interface ProviderV2 {
3360
3735
  speechModel?(modelId: string): SpeechModelV2;
3361
3736
  }
3362
3737
 
3363
- export { AISDKError, APICallError, type EmbeddingModelV2, type EmbeddingModelV2Embedding, type EmbeddingModelV3, type EmbeddingModelV3Embedding, EmptyResponseBodyError, type ImageModelV2, type ImageModelV2CallOptions, type ImageModelV2CallWarning, type ImageModelV2ProviderMetadata, type ImageModelV3, type ImageModelV3CallOptions, type ImageModelV3CallWarning, type ImageModelV3ProviderMetadata, InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV2, type LanguageModelV2CallOptions, type LanguageModelV2CallWarning, type LanguageModelV2Content, type LanguageModelV2DataContent, type LanguageModelV2File, type LanguageModelV2FilePart, type LanguageModelV2FinishReason, type LanguageModelV2FunctionTool, type LanguageModelV2Message, type LanguageModelV2Middleware, type LanguageModelV2Prompt, type LanguageModelV2ProviderDefinedTool, type LanguageModelV2Reasoning, type LanguageModelV2ReasoningPart, type LanguageModelV2ResponseMetadata, type LanguageModelV2Source, type LanguageModelV2StreamPart, type LanguageModelV2Text, type LanguageModelV2TextPart, type LanguageModelV2ToolCall, type LanguageModelV2ToolCallPart, type LanguageModelV2ToolChoice, type LanguageModelV2ToolResultOutput, type LanguageModelV2ToolResultPart, type LanguageModelV2Usage, type LanguageModelV3, type LanguageModelV3CallOptions, type LanguageModelV3CallWarning, type LanguageModelV3Content, type LanguageModelV3DataContent, type LanguageModelV3File, type LanguageModelV3FilePart, type LanguageModelV3FinishReason, type LanguageModelV3FunctionTool, type LanguageModelV3Message, type LanguageModelV3Middleware, type LanguageModelV3Prompt, type LanguageModelV3ProviderDefinedTool, type LanguageModelV3Reasoning, type LanguageModelV3ReasoningPart, type LanguageModelV3ResponseMetadata, type LanguageModelV3Source, type LanguageModelV3StreamPart, type LanguageModelV3Text, type LanguageModelV3TextPart, type LanguageModelV3ToolCall, type LanguageModelV3ToolCallPart, type LanguageModelV3ToolChoice, type LanguageModelV3ToolResult, type LanguageModelV3ToolResultOutput, type LanguageModelV3ToolResultPart, type LanguageModelV3Usage, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV2, type ProviderV3, type SharedV2Headers, type SharedV2ProviderMetadata, type SharedV2ProviderOptions, type SharedV3Headers, type SharedV3ProviderMetadata, type SharedV3ProviderOptions, type SpeechModelV2, type SpeechModelV2CallOptions, type SpeechModelV2CallWarning, type SpeechModelV3, type SpeechModelV3CallOptions, type SpeechModelV3CallWarning, TooManyEmbeddingValuesForCallError, type TranscriptionModelV2, type TranscriptionModelV2CallOptions, type TranscriptionModelV2CallWarning, type TranscriptionModelV3, type TranscriptionModelV3CallOptions, type TranscriptionModelV3CallWarning, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };
3738
+ export { AISDKError, APICallError, type EmbeddingModelV2, type EmbeddingModelV2Embedding, type EmbeddingModelV3, type EmbeddingModelV3CallOptions, type EmbeddingModelV3Embedding, type EmbeddingModelV3Middleware, type EmbeddingModelV3Result, EmptyResponseBodyError, type ImageModelV2, type ImageModelV2CallOptions, type ImageModelV2CallWarning, type ImageModelV2ProviderMetadata, type ImageModelV3, type ImageModelV3CallOptions, type ImageModelV3File, type ImageModelV3ProviderMetadata, type ImageModelV3Usage, InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV2, type LanguageModelV2CallOptions, type LanguageModelV2CallWarning, type LanguageModelV2Content, type LanguageModelV2DataContent, type LanguageModelV2File, type LanguageModelV2FilePart, type LanguageModelV2FinishReason, type LanguageModelV2FunctionTool, type LanguageModelV2Message, type LanguageModelV2Middleware, type LanguageModelV2Prompt, type LanguageModelV2ProviderTool, type LanguageModelV2Reasoning, type LanguageModelV2ReasoningPart, type LanguageModelV2ResponseMetadata, type LanguageModelV2Source, type LanguageModelV2StreamPart, type LanguageModelV2Text, type LanguageModelV2TextPart, type LanguageModelV2ToolCall, type LanguageModelV2ToolCallPart, type LanguageModelV2ToolChoice, type LanguageModelV2ToolResultOutput, type LanguageModelV2ToolResultPart, type LanguageModelV2Usage, type LanguageModelV3, type LanguageModelV3CallOptions, type LanguageModelV3Content, type LanguageModelV3DataContent, type LanguageModelV3File, type LanguageModelV3FilePart, type LanguageModelV3FinishReason, type LanguageModelV3FunctionTool, type LanguageModelV3GenerateResult, type LanguageModelV3Message, type LanguageModelV3Middleware, type LanguageModelV3Prompt, type LanguageModelV3ProviderTool, type LanguageModelV3Reasoning, type LanguageModelV3ReasoningPart, type LanguageModelV3ResponseMetadata, type LanguageModelV3Source, type LanguageModelV3StreamPart, type LanguageModelV3StreamResult, type LanguageModelV3Text, type LanguageModelV3TextPart, type LanguageModelV3ToolApprovalRequest, type LanguageModelV3ToolApprovalResponsePart, type LanguageModelV3ToolCall, type LanguageModelV3ToolCallPart, type LanguageModelV3ToolChoice, type LanguageModelV3ToolResult, type LanguageModelV3ToolResultOutput, type LanguageModelV3ToolResultPart, type LanguageModelV3Usage, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV2, type ProviderV3, type RerankingModelV3, type RerankingModelV3CallOptions, type SharedV2Headers, type SharedV2ProviderMetadata, type SharedV2ProviderOptions, type SharedV3Headers, type SharedV3ProviderMetadata, type SharedV3ProviderOptions, type SharedV3Warning, type SpeechModelV2, type SpeechModelV2CallOptions, type SpeechModelV2CallWarning, type SpeechModelV3, type SpeechModelV3CallOptions, TooManyEmbeddingValuesForCallError, type TranscriptionModelV2, type TranscriptionModelV2CallOptions, type TranscriptionModelV2CallWarning, type TranscriptionModelV3, type TranscriptionModelV3CallOptions, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };