@ai-sdk/provider 3.0.0-beta.9 → 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,31 +57,48 @@ 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
61
 
62
62
  /**
63
- * Warning from the model that certain features are e.g. unsupported or that compatibility
63
+ * Warning from the model.
64
+ *
65
+ * For example, that certain features are unsupported or compatibility
64
66
  * functionality is used (which might lead to suboptimal results).
65
67
  */
66
68
  type SharedV3Warning = {
67
69
  /**
68
- * A configuration setting is not supported by the model.
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.
69
79
  */
70
- type: 'unsupported-setting';
71
- setting: string;
72
80
  details?: string;
73
81
  } | {
74
82
  /**
75
83
  * A compatibility feature is used that might lead to suboptimal results.
76
84
  */
77
85
  type: 'compatibility';
86
+ /**
87
+ * The feature that is used in a compatibility mode.
88
+ */
78
89
  feature: string;
90
+ /**
91
+ * Additional details about the warning.
92
+ */
79
93
  details?: string;
80
94
  } | {
81
95
  /**
82
96
  * Other warning.
83
97
  */
84
98
  type: 'other';
99
+ /**
100
+ * The message of the warning.
101
+ */
85
102
  message: string;
86
103
  };
87
104
 
@@ -133,21 +150,80 @@ type SharedV2ProviderMetadata = Record<string, Record<string, JSONValue>>;
133
150
  */
134
151
  type SharedV2ProviderOptions = Record<string, Record<string, JSONValue>>;
135
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
+
136
175
  /**
137
176
  An embedding is a vector, i.e. an array of numbers.
138
177
  It is e.g. used to represent a text as a vector of word embeddings.
139
178
  */
140
179
  type EmbeddingModelV3Embedding = Array<number>;
141
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
+
142
220
  /**
143
221
  Specification for an embedding model that implements the embedding model
144
- interface version 1.
222
+ interface version 3.
145
223
 
146
- VALUE is the type of the values that the model can embed.
147
- This will allow us to go beyond text embeddings in the future,
148
- e.g. to support image embeddings
224
+ It is specific to text embeddings.
149
225
  */
150
- type EmbeddingModelV3<VALUE> = {
226
+ type EmbeddingModelV3 = {
151
227
  /**
152
228
  The embedding model must specify which embedding model interface
153
229
  version it implements. This will allow us to evolve the embedding
@@ -180,57 +256,7 @@ type EmbeddingModelV3<VALUE> = {
180
256
  Naming: "do" prefix to prevent accidental direct usage of the method
181
257
  by the user.
182
258
  */
183
- doEmbed(options: {
184
- /**
185
- List of values to embed.
186
- */
187
- values: Array<VALUE>;
188
- /**
189
- Abort signal for cancelling the operation.
190
- */
191
- abortSignal?: AbortSignal;
192
- /**
193
- Additional provider-specific options. They are passed through
194
- to the provider from the AI SDK and enable provider-specific
195
- functionality that can be fully encapsulated in the provider.
196
- */
197
- providerOptions?: SharedV3ProviderOptions;
198
- /**
199
- Additional HTTP headers to be sent with the request.
200
- Only applicable for HTTP-based providers.
201
- */
202
- headers?: Record<string, string | undefined>;
203
- }): PromiseLike<{
204
- /**
205
- Generated embeddings. They are in the same order as the input values.
206
- */
207
- embeddings: Array<EmbeddingModelV3Embedding>;
208
- /**
209
- Token usage. We only have input tokens for embeddings.
210
- */
211
- usage?: {
212
- tokens: number;
213
- };
214
- /**
215
- Additional provider-specific metadata. They are passed through
216
- from the provider to the AI SDK and enable provider-specific
217
- results that can be fully encapsulated in the provider.
218
- */
219
- providerMetadata?: SharedV3ProviderMetadata;
220
- /**
221
- Optional response information for debugging purposes.
222
- */
223
- response?: {
224
- /**
225
- Response headers.
226
- */
227
- headers?: SharedV3Headers;
228
- /**
229
- The response body.
230
- */
231
- body?: unknown;
232
- };
233
- }>;
259
+ doEmbed(options: EmbeddingModelV3CallOptions): PromiseLike<EmbeddingModelV3Result>;
234
260
  };
235
261
 
236
262
  /**
@@ -493,11 +519,11 @@ declare const symbol$3: unique symbol;
493
519
  declare class NoSuchModelError extends AISDKError {
494
520
  private readonly [symbol$3];
495
521
  readonly modelId: string;
496
- readonly modelType: 'languageModel' | 'textEmbeddingModel' | 'imageModel' | 'transcriptionModel' | 'speechModel';
522
+ readonly modelType: 'languageModel' | 'embeddingModel' | 'imageModel' | 'transcriptionModel' | 'speechModel' | 'rerankingModel';
497
523
  constructor({ errorName, modelId, modelType, message, }: {
498
524
  errorName?: string;
499
525
  modelId: string;
500
- modelType: 'languageModel' | 'textEmbeddingModel' | 'imageModel' | 'transcriptionModel' | 'speechModel';
526
+ modelType: 'languageModel' | 'embeddingModel' | 'imageModel' | 'transcriptionModel' | 'speechModel' | 'rerankingModel';
501
527
  message?: string;
502
528
  });
503
529
  static isInstance(error: unknown): error is NoSuchModelError;
@@ -559,71 +585,123 @@ declare function isJSONValue(value: unknown): value is JSONValue;
559
585
  declare function isJSONArray(value: unknown): value is JSONArray;
560
586
  declare function isJSONObject(value: unknown): value is JSONObject;
561
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
+
562
642
  type ImageModelV3CallOptions = {
563
643
  /**
564
- Prompt for the image generation.
565
- */
566
- prompt: string;
644
+ * Prompt for the image generation. Some operations, like upscaling, may not require a prompt.
645
+ */
646
+ prompt: string | undefined;
567
647
  /**
568
- Number of images to generate.
569
- */
648
+ * Number of images to generate.
649
+ */
570
650
  n: number;
571
651
  /**
572
- Size of the images to generate.
573
- Must have the format `{width}x{height}`.
574
- `undefined` will use the provider's default size.
575
- */
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
+ */
576
656
  size: `${number}x${number}` | undefined;
577
657
  /**
578
- Aspect ratio of the images to generate.
579
- Must have the format `{width}:{height}`.
580
- `undefined` will use the provider's default aspect ratio.
581
- */
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
+ */
582
662
  aspectRatio: `${number}:${number}` | undefined;
583
663
  /**
584
- Seed for the image generation.
585
- `undefined` will use the provider's default seed.
586
- */
664
+ * Seed for the image generation.
665
+ * `undefined` will use the provider's default seed.
666
+ */
587
667
  seed: number | undefined;
588
668
  /**
589
- Additional provider-specific options that are passed through to the provider
590
- as body parameters.
591
-
592
- The outer record is keyed by the provider name, and the inner
593
- record is keyed by the provider-specific metadata key.
594
- ```ts
595
- {
596
- "openai": {
597
- "style": "vivid"
598
- }
599
- }
600
- ```
601
- */
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
+ */
602
693
  providerOptions: SharedV3ProviderOptions;
603
694
  /**
604
- Abort signal for cancelling the operation.
605
- */
695
+ * Abort signal for cancelling the operation.
696
+ */
606
697
  abortSignal?: AbortSignal;
607
698
  /**
608
- Additional HTTP headers to be sent with the request.
609
- Only applicable for HTTP-based providers.
610
- */
699
+ * Additional HTTP headers to be sent with the request.
700
+ * Only applicable for HTTP-based providers.
701
+ */
611
702
  headers?: Record<string, string | undefined>;
612
703
  };
613
704
 
614
- /**
615
- Warning from the model provider for this call. The call will proceed, but e.g.
616
- some settings might not be supported, which can lead to suboptimal results.
617
- */
618
- type ImageModelV3CallWarning = {
619
- type: 'unsupported-setting';
620
- setting: keyof ImageModelV3CallOptions;
621
- details?: string;
622
- } | {
623
- type: 'other';
624
- message: string;
625
- };
626
-
627
705
  type ImageModelV3ProviderMetadata = Record<string, {
628
706
  images: JSONArray;
629
707
  } & JSONValue>;
@@ -670,9 +748,9 @@ type ImageModelV3 = {
670
748
  */
671
749
  images: Array<string> | Array<Uint8Array>;
672
750
  /**
673
- Warnings for the call, e.g. unsupported settings.
751
+ Warnings for the call, e.g. unsupported features.
674
752
  */
675
- warnings: Array<ImageModelV3CallWarning>;
753
+ warnings: Array<SharedV3Warning>;
676
754
  /**
677
755
  Additional provider-specific metadata. They are passed through
678
756
  from the provider to the AI SDK and enable provider-specific
@@ -708,6 +786,10 @@ type ImageModelV3 = {
708
786
  */
709
787
  headers: Record<string, string> | undefined;
710
788
  };
789
+ /**
790
+ Optional token usage for the image generation call (if the provider reports it).
791
+ */
792
+ usage?: ImageModelV3Usage;
711
793
  }>;
712
794
  };
713
795
 
@@ -889,6 +971,21 @@ type LanguageModelV3FunctionTool = {
889
971
  */
890
972
  inputSchema: JSONSchema7;
891
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
+ /**
892
989
  The provider-specific options for the tool.
893
990
  */
894
991
  providerOptions?: SharedV3ProviderOptions;
@@ -920,7 +1017,7 @@ type LanguageModelV3Message = ({
920
1017
  content: Array<LanguageModelV3TextPart | LanguageModelV3FilePart | LanguageModelV3ReasoningPart | LanguageModelV3ToolCallPart | LanguageModelV3ToolResultPart>;
921
1018
  } | {
922
1019
  role: 'tool';
923
- content: Array<LanguageModelV3ToolResultPart>;
1020
+ content: Array<LanguageModelV3ToolResultPart | LanguageModelV3ToolApprovalResponsePart>;
924
1021
  }) & {
925
1022
  /**
926
1023
  * Additional provider-specific options. They are passed through
@@ -1042,6 +1139,31 @@ interface LanguageModelV3ToolResultPart {
1042
1139
  */
1043
1140
  providerOptions?: SharedV3ProviderOptions;
1044
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
+ }
1045
1167
  /**
1046
1168
  * Result of a tool call.
1047
1169
  */
@@ -1208,19 +1330,23 @@ IANA media type.
1208
1330
  };
1209
1331
 
1210
1332
  /**
1211
- * 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.
1212
1338
  */
1213
- type LanguageModelV3ProviderDefinedTool = {
1339
+ type LanguageModelV3ProviderTool = {
1214
1340
  /**
1215
- * The type of the tool (always 'provider-defined').
1341
+ * The type of the tool (always 'provider').
1216
1342
  */
1217
- type: 'provider-defined';
1343
+ type: 'provider';
1218
1344
  /**
1219
1345
  * The ID of the tool. Should follow the format `<provider-id>.<unique-tool-name>`.
1220
1346
  */
1221
1347
  id: `${string}.${string}`;
1222
1348
  /**
1223
- * 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.
1224
1350
  */
1225
1351
  name: string;
1226
1352
  /**
@@ -1315,7 +1441,7 @@ type LanguageModelV3CallOptions = {
1315
1441
  /**
1316
1442
  The tools that are available for the model.
1317
1443
  */
1318
- tools?: Array<LanguageModelV3FunctionTool | LanguageModelV3ProviderDefinedTool>;
1444
+ tools?: Array<LanguageModelV3FunctionTool | LanguageModelV3ProviderTool>;
1319
1445
  /**
1320
1446
  Specifies how the tool should be selected. Defaults to 'auto'.
1321
1447
  */
@@ -1341,23 +1467,6 @@ type LanguageModelV3CallOptions = {
1341
1467
  providerOptions?: SharedV3ProviderOptions;
1342
1468
  };
1343
1469
 
1344
- /**
1345
- Warning from the model provider for this call. The call will proceed, but e.g.
1346
- some settings might not be supported, which can lead to suboptimal results.
1347
- */
1348
- type LanguageModelV3CallWarning = {
1349
- type: 'unsupported-setting';
1350
- setting: Omit<keyof LanguageModelV3CallOptions, 'prompt'>;
1351
- details?: string;
1352
- } | {
1353
- type: 'unsupported-tool';
1354
- tool: LanguageModelV3FunctionTool | LanguageModelV3ProviderDefinedTool;
1355
- details?: string;
1356
- } | {
1357
- type: 'other';
1358
- message: string;
1359
- };
1360
-
1361
1470
  /**
1362
1471
  A file that has been generated by the model.
1363
1472
  Generated files as base64 encoded strings or binary data.
@@ -1380,6 +1489,10 @@ type LanguageModelV3File = {
1380
1489
  be returned as binary data.
1381
1490
  */
1382
1491
  data: string | Uint8Array;
1492
+ /**
1493
+ * Optional provider-specific metadata for the file part.
1494
+ */
1495
+ providerMetadata?: SharedV3ProviderMetadata;
1383
1496
  };
1384
1497
 
1385
1498
  /**
@@ -1459,6 +1572,29 @@ type LanguageModelV3Text = {
1459
1572
  providerMetadata?: SharedV3ProviderMetadata;
1460
1573
  };
1461
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
+
1462
1598
  /**
1463
1599
  * Tool calls that the model has generated.
1464
1600
  */
@@ -1509,18 +1645,11 @@ type LanguageModelV3ToolResult = {
1509
1645
  /**
1510
1646
  * Result of the tool call. This is a JSON-serializable object.
1511
1647
  */
1512
- result: unknown;
1648
+ result: NonNullable<JSONValue>;
1513
1649
  /**
1514
1650
  * Optional flag if the result is an error or an error message.
1515
1651
  */
1516
1652
  isError?: boolean;
1517
- /**
1518
- * Whether the tool result was generated by the provider.
1519
- *
1520
- * If this flag is set to true, the tool result was generated by the provider.
1521
- * If this flag is not set or is false, the tool result was generated by the client.
1522
- */
1523
- providerExecuted?: boolean;
1524
1653
  /**
1525
1654
  * Whether the tool result is preliminary.
1526
1655
  *
@@ -1542,21 +1671,34 @@ type LanguageModelV3ToolResult = {
1542
1671
  providerMetadata?: SharedV3ProviderMetadata;
1543
1672
  };
1544
1673
 
1545
- type LanguageModelV3Content = LanguageModelV3Text | LanguageModelV3Reasoning | LanguageModelV3File | LanguageModelV3Source | LanguageModelV3ToolCall | LanguageModelV3ToolResult;
1674
+ type LanguageModelV3Content = LanguageModelV3Text | LanguageModelV3Reasoning | LanguageModelV3File | LanguageModelV3ToolApprovalRequest | LanguageModelV3Source | LanguageModelV3ToolCall | LanguageModelV3ToolResult;
1546
1675
 
1547
1676
  /**
1548
- Reason why a language model finished generating a response.
1549
-
1550
- Can be one of the following:
1551
- - `stop`: model generated stop sequence
1552
- - `length`: model generated maximum number of tokens
1553
- - `content-filter`: content filter violation stopped the model
1554
- - `tool-calls`: model triggered tool calls
1555
- - `error`: model stopped because of an error
1556
- - `other`: model stopped for other reasons
1557
- - `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.
1558
1682
  */
1559
- 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
+ };
1560
1702
 
1561
1703
  interface LanguageModelV3ResponseMetadata {
1562
1704
  /**
@@ -1574,34 +1716,104 @@ interface LanguageModelV3ResponseMetadata {
1574
1716
  }
1575
1717
 
1576
1718
  /**
1577
- Usage information for a language model call.
1578
-
1579
- If your API return additional usage information, you can add it to the
1580
- provider metadata under your provider's key.
1719
+ * Usage information for a language model call.
1581
1720
  */
1582
1721
  type LanguageModelV3Usage = {
1583
1722
  /**
1584
- The number of input (prompt) tokens used.
1723
+ * Information about the input tokens.
1585
1724
  */
1586
- 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
+ };
1587
1743
  /**
1588
- The number of output (completion) tokens used.
1744
+ * Information about the output tokens.
1589
1745
  */
1590
- 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
+ };
1591
1760
  /**
1592
- The total number of tokens as reported by the provider.
1593
- This number might be different from the sum of `inputTokens` and `outputTokens`
1594
- 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.
1595
1765
  */
1596
- totalTokens: number | undefined;
1766
+ raw?: JSONObject;
1767
+ };
1768
+
1769
+ /**
1770
+ * The result of a language model doGenerate call.
1771
+ */
1772
+ type LanguageModelV3GenerateResult = {
1597
1773
  /**
1598
- The number of reasoning tokens used.
1774
+ * Ordered content that the model has generated.
1599
1775
  */
1600
- 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
+ };
1601
1813
  /**
1602
- The number of cached input tokens.
1814
+ * Warnings for the call, e.g. unsupported settings.
1603
1815
  */
1604
- cachedInputTokens?: number | undefined;
1816
+ warnings: Array<SharedV3Warning>;
1605
1817
  };
1606
1818
 
1607
1819
  type LanguageModelV3StreamPart = {
@@ -1647,9 +1859,9 @@ type LanguageModelV3StreamPart = {
1647
1859
  type: 'tool-input-end';
1648
1860
  id: string;
1649
1861
  providerMetadata?: SharedV3ProviderMetadata;
1650
- } | LanguageModelV3ToolCall | LanguageModelV3ToolResult | LanguageModelV3File | LanguageModelV3Source | {
1862
+ } | LanguageModelV3ToolApprovalRequest | LanguageModelV3ToolCall | LanguageModelV3ToolResult | LanguageModelV3File | LanguageModelV3Source | {
1651
1863
  type: 'stream-start';
1652
- warnings: Array<LanguageModelV3CallWarning>;
1864
+ warnings: Array<SharedV3Warning>;
1653
1865
  } | ({
1654
1866
  type: 'response-metadata';
1655
1867
  } & LanguageModelV3ResponseMetadata) | {
@@ -1666,115 +1878,78 @@ type LanguageModelV3StreamPart = {
1666
1878
  };
1667
1879
 
1668
1880
  /**
1669
- 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.
1670
1910
  */
1671
1911
  type LanguageModelV3 = {
1672
1912
  /**
1673
- 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.
1674
1914
  */
1675
1915
  readonly specificationVersion: 'v3';
1676
1916
  /**
1677
- Provider ID.
1917
+ * Provider ID.
1678
1918
  */
1679
1919
  readonly provider: string;
1680
1920
  /**
1681
- Provider-specific model ID.
1921
+ * Provider-specific model ID.
1682
1922
  */
1683
1923
  readonly modelId: string;
1684
1924
  /**
1685
- Supported URL patterns by media type for the provider.
1686
-
1687
- The keys are media type patterns or full media types (e.g. `*\/*` for everything, `audio/*`, `video/*`, or `application/pdf`).
1688
- and the values are arrays of regular expressions that match the URL paths.
1689
-
1690
- The matching should be against lower-case URLs.
1691
-
1692
- Matched URLs are supported natively by the model and are not downloaded.
1693
-
1694
- @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).
1695
1935
  */
1696
1936
  supportedUrls: PromiseLike<Record<string, RegExp[]>> | Record<string, RegExp[]>;
1697
1937
  /**
1698
- Generates a language model output (non-streaming).
1938
+ * Generates a language model output (non-streaming).
1699
1939
 
1700
- Naming: "do" prefix to prevent accidental direct usage of the method
1701
- by the user.
1940
+ * Naming: "do" prefix to prevent accidental direct usage of the method
1941
+ * by the user.
1702
1942
  */
1703
- doGenerate(options: LanguageModelV3CallOptions): PromiseLike<{
1704
- /**
1705
- Ordered content that the model has generated.
1706
- */
1707
- content: Array<LanguageModelV3Content>;
1708
- /**
1709
- Finish reason.
1710
- */
1711
- finishReason: LanguageModelV3FinishReason;
1712
- /**
1713
- Usage information.
1714
- */
1715
- usage: LanguageModelV3Usage;
1716
- /**
1717
- Additional provider-specific metadata. They are passed through
1718
- from the provider to the AI SDK and enable provider-specific
1719
- results that can be fully encapsulated in the provider.
1720
- */
1721
- providerMetadata?: SharedV3ProviderMetadata;
1722
- /**
1723
- Optional request information for telemetry and debugging purposes.
1724
- */
1725
- request?: {
1726
- /**
1727
- Request HTTP body that was sent to the provider API.
1728
- */
1729
- body?: unknown;
1730
- };
1731
- /**
1732
- Optional response information for telemetry and debugging purposes.
1733
- */
1734
- response?: LanguageModelV3ResponseMetadata & {
1735
- /**
1736
- Response headers.
1737
- */
1738
- headers?: SharedV3Headers;
1739
- /**
1740
- Response HTTP body.
1741
- */
1742
- body?: unknown;
1743
- };
1744
- /**
1745
- Warnings for the call, e.g. unsupported settings.
1746
- */
1747
- warnings: Array<LanguageModelV3CallWarning>;
1748
- }>;
1943
+ doGenerate(options: LanguageModelV3CallOptions): PromiseLike<LanguageModelV3GenerateResult>;
1749
1944
  /**
1750
- Generates a language model output (streaming).
1751
-
1752
- Naming: "do" prefix to prevent accidental direct usage of the method
1753
- by the user.
1945
+ * Generates a language model output (streaming).
1754
1946
  *
1755
- @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.
1756
1951
  */
1757
- doStream(options: LanguageModelV3CallOptions): PromiseLike<{
1758
- stream: ReadableStream<LanguageModelV3StreamPart>;
1759
- /**
1760
- Optional request information for telemetry and debugging purposes.
1761
- */
1762
- request?: {
1763
- /**
1764
- Request HTTP body that was sent to the provider API.
1765
- */
1766
- body?: unknown;
1767
- };
1768
- /**
1769
- Optional response data.
1770
- */
1771
- response?: {
1772
- /**
1773
- Response headers.
1774
- */
1775
- headers?: SharedV3Headers;
1776
- };
1777
- }>;
1952
+ doStream(options: LanguageModelV3CallOptions): PromiseLike<LanguageModelV3StreamResult>;
1778
1953
  };
1779
1954
 
1780
1955
  /**
@@ -1786,7 +1961,7 @@ type LanguageModelV3Middleware = {
1786
1961
  /**
1787
1962
  * Middleware specification version. Use `v3` for the current version.
1788
1963
  */
1789
- middlewareVersion?: 'v3' | undefined;
1964
+ readonly specificationVersion: 'v3';
1790
1965
  /**
1791
1966
  * Override the provider name if desired.
1792
1967
  * @param options.model - The language model instance.
@@ -1831,11 +2006,11 @@ type LanguageModelV3Middleware = {
1831
2006
  * @returns A promise that resolves to the result of the generate operation.
1832
2007
  */
1833
2008
  wrapGenerate?: (options: {
1834
- doGenerate: () => ReturnType<LanguageModelV3['doGenerate']>;
1835
- doStream: () => ReturnType<LanguageModelV3['doStream']>;
2009
+ doGenerate: () => PromiseLike<LanguageModelV3GenerateResult>;
2010
+ doStream: () => PromiseLike<LanguageModelV3StreamResult>;
1836
2011
  params: LanguageModelV3CallOptions;
1837
2012
  model: LanguageModelV3;
1838
- }) => Promise<Awaited<ReturnType<LanguageModelV3['doGenerate']>>>;
2013
+ }) => PromiseLike<LanguageModelV3GenerateResult>;
1839
2014
  /**
1840
2015
  * Wraps the stream operation of the language model.
1841
2016
  *
@@ -1848,11 +2023,11 @@ type LanguageModelV3Middleware = {
1848
2023
  * @returns A promise that resolves to the result of the stream operation.
1849
2024
  */
1850
2025
  wrapStream?: (options: {
1851
- doGenerate: () => ReturnType<LanguageModelV3['doGenerate']>;
1852
- doStream: () => ReturnType<LanguageModelV3['doStream']>;
2026
+ doGenerate: () => PromiseLike<LanguageModelV3GenerateResult>;
2027
+ doStream: () => PromiseLike<LanguageModelV3StreamResult>;
1853
2028
  params: LanguageModelV3CallOptions;
1854
2029
  model: LanguageModelV3;
1855
- }) => PromiseLike<Awaited<ReturnType<LanguageModelV3['doStream']>>>;
2030
+ }) => PromiseLike<LanguageModelV3StreamResult>;
1856
2031
  };
1857
2032
 
1858
2033
  /**
@@ -2071,11 +2246,11 @@ IANA media type.
2071
2246
  /**
2072
2247
  The configuration of a tool that is defined by the provider.
2073
2248
  */
2074
- type LanguageModelV2ProviderDefinedTool = {
2249
+ type LanguageModelV2ProviderTool = {
2075
2250
  /**
2076
- The type of the tool (always 'provider-defined').
2251
+ The type of the tool (always 'provider').
2077
2252
  */
2078
- type: 'provider-defined';
2253
+ type: 'provider';
2079
2254
  /**
2080
2255
  The ID of the tool. Should follow the format `<provider-name>.<unique-tool-name>`.
2081
2256
  */
@@ -2176,7 +2351,7 @@ type LanguageModelV2CallOptions = {
2176
2351
  /**
2177
2352
  The tools that are available for the model.
2178
2353
  */
2179
- tools?: Array<LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool>;
2354
+ tools?: Array<LanguageModelV2FunctionTool | LanguageModelV2ProviderTool>;
2180
2355
  /**
2181
2356
  Specifies how the tool should be selected. Defaults to 'auto'.
2182
2357
  */
@@ -2212,7 +2387,7 @@ type LanguageModelV2CallWarning = {
2212
2387
  details?: string;
2213
2388
  } | {
2214
2389
  type: 'unsupported-tool';
2215
- tool: LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool;
2390
+ tool: LanguageModelV2FunctionTool | LanguageModelV2ProviderTool;
2216
2391
  details?: string;
2217
2392
  } | {
2218
2393
  type: 'other';
@@ -2693,7 +2868,181 @@ type LanguageModelV2Middleware = {
2693
2868
  }) => PromiseLike<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
2694
2869
  };
2695
2870
 
2696
- 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>;
2697
3046
  type SpeechModelV3CallOptions = {
2698
3047
  /**
2699
3048
  * Text to convert to speech.
@@ -2745,19 +3094,6 @@ type SpeechModelV3CallOptions = {
2745
3094
  headers?: Record<string, string | undefined>;
2746
3095
  };
2747
3096
 
2748
- /**
2749
- * Warning from the model provider for this call. The call will proceed, but e.g.
2750
- * some settings might not be supported, which can lead to suboptimal results.
2751
- */
2752
- type SpeechModelV3CallWarning = {
2753
- type: 'unsupported-setting';
2754
- setting: keyof SpeechModelV3CallOptions;
2755
- details?: string;
2756
- } | {
2757
- type: 'other';
2758
- message: string;
2759
- };
2760
-
2761
3097
  /**
2762
3098
  * Speech model specification version 3.
2763
3099
  */
@@ -2793,7 +3129,7 @@ type SpeechModelV3 = {
2793
3129
  /**
2794
3130
  * Warnings for the call, e.g. unsupported settings.
2795
3131
  */
2796
- warnings: Array<SpeechModelV3CallWarning>;
3132
+ warnings: Array<SharedV3Warning>;
2797
3133
  /**
2798
3134
  * Optional request information for telemetry and debugging purposes.
2799
3135
  */
@@ -2829,11 +3165,11 @@ type SpeechModelV3 = {
2829
3165
  * from the provider to the AI SDK and enable provider-specific
2830
3166
  * results that can be fully encapsulated in the provider.
2831
3167
  */
2832
- providerMetadata?: Record<string, Record<string, JSONValue>>;
3168
+ providerMetadata?: Record<string, JSONObject>;
2833
3169
  }>;
2834
3170
  };
2835
3171
 
2836
- type TranscriptionModelV3ProviderOptions = Record<string, Record<string, JSONValue>>;
3172
+ type TranscriptionModelV3ProviderOptions = Record<string, JSONObject>;
2837
3173
  type TranscriptionModelV3CallOptions = {
2838
3174
  /**
2839
3175
  Audio data to transcribe.
@@ -2872,19 +3208,6 @@ type TranscriptionModelV3CallOptions = {
2872
3208
  headers?: Record<string, string | undefined>;
2873
3209
  };
2874
3210
 
2875
- /**
2876
- Warning from the model provider for this call. The call will proceed, but e.g.
2877
- some settings might not be supported, which can lead to suboptimal results.
2878
- */
2879
- type TranscriptionModelV3CallWarning = {
2880
- type: 'unsupported-setting';
2881
- setting: keyof TranscriptionModelV3CallOptions;
2882
- details?: string;
2883
- } | {
2884
- type: 'other';
2885
- message: string;
2886
- };
2887
-
2888
3211
  /**
2889
3212
  Transcription model specification version 3.
2890
3213
  */
@@ -2944,7 +3267,7 @@ type TranscriptionModelV3 = {
2944
3267
  /**
2945
3268
  Warnings for the call, e.g. unsupported settings.
2946
3269
  */
2947
- warnings: Array<TranscriptionModelV3CallWarning>;
3270
+ warnings: Array<SharedV3Warning>;
2948
3271
  /**
2949
3272
  Optional request information for telemetry and debugging purposes.
2950
3273
  */
@@ -2981,7 +3304,7 @@ type TranscriptionModelV3 = {
2981
3304
  from the provider to the AI SDK and enable provider-specific
2982
3305
  results that can be fully encapsulated in the provider.
2983
3306
  */
2984
- providerMetadata?: Record<string, Record<string, JSONValue>>;
3307
+ providerMetadata?: Record<string, JSONObject>;
2985
3308
  }>;
2986
3309
  };
2987
3310
 
@@ -2989,6 +3312,7 @@ type TranscriptionModelV3 = {
2989
3312
  * Provider for language, text embedding, and image generation models.
2990
3313
  */
2991
3314
  interface ProviderV3 {
3315
+ readonly specificationVersion: 'v3';
2992
3316
  /**
2993
3317
  Returns the language model with the given id.
2994
3318
  The model id is then passed to the provider function to get the model.
@@ -3010,7 +3334,20 @@ interface ProviderV3 {
3010
3334
 
3011
3335
  @throws {NoSuchModelError} If no such model exists.
3012
3336
  */
3013
- 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;
3014
3351
  /**
3015
3352
  Returns the image model with the given id.
3016
3353
  The model id is then passed to the provider function to get the model.
@@ -3038,6 +3375,17 @@ interface ProviderV3 {
3038
3375
  @returns {SpeechModel} The speech model associated with the id
3039
3376
  */
3040
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;
3041
3389
  }
3042
3390
 
3043
3391
  type SpeechModelV2ProviderOptions = Record<string, Record<string, JSONValue>>;
@@ -3387,4 +3735,4 @@ interface ProviderV2 {
3387
3735
  speechModel?(modelId: string): SpeechModelV2;
3388
3736
  }
3389
3737
 
3390
- 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 SharedV3Warning, 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 };