@ai-sdk/provider 2.0.0-canary.9 → 2.1.0-beta.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.ts CHANGED
@@ -3,6 +3,10 @@ export { JSONSchema7, JSONSchema7Definition } from 'json-schema';
3
3
 
4
4
  type SharedV2Headers = Record<string, string>;
5
5
 
6
+ /**
7
+ A JSON value can be a string, number, boolean, object, array, or null.
8
+ JSON values can be serialized and deserialized by the JSON.stringify and JSON.parse methods.
9
+ */
6
10
  type JSONValue = null | string | number | boolean | JSONObject | JSONArray;
7
11
  type JSONObject = {
8
12
  [key: string]: JSONValue;
@@ -88,12 +92,14 @@ type EmbeddingModelV2<VALUE> = {
88
92
  readonly modelId: string;
89
93
  /**
90
94
  Limit of how many embeddings can be generated in a single API call.
95
+
96
+ Use Infinity for models that do not have a limit.
91
97
  */
92
- readonly maxEmbeddingsPerCall: number | undefined;
98
+ readonly maxEmbeddingsPerCall: PromiseLike<number | undefined> | number | undefined;
93
99
  /**
94
100
  True if the model can handle multiple embedding calls in parallel.
95
101
  */
96
- readonly supportsParallelCalls: boolean;
102
+ readonly supportsParallelCalls: PromiseLike<boolean> | boolean;
97
103
  /**
98
104
  Generates a list of embeddings for the given input text.
99
105
 
@@ -132,6 +138,12 @@ type EmbeddingModelV2<VALUE> = {
132
138
  tokens: number;
133
139
  };
134
140
  /**
141
+ Additional provider-specific metadata. They are passed through
142
+ from the provider to the AI SDK and enable provider-specific
143
+ results that can be fully encapsulated in the provider.
144
+ */
145
+ providerMetadata?: SharedV2ProviderMetadata;
146
+ /**
135
147
  Optional response information for debugging purposes.
136
148
  */
137
149
  response?: {
@@ -307,11 +319,11 @@ declare const symbol$3: unique symbol;
307
319
  declare class NoSuchModelError extends AISDKError {
308
320
  private readonly [symbol$3];
309
321
  readonly modelId: string;
310
- readonly modelType: 'languageModel' | 'textEmbeddingModel' | 'imageModel';
322
+ readonly modelType: 'languageModel' | 'textEmbeddingModel' | 'imageModel' | 'transcriptionModel' | 'speechModel';
311
323
  constructor({ errorName, modelId, modelType, message, }: {
312
324
  errorName?: string;
313
325
  modelId: string;
314
- modelType: 'languageModel' | 'textEmbeddingModel' | 'imageModel';
326
+ modelType: 'languageModel' | 'textEmbeddingModel' | 'imageModel' | 'transcriptionModel' | 'speechModel';
315
327
  message?: string;
316
328
  });
317
329
  static isInstance(error: unknown): error is NoSuchModelError;
@@ -369,7 +381,11 @@ declare class UnsupportedFunctionalityError extends AISDKError {
369
381
  static isInstance(error: unknown): error is UnsupportedFunctionalityError;
370
382
  }
371
383
 
372
- type ImageModelV1CallOptions = {
384
+ declare function isJSONValue(value: unknown): value is JSONValue;
385
+ declare function isJSONArray(value: unknown): value is JSONArray;
386
+ declare function isJSONObject(value: unknown): value is JSONObject;
387
+
388
+ type ImageModelV2CallOptions = {
373
389
  /**
374
390
  Prompt for the image generation.
375
391
  */
@@ -403,13 +419,13 @@ type ImageModelV1CallOptions = {
403
419
  record is keyed by the provider-specific metadata key.
404
420
  ```ts
405
421
  {
406
- "openai": {
407
- "style": "vivid"
408
- }
422
+ "openai": {
423
+ "style": "vivid"
424
+ }
409
425
  }
410
426
  ```
411
427
  */
412
- providerOptions: Record<string, Record<string, JSONValue>>;
428
+ providerOptions: SharedV2ProviderOptions;
413
429
  /**
414
430
  Abort signal for cancelling the operation.
415
431
  */
@@ -425,19 +441,25 @@ type ImageModelV1CallOptions = {
425
441
  Warning from the model provider for this call. The call will proceed, but e.g.
426
442
  some settings might not be supported, which can lead to suboptimal results.
427
443
  */
428
- type ImageModelV1CallWarning = {
444
+ type ImageModelV2CallWarning = {
429
445
  type: 'unsupported-setting';
430
- setting: keyof ImageModelV1CallOptions;
446
+ setting: keyof ImageModelV2CallOptions;
431
447
  details?: string;
432
448
  } | {
433
449
  type: 'other';
434
450
  message: string;
435
451
  };
436
452
 
453
+ type ImageModelV2ProviderMetadata = Record<string, {
454
+ images: JSONArray;
455
+ } & JSONValue>;
456
+ type GetMaxImagesPerCallFunction = (options: {
457
+ modelId: string;
458
+ }) => PromiseLike<number | undefined> | number | undefined;
437
459
  /**
438
- Image generation model specification version 1.
460
+ Image generation model specification version 2.
439
461
  */
440
- type ImageModelV1 = {
462
+ type ImageModelV2 = {
441
463
  /**
442
464
  The image model must specify which image model interface
443
465
  version it implements. This will allow us to evolve the image
@@ -445,7 +467,7 @@ type ImageModelV1 = {
445
467
  implementation versions can be handled as a discriminated union
446
468
  on our side.
447
469
  */
448
- readonly specificationVersion: 'v1';
470
+ readonly specificationVersion: 'v2';
449
471
  /**
450
472
  Name of the provider for logging purposes.
451
473
  */
@@ -456,13 +478,15 @@ type ImageModelV1 = {
456
478
  readonly modelId: string;
457
479
  /**
458
480
  Limit of how many images can be generated in a single API call.
459
- If undefined, we will max generate one image per call.
481
+ Can be set to a number for a fixed limit, to undefined to use
482
+ the global limit, or a function that returns a number or undefined,
483
+ optionally as a promise.
460
484
  */
461
- readonly maxImagesPerCall: number | undefined;
485
+ readonly maxImagesPerCall: number | undefined | GetMaxImagesPerCallFunction;
462
486
  /**
463
487
  Generates an array of images.
464
488
  */
465
- doGenerate(options: ImageModelV1CallOptions): PromiseLike<{
489
+ doGenerate(options: ImageModelV2CallOptions): PromiseLike<{
466
490
  /**
467
491
  Generated images as base64 encoded strings or binary data.
468
492
  The images should be returned without any unnecessary conversion.
@@ -474,7 +498,25 @@ type ImageModelV1 = {
474
498
  /**
475
499
  Warnings for the call, e.g. unsupported settings.
476
500
  */
477
- warnings: Array<ImageModelV1CallWarning>;
501
+ warnings: Array<ImageModelV2CallWarning>;
502
+ /**
503
+ Additional provider-specific metadata. They are passed through
504
+ from the provider to the AI SDK and enable provider-specific
505
+ results that can be fully encapsulated in the provider.
506
+
507
+ The outer record is keyed by the provider name, and the inner
508
+ record is provider-specific metadata. It always includes an
509
+ `images` key with image-specific metadata
510
+
511
+ ```ts
512
+ {
513
+ "openai": {
514
+ "images": ["revisedPrompt": "Revised prompt here."]
515
+ }
516
+ }
517
+ ```
518
+ */
519
+ providerMetadata?: ImageModelV2ProviderMetadata;
478
520
  /**
479
521
  Response information for telemetry and debugging purposes.
480
522
  */
@@ -495,10 +537,6 @@ type ImageModelV1 = {
495
537
  }>;
496
538
  };
497
539
 
498
- declare function isJSONValue(value: unknown): value is JSONValue;
499
- declare function isJSONArray(value: unknown): value is JSONArray;
500
- declare function isJSONObject(value: unknown): value is JSONObject;
501
-
502
540
  /**
503
541
  A tool has a name, a description, and a set of parameters.
504
542
 
@@ -523,7 +561,11 @@ type LanguageModelV2FunctionTool = {
523
561
  The parameters that the tool expects. The language model uses this to
524
562
  understand the tool's input requirements and to provide matching suggestions.
525
563
  */
526
- parameters: JSONSchema7;
564
+ inputSchema: JSONSchema7;
565
+ /**
566
+ The provider-specific options for the tool.
567
+ */
568
+ providerOptions?: SharedV2ProviderOptions;
527
569
  };
528
570
 
529
571
  /**
@@ -549,7 +591,7 @@ type LanguageModelV2Message = ({
549
591
  content: Array<LanguageModelV2TextPart | LanguageModelV2FilePart>;
550
592
  } | {
551
593
  role: 'assistant';
552
- content: Array<LanguageModelV2TextPart | LanguageModelV2FilePart | LanguageModelV2ReasoningPart | LanguageModelV2RedactedReasoningPart | LanguageModelV2ToolCallPart>;
594
+ content: Array<LanguageModelV2TextPart | LanguageModelV2FilePart | LanguageModelV2ReasoningPart | LanguageModelV2ToolCallPart | LanguageModelV2ToolResultPart>;
553
595
  } | {
554
596
  role: 'tool';
555
597
  content: Array<LanguageModelV2ToolResultPart>;
@@ -587,26 +629,6 @@ interface LanguageModelV2ReasoningPart {
587
629
  */
588
630
  text: string;
589
631
  /**
590
- An optional signature for verifying that the reasoning originated from the model.
591
- */
592
- signature?: string;
593
- /**
594
- * Additional provider-specific options. They are passed through
595
- * to the provider from the AI SDK and enable provider-specific
596
- * functionality that can be fully encapsulated in the provider.
597
- */
598
- providerOptions?: SharedV2ProviderOptions;
599
- }
600
- /**
601
- Redacted reasoning content part of a prompt.
602
- */
603
- interface LanguageModelV2RedactedReasoningPart {
604
- type: 'redacted-reasoning';
605
- /**
606
- Redacted reasoning data.
607
- */
608
- data: string;
609
- /**
610
632
  * Additional provider-specific options. They are passed through
611
633
  * to the provider from the AI SDK and enable provider-specific
612
634
  * functionality that can be fully encapsulated in the provider.
@@ -657,7 +679,12 @@ interface LanguageModelV2ToolCallPart {
657
679
  /**
658
680
  Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
659
681
  */
660
- args: unknown;
682
+ input: unknown;
683
+ /**
684
+ * Whether the tool call will be executed by the provider.
685
+ * If this flag is not set or is false, the tool call will be executed by the client.
686
+ */
687
+ providerExecuted?: boolean;
661
688
  /**
662
689
  * Additional provider-specific options. They are passed through
663
690
  * to the provider from the AI SDK and enable provider-specific
@@ -679,43 +706,49 @@ interface LanguageModelV2ToolResultPart {
679
706
  */
680
707
  toolName: string;
681
708
  /**
682
- Result of the tool call. This is a JSON-serializable object.
709
+ Result of the tool call.
683
710
  */
684
- result: unknown;
685
- /**
686
- Optional flag if the result is an error or an error message.
687
- */
688
- isError?: boolean;
711
+ output: LanguageModelV2ToolResultOutput;
689
712
  /**
690
- Tool results as an array of parts. This enables advanced tool results including images.
691
- When this is used, the `result` field should be ignored (if the provider supports content).
713
+ * Additional provider-specific options. They are passed through
714
+ * to the provider from the AI SDK and enable provider-specific
715
+ * functionality that can be fully encapsulated in the provider.
692
716
  */
693
- content?: Array<{
717
+ providerOptions?: SharedV2ProviderOptions;
718
+ }
719
+ type LanguageModelV2ToolResultOutput = {
720
+ type: 'text';
721
+ value: string;
722
+ } | {
723
+ type: 'json';
724
+ value: JSONValue;
725
+ } | {
726
+ type: 'error-text';
727
+ value: string;
728
+ } | {
729
+ type: 'error-json';
730
+ value: JSONValue;
731
+ } | {
732
+ type: 'content';
733
+ value: Array<{
694
734
  type: 'text';
695
735
  /**
696
736
  Text content.
697
- */
737
+ */
698
738
  text: string;
699
739
  } | {
700
- type: 'image';
740
+ type: 'media';
701
741
  /**
702
- base-64 encoded image data
703
- */
742
+ Base-64 encoded media data.
743
+ */
704
744
  data: string;
705
745
  /**
706
- IANA media type of the image.
707
-
746
+ IANA media type.
708
747
  @see https://www.iana.org/assignments/media-types/media-types.xhtml
709
- */
710
- mediaType?: string;
748
+ */
749
+ mediaType: string;
711
750
  }>;
712
- /**
713
- * Additional provider-specific options. They are passed through
714
- * to the provider from the AI SDK and enable provider-specific
715
- * functionality that can be fully encapsulated in the provider.
716
- */
717
- providerOptions?: SharedV2ProviderOptions;
718
- }
751
+ };
719
752
 
720
753
  /**
721
754
  The configuration of a tool that is defined by the provider.
@@ -726,11 +759,11 @@ type LanguageModelV2ProviderDefinedTool = {
726
759
  */
727
760
  type: 'provider-defined';
728
761
  /**
729
- The ID of the tool. Should follow the format `<provider-name>.<tool-name>`.
762
+ The ID of the tool. Should follow the format `<provider-name>.<unique-tool-name>`.
730
763
  */
731
764
  id: `${string}.${string}`;
732
765
  /**
733
- The name of the tool. Unique within this model call.
766
+ The name of the tool that the user must use in the tool set.
734
767
  */
735
768
  name: string;
736
769
  /**
@@ -752,13 +785,6 @@ type LanguageModelV2ToolChoice = {
752
785
 
753
786
  type LanguageModelV2CallOptions = {
754
787
  /**
755
- Whether the user provided the input as messages or as
756
- a prompt. This can help guide non-chat models in the
757
- expansion, bc different expansions can be needed for
758
- chat/non-chat use cases.
759
- */
760
- inputFormat: 'messages' | 'prompt';
761
- /**
762
788
  A language mode prompt is a standardized prompt type.
763
789
 
764
790
  Note: This is **not** the user-facing prompt. The AI SDK methods will map the
@@ -772,9 +798,7 @@ type LanguageModelV2CallOptions = {
772
798
  */
773
799
  maxOutputTokens?: number;
774
800
  /**
775
- Temperature setting.
776
-
777
- It is recommended to set either `temperature` or `topP`, but not both.
801
+ Temperature setting. The range depends on the provider and model.
778
802
  */
779
803
  temperature?: number;
780
804
  /**
@@ -785,8 +809,6 @@ type LanguageModelV2CallOptions = {
785
809
  stopSequences?: string[];
786
810
  /**
787
811
  Nucleus sampling.
788
-
789
- It is recommended to set either `temperature` or `topP`, but not both.
790
812
  */
791
813
  topP?: number;
792
814
  /**
@@ -842,6 +864,10 @@ type LanguageModelV2CallOptions = {
842
864
  */
843
865
  toolChoice?: LanguageModelV2ToolChoice;
844
866
  /**
867
+ Include raw chunks in the stream. Only applicable for streaming calls.
868
+ */
869
+ includeRawChunks?: boolean;
870
+ /**
845
871
  Abort signal for cancelling the operation.
846
872
  */
847
873
  abortSignal?: AbortSignal;
@@ -904,16 +930,11 @@ Reasoning that the model has generated.
904
930
  */
905
931
  type LanguageModelV2Reasoning = {
906
932
  type: 'reasoning';
907
- reasoningType: 'text';
908
933
  text: string;
909
- } | {
910
- type: 'reasoning';
911
- reasoningType: 'signature';
912
- signature: string;
913
- } | {
914
- type: 'reasoning';
915
- reasoningType: 'redacted';
916
- data: string;
934
+ /**
935
+ * Optional provider-specific metadata for the reasoning part.
936
+ */
937
+ providerMetadata?: SharedV2ProviderMetadata;
917
938
  };
918
939
 
919
940
  /**
@@ -922,7 +943,7 @@ A source that has been used as input to generate the response.
922
943
  type LanguageModelV2Source = {
923
944
  type: 'source';
924
945
  /**
925
- * A URL source. This is return by web search RAG models.
946
+ * The type of source - URL sources reference web content.
926
947
  */
927
948
  sourceType: 'url';
928
949
  /**
@@ -941,6 +962,32 @@ type LanguageModelV2Source = {
941
962
  * Additional provider metadata for the source.
942
963
  */
943
964
  providerMetadata?: SharedV2ProviderMetadata;
965
+ } | {
966
+ type: 'source';
967
+ /**
968
+ * The type of source - document sources reference files/documents.
969
+ */
970
+ sourceType: 'document';
971
+ /**
972
+ * The ID of the source.
973
+ */
974
+ id: string;
975
+ /**
976
+ * IANA media type of the document (e.g., 'application/pdf').
977
+ */
978
+ mediaType: string;
979
+ /**
980
+ * The title of the document.
981
+ */
982
+ title: string;
983
+ /**
984
+ * Optional filename of the document.
985
+ */
986
+ filename?: string;
987
+ /**
988
+ * Additional provider metadata for the source.
989
+ */
990
+ providerMetadata?: SharedV2ProviderMetadata;
944
991
  };
945
992
 
946
993
  /**
@@ -952,24 +999,72 @@ type LanguageModelV2Text = {
952
999
  The text content.
953
1000
  */
954
1001
  text: string;
1002
+ providerMetadata?: SharedV2ProviderMetadata;
955
1003
  };
956
1004
 
957
1005
  /**
958
- Tool calls that the model has generated.
959
- */
1006
+ * Tool calls that the model has generated.
1007
+ */
960
1008
  type LanguageModelV2ToolCall = {
961
1009
  type: 'tool-call';
962
- toolCallType: 'function';
1010
+ /**
1011
+ * The identifier of the tool call. It must be unique across all tool calls.
1012
+ */
1013
+ toolCallId: string;
1014
+ /**
1015
+ * The name of the tool that should be called.
1016
+ */
1017
+ toolName: string;
1018
+ /**
1019
+ * Stringified JSON object with the tool call arguments. Must match the
1020
+ * parameters schema of the tool.
1021
+ */
1022
+ input: string;
1023
+ /**
1024
+ * Whether the tool call will be executed by the provider.
1025
+ * If this flag is not set or is false, the tool call will be executed by the client.
1026
+ */
1027
+ providerExecuted?: boolean;
1028
+ /**
1029
+ * Additional provider-specific metadata for the tool call.
1030
+ */
1031
+ providerMetadata?: SharedV2ProviderMetadata;
1032
+ };
1033
+
1034
+ /**
1035
+ Result of a tool call that has been executed by the provider.
1036
+ */
1037
+ type LanguageModelV2ToolResult = {
1038
+ type: 'tool-result';
1039
+ /**
1040
+ * The ID of the tool call that this result is associated with.
1041
+ */
963
1042
  toolCallId: string;
1043
+ /**
1044
+ * Name of the tool that generated this result.
1045
+ */
964
1046
  toolName: string;
965
1047
  /**
966
- Stringified JSON object with the tool call arguments. Must match the
967
- parameters schema of the tool.
1048
+ * Result of the tool call. This is a JSON-serializable object.
1049
+ */
1050
+ result: unknown;
1051
+ /**
1052
+ * Optional flag if the result is an error or an error message.
1053
+ */
1054
+ isError?: boolean;
1055
+ /**
1056
+ * Whether the tool result was generated by the provider.
1057
+ * If this flag is set to true, the tool result was generated by the provider.
1058
+ * If this flag is not set or is false, the tool result was generated by the client.
1059
+ */
1060
+ providerExecuted?: boolean;
1061
+ /**
1062
+ * Additional provider-specific metadata for the tool result.
968
1063
  */
969
- args: string;
1064
+ providerMetadata?: SharedV2ProviderMetadata;
970
1065
  };
971
1066
 
972
- type LanguageModelV2Content = LanguageModelV2Text | LanguageModelV2Reasoning | LanguageModelV2File | LanguageModelV2Source | LanguageModelV2ToolCall;
1067
+ type LanguageModelV2Content = LanguageModelV2Text | LanguageModelV2Reasoning | LanguageModelV2File | LanguageModelV2Source | LanguageModelV2ToolCall | LanguageModelV2ToolResult;
973
1068
 
974
1069
  /**
975
1070
  Reason why a language model finished generating a response.
@@ -1000,38 +1095,91 @@ interface LanguageModelV2ResponseMetadata {
1000
1095
  modelId?: string;
1001
1096
  }
1002
1097
 
1003
- type LanguageModelV2ToolCallDelta = {
1004
- type: 'tool-call-delta';
1005
- toolCallType: 'function';
1006
- toolCallId: string;
1007
- toolName: string;
1008
- argsTextDelta: string;
1009
- };
1010
-
1011
1098
  /**
1012
- * Usage information for a language model call.
1099
+ Usage information for a language model call.
1100
+
1101
+ If your API return additional usage information, you can add it to the
1102
+ provider metadata under your provider's key.
1013
1103
  */
1014
1104
  type LanguageModelV2Usage = {
1015
1105
  /**
1016
- * The number of input (prompt) tokens used.
1106
+ The number of input (prompt) tokens used.
1017
1107
  */
1018
1108
  inputTokens: number | undefined;
1019
1109
  /**
1020
- * The number of output (completion) tokens used.
1110
+ The number of output (completion) tokens used.
1021
1111
  */
1022
1112
  outputTokens: number | undefined;
1113
+ /**
1114
+ The total number of tokens as reported by the provider.
1115
+ This number might be different from the sum of `inputTokens` and `outputTokens`
1116
+ and e.g. include reasoning tokens or other overhead.
1117
+ */
1118
+ totalTokens: number | undefined;
1119
+ /**
1120
+ The number of reasoning tokens used.
1121
+ */
1122
+ reasoningTokens?: number | undefined;
1123
+ /**
1124
+ The number of cached input tokens.
1125
+ */
1126
+ cachedInputTokens?: number | undefined;
1023
1127
  };
1024
1128
 
1025
- type LanguageModelV2StreamPart = LanguageModelV2Content | LanguageModelV2ToolCallDelta | {
1129
+ type LanguageModelV2StreamPart = {
1130
+ type: 'text-start';
1131
+ providerMetadata?: SharedV2ProviderMetadata;
1132
+ id: string;
1133
+ } | {
1134
+ type: 'text-delta';
1135
+ id: string;
1136
+ providerMetadata?: SharedV2ProviderMetadata;
1137
+ delta: string;
1138
+ } | {
1139
+ type: 'text-end';
1140
+ providerMetadata?: SharedV2ProviderMetadata;
1141
+ id: string;
1142
+ } | {
1143
+ type: 'reasoning-start';
1144
+ providerMetadata?: SharedV2ProviderMetadata;
1145
+ id: string;
1146
+ } | {
1147
+ type: 'reasoning-delta';
1148
+ id: string;
1149
+ providerMetadata?: SharedV2ProviderMetadata;
1150
+ delta: string;
1151
+ } | {
1152
+ type: 'reasoning-end';
1153
+ id: string;
1154
+ providerMetadata?: SharedV2ProviderMetadata;
1155
+ } | {
1156
+ type: 'tool-input-start';
1157
+ id: string;
1158
+ toolName: string;
1159
+ providerMetadata?: SharedV2ProviderMetadata;
1160
+ providerExecuted?: boolean;
1161
+ } | {
1162
+ type: 'tool-input-delta';
1163
+ id: string;
1164
+ delta: string;
1165
+ providerMetadata?: SharedV2ProviderMetadata;
1166
+ } | {
1167
+ type: 'tool-input-end';
1168
+ id: string;
1169
+ providerMetadata?: SharedV2ProviderMetadata;
1170
+ } | LanguageModelV2ToolCall | LanguageModelV2ToolResult | LanguageModelV2File | LanguageModelV2Source | {
1026
1171
  type: 'stream-start';
1027
1172
  warnings: Array<LanguageModelV2CallWarning>;
1028
1173
  } | ({
1029
1174
  type: 'response-metadata';
1030
1175
  } & LanguageModelV2ResponseMetadata) | {
1031
1176
  type: 'finish';
1177
+ usage: LanguageModelV2Usage;
1032
1178
  finishReason: LanguageModelV2FinishReason;
1033
1179
  providerMetadata?: SharedV2ProviderMetadata;
1034
- usage: LanguageModelV2Usage;
1180
+ } | {
1181
+ type: 'raw';
1182
+ rawValue: unknown;
1035
1183
  } | {
1036
1184
  type: 'error';
1037
1185
  error: unknown;
@@ -1042,11 +1190,7 @@ Specification for a language model that implements the language model interface
1042
1190
  */
1043
1191
  type LanguageModelV2 = {
1044
1192
  /**
1045
- The language model must specify which language model interface
1046
- version it implements. This will allow us to evolve the language
1047
- model interface and retain backwards compatibility. The different
1048
- implementation versions can be handled as a discriminated union
1049
- on our side.
1193
+ The language model must specify which language model interface version it implements.
1050
1194
  */
1051
1195
  readonly specificationVersion: 'v2';
1052
1196
  /**
@@ -1058,17 +1202,18 @@ type LanguageModelV2 = {
1058
1202
  */
1059
1203
  readonly modelId: string;
1060
1204
  /**
1061
- * Returns a map of supported URL patterns for the model.
1062
- * The keys are media type patterns or full media types (e.g. `*\/*` for everything, `audio/*`, `video/*`, or `application/pdf`).
1063
- * and the values are arrays of regular expressions that match the URL paths.
1064
- *
1065
- * The matching should be against lower-case URLs.
1066
- *
1067
- * Matched URLs are supported natively by the model and are not downloaded.
1068
- *
1069
- * @returns A promise resolving to a map of supported URL patterns.
1205
+ Supported URL patterns by media type for the provider.
1206
+
1207
+ The keys are media type patterns or full media types (e.g. `*\/*` for everything, `audio/*`, `video/*`, or `application/pdf`).
1208
+ and the values are arrays of regular expressions that match the URL paths.
1209
+
1210
+ The matching should be against lower-case URLs.
1211
+
1212
+ Matched URLs are supported natively by the model and are not downloaded.
1213
+
1214
+ @returns A map of supported URL patterns by media type (as a promise or a plain object).
1070
1215
  */
1071
- getSupportedUrls(): PromiseLike<Record<string, RegExp[]>>;
1216
+ supportedUrls: PromiseLike<Record<string, RegExp[]>> | Record<string, RegExp[]>;
1072
1217
  /**
1073
1218
  Generates a language model output (non-streaming).
1074
1219
 
@@ -1162,6 +1307,27 @@ type LanguageModelV2Middleware = {
1162
1307
  * Middleware specification version. Use `v2` for the current version.
1163
1308
  */
1164
1309
  middlewareVersion?: 'v2' | undefined;
1310
+ /**
1311
+ * Override the provider name if desired.
1312
+ * @param options.model - The language model instance.
1313
+ */
1314
+ overrideProvider?: (options: {
1315
+ model: LanguageModelV2;
1316
+ }) => string;
1317
+ /**
1318
+ * Override the model ID if desired.
1319
+ * @param options.model - The language model instance.
1320
+ */
1321
+ overrideModelId?: (options: {
1322
+ model: LanguageModelV2;
1323
+ }) => string;
1324
+ /**
1325
+ * Override the supported URLs if desired.
1326
+ * @param options.model - The language model instance.
1327
+ */
1328
+ overrideSupportedUrls?: (options: {
1329
+ model: LanguageModelV2;
1330
+ }) => PromiseLike<Record<string, RegExp[]>> | Record<string, RegExp[]>;
1165
1331
  /**
1166
1332
  * Transforms the parameters before they are passed to the language model.
1167
1333
  * @param options - Object containing the type of operation and the parameters.
@@ -1172,6 +1338,7 @@ type LanguageModelV2Middleware = {
1172
1338
  transformParams?: (options: {
1173
1339
  type: 'generate' | 'stream';
1174
1340
  params: LanguageModelV2CallOptions;
1341
+ model: LanguageModelV2;
1175
1342
  }) => PromiseLike<LanguageModelV2CallOptions>;
1176
1343
  /**
1177
1344
  * Wraps the generate operation of the language model.
@@ -1208,467 +1375,65 @@ type LanguageModelV2Middleware = {
1208
1375
  }) => PromiseLike<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
1209
1376
  };
1210
1377
 
1211
- /**
1212
- * Additional provider-specific metadata. They are passed through
1213
- * to the provider from the AI SDK and enable provider-specific
1214
- * functionality that can be fully encapsulated in the provider.
1215
- *
1216
- * This enables us to quickly ship provider-specific functionality
1217
- * without affecting the core AI SDK.
1218
- *
1219
- * The outer record is keyed by the provider name, and the inner
1220
- * record is keyed by the provider-specific metadata key.
1221
- *
1222
- * ```ts
1223
- * {
1224
- * "anthropic": {
1225
- * "cacheControl": { "type": "ephemeral" }
1226
- * }
1227
- * }
1228
- * ```
1229
- */
1230
- type LanguageModelV1ProviderMetadata = Record<string, Record<string, JSONValue>>;
1231
-
1232
- /**
1233
- * A source that has been used as input to generate the response.
1234
- */
1235
- type LanguageModelV1Source = {
1236
- /**
1237
- * A URL source. This is return by web search RAG models.
1238
- */
1239
- sourceType: 'url';
1378
+ type SpeechModelV2ProviderOptions = Record<string, Record<string, JSONValue>>;
1379
+ type SpeechModelV2CallOptions = {
1240
1380
  /**
1241
- * The ID of the source.
1381
+ * Text to convert to speech.
1242
1382
  */
1243
- id: string;
1383
+ text: string;
1244
1384
  /**
1245
- * The URL of the source.
1385
+ * The voice to use for speech synthesis.
1386
+ * This is provider-specific and may be a voice ID, name, or other identifier.
1246
1387
  */
1247
- url: string;
1388
+ voice?: string;
1248
1389
  /**
1249
- * The title of the source.
1390
+ * The desired output format for the audio e.g. "mp3", "wav", etc.
1250
1391
  */
1251
- title?: string;
1392
+ outputFormat?: string;
1252
1393
  /**
1253
- * Additional provider metadata for the source.
1394
+ * Instructions for the speech generation e.g. "Speak in a slow and steady tone".
1254
1395
  */
1255
- providerMetadata?: LanguageModelV1ProviderMetadata;
1256
- };
1257
-
1258
- type LanguageModelV1CallSettings = {
1396
+ instructions?: string;
1259
1397
  /**
1260
- Maximum number of tokens to generate.
1398
+ * The speed of the speech generation.
1261
1399
  */
1262
- maxTokens?: number;
1400
+ speed?: number;
1263
1401
  /**
1264
- Temperature setting.
1265
-
1266
- It is recommended to set either `temperature` or `topP`, but not both.
1402
+ * The language for speech generation. This should be an ISO 639-1 language code (e.g. "en", "es", "fr")
1403
+ * or "auto" for automatic language detection. Provider support varies.
1267
1404
  */
1268
- temperature?: number;
1405
+ language?: string;
1269
1406
  /**
1270
- Stop sequences.
1271
- If set, the model will stop generating text when one of the stop sequences is generated.
1272
- Providers may have limits on the number of stop sequences.
1273
- */
1274
- stopSequences?: string[];
1275
- /**
1276
- Nucleus sampling.
1277
-
1278
- It is recommended to set either `temperature` or `topP`, but not both.
1279
- */
1280
- topP?: number;
1281
- /**
1282
- Only sample from the top K options for each subsequent token.
1283
-
1284
- Used to remove "long tail" low probability responses.
1285
- Recommended for advanced use cases only. You usually only need to use temperature.
1286
- */
1287
- topK?: number;
1288
- /**
1289
- Presence penalty setting. It affects the likelihood of the model to
1290
- repeat information that is already in the prompt.
1291
- */
1292
- presencePenalty?: number;
1293
- /**
1294
- Frequency penalty setting. It affects the likelihood of the model
1295
- to repeatedly use the same words or phrases.
1296
- */
1297
- frequencyPenalty?: number;
1298
- /**
1299
- Response format. The output can either be text or JSON. Default is text.
1300
-
1301
- If JSON is selected, a schema can optionally be provided to guide the LLM.
1302
- */
1303
- responseFormat?: {
1304
- type: 'text';
1305
- } | {
1306
- type: 'json';
1307
- /**
1308
- * JSON schema that the generated output should conform to.
1309
- */
1310
- schema?: JSONSchema7;
1311
- /**
1312
- * Name of output that should be generated. Used by some providers for additional LLM guidance.
1313
- */
1314
- name?: string;
1315
- /**
1316
- * Description of the output that should be generated. Used by some providers for additional LLM guidance.
1317
- */
1318
- description?: string;
1319
- };
1320
- /**
1321
- The seed (integer) to use for random sampling. If set and supported
1322
- by the model, calls will generate deterministic results.
1407
+ * Additional provider-specific options that are passed through to the provider
1408
+ * as body parameters.
1409
+ *
1410
+ * The outer record is keyed by the provider name, and the inner
1411
+ * record is keyed by the provider-specific metadata key.
1412
+ * ```ts
1413
+ * {
1414
+ * "openai": {}
1415
+ * }
1416
+ * ```
1323
1417
  */
1324
- seed?: number;
1418
+ providerOptions?: SpeechModelV2ProviderOptions;
1325
1419
  /**
1326
- Abort signal for cancelling the operation.
1420
+ * Abort signal for cancelling the operation.
1327
1421
  */
1328
1422
  abortSignal?: AbortSignal;
1329
1423
  /**
1330
- Additional HTTP headers to be sent with the request.
1331
- Only applicable for HTTP-based providers.
1424
+ * Additional HTTP headers to be sent with the request.
1425
+ * Only applicable for HTTP-based providers.
1332
1426
  */
1333
1427
  headers?: Record<string, string | undefined>;
1334
1428
  };
1335
1429
 
1336
1430
  /**
1337
- A tool has a name, a description, and a set of parameters.
1338
-
1339
- Note: this is **not** the user-facing tool definition. The AI SDK methods will
1340
- map the user-facing tool definitions to this format.
1341
- */
1342
- type LanguageModelV1FunctionTool = {
1343
- /**
1344
- The type of the tool (always 'function').
1345
- */
1346
- type: 'function';
1347
- /**
1348
- The name of the tool. Unique within this model call.
1349
- */
1350
- name: string;
1351
- /**
1352
- A description of the tool. The language model uses this to understand the
1353
- tool's purpose and to provide better completion suggestions.
1354
- */
1355
- description?: string;
1356
- /**
1357
- The parameters that the tool expects. The language model uses this to
1358
- understand the tool's input requirements and to provide matching suggestions.
1359
- */
1360
- parameters: JSONSchema7;
1361
- };
1362
-
1363
- /**
1364
- A prompt is a list of messages.
1365
-
1366
- Note: Not all models and prompt formats support multi-modal inputs and
1367
- tool calls. The validation happens at runtime.
1368
-
1369
- Note: This is not a user-facing prompt. The AI SDK methods will map the
1370
- user-facing prompt types such as chat or instruction prompts to this format.
1371
- */
1372
- type LanguageModelV1Prompt = Array<LanguageModelV1Message>;
1373
- type LanguageModelV1Message = ({
1374
- role: 'system';
1375
- content: string;
1376
- } | {
1377
- role: 'user';
1378
- content: Array<LanguageModelV1TextPart | LanguageModelV1ImagePart | LanguageModelV1FilePart>;
1379
- } | {
1380
- role: 'assistant';
1381
- content: Array<LanguageModelV1TextPart | LanguageModelV1FilePart | LanguageModelV1ReasoningPart | LanguageModelV1RedactedReasoningPart | LanguageModelV1ToolCallPart>;
1382
- } | {
1383
- role: 'tool';
1384
- content: Array<LanguageModelV1ToolResultPart>;
1385
- }) & {
1386
- /**
1387
- * Additional provider-specific metadata. They are passed through
1388
- * to the provider from the AI SDK and enable provider-specific
1389
- * functionality that can be fully encapsulated in the provider.
1390
- */
1391
- providerMetadata?: LanguageModelV1ProviderMetadata;
1392
- };
1393
- /**
1394
- Text content part of a prompt. It contains a string of text.
1395
- */
1396
- interface LanguageModelV1TextPart {
1397
- type: 'text';
1398
- /**
1399
- The text content.
1400
- */
1401
- text: string;
1402
- /**
1403
- * Additional provider-specific metadata. They are passed through
1404
- * to the provider from the AI SDK and enable provider-specific
1405
- * functionality that can be fully encapsulated in the provider.
1406
- */
1407
- providerMetadata?: LanguageModelV1ProviderMetadata;
1408
- }
1409
- /**
1410
- Reasoning content part of a prompt. It contains a string of reasoning text.
1411
- */
1412
- interface LanguageModelV1ReasoningPart {
1413
- type: 'reasoning';
1414
- /**
1415
- The reasoning text.
1416
- */
1417
- text: string;
1418
- /**
1419
- An optional signature for verifying that the reasoning originated from the model.
1420
- */
1421
- signature?: string;
1422
- /**
1423
- Additional provider-specific metadata. They are passed through
1424
- to the provider from the AI SDK and enable provider-specific
1425
- functionality that can be fully encapsulated in the provider.
1426
- */
1427
- providerMetadata?: LanguageModelV1ProviderMetadata;
1428
- }
1429
- /**
1430
- Redacted reasoning content part of a prompt.
1431
- */
1432
- interface LanguageModelV1RedactedReasoningPart {
1433
- type: 'redacted-reasoning';
1434
- /**
1435
- Redacted reasoning data.
1436
- */
1437
- data: string;
1438
- /**
1439
- Additional provider-specific metadata. They are passed through
1440
- to the provider from the AI SDK and enable provider-specific
1441
- functionality that can be fully encapsulated in the provider.
1442
- */
1443
- providerMetadata?: LanguageModelV1ProviderMetadata;
1444
- }
1445
- /**
1446
- Image content part of a prompt. It contains an image.
1447
- */
1448
- interface LanguageModelV1ImagePart {
1449
- type: 'image';
1450
- /**
1451
- Image data as a Uint8Array (e.g. from a Blob or Buffer) or a URL.
1452
- */
1453
- image: Uint8Array | URL;
1454
- /**
1455
- Optional mime type of the image.
1456
- */
1457
- mimeType?: string;
1458
- /**
1459
- * Additional provider-specific metadata. They are passed through
1460
- * to the provider from the AI SDK and enable provider-specific
1461
- * functionality that can be fully encapsulated in the provider.
1462
- */
1463
- providerMetadata?: LanguageModelV1ProviderMetadata;
1464
- }
1465
- /**
1466
- File content part of a prompt. It contains a file.
1467
- */
1468
- interface LanguageModelV1FilePart {
1469
- type: 'file';
1470
- /**
1471
- * Optional filename of the file.
1472
- */
1473
- filename?: string;
1474
- /**
1475
- File data as base64 encoded string or as a URL.
1476
- */
1477
- data: string | URL;
1478
- /**
1479
- Mime type of the file.
1480
- */
1481
- mimeType: string;
1482
- /**
1483
- * Additional provider-specific metadata. They are passed through
1484
- * to the provider from the AI SDK and enable provider-specific
1485
- * functionality that can be fully encapsulated in the provider.
1486
- */
1487
- providerMetadata?: LanguageModelV1ProviderMetadata;
1488
- }
1489
- /**
1490
- Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
1491
- */
1492
- interface LanguageModelV1ToolCallPart {
1493
- type: 'tool-call';
1494
- /**
1495
- ID of the tool call. This ID is used to match the tool call with the tool result.
1496
- */
1497
- toolCallId: string;
1498
- /**
1499
- Name of the tool that is being called.
1500
- */
1501
- toolName: string;
1502
- /**
1503
- Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
1504
- */
1505
- args: unknown;
1506
- /**
1507
- * Additional provider-specific metadata. They are passed through
1508
- * to the provider from the AI SDK and enable provider-specific
1509
- * functionality that can be fully encapsulated in the provider.
1510
- */
1511
- providerMetadata?: LanguageModelV1ProviderMetadata;
1512
- }
1513
- /**
1514
- Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
1515
- */
1516
- interface LanguageModelV1ToolResultPart {
1517
- type: 'tool-result';
1518
- /**
1519
- ID of the tool call that this result is associated with.
1520
- */
1521
- toolCallId: string;
1522
- /**
1523
- Name of the tool that generated this result.
1524
- */
1525
- toolName: string;
1526
- /**
1527
- Result of the tool call. This is a JSON-serializable object.
1528
- */
1529
- result: unknown;
1530
- /**
1531
- Optional flag if the result is an error or an error message.
1532
- */
1533
- isError?: boolean;
1534
- /**
1535
- Tool results as an array of parts. This enables advanced tool results including images.
1536
- When this is used, the `result` field should be ignored (if the provider supports content).
1537
- */
1538
- content?: Array<{
1539
- type: 'text';
1540
- /**
1541
- Text content.
1542
- */
1543
- text: string;
1544
- } | {
1545
- type: 'image';
1546
- /**
1547
- base-64 encoded image data
1548
- */
1549
- data: string;
1550
- /**
1551
- Mime type of the image.
1552
- */
1553
- mimeType?: string;
1554
- }>;
1555
- /**
1556
- * Additional provider-specific metadata. They are passed through
1557
- * to the provider from the AI SDK and enable provider-specific
1558
- * functionality that can be fully encapsulated in the provider.
1559
- */
1560
- providerMetadata?: LanguageModelV1ProviderMetadata;
1561
- }
1562
-
1563
- /**
1564
- The configuration of a tool that is defined by the provider.
1565
- */
1566
- type LanguageModelV1ProviderDefinedTool = {
1567
- /**
1568
- The type of the tool (always 'provider-defined').
1569
- */
1570
- type: 'provider-defined';
1571
- /**
1572
- The ID of the tool. Should follow the format `<provider-name>.<tool-name>`.
1573
- */
1574
- id: `${string}.${string}`;
1575
- /**
1576
- The name of the tool. Unique within this model call.
1577
- */
1578
- name: string;
1579
- /**
1580
- The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
1581
- */
1582
- args: Record<string, unknown>;
1583
- };
1584
-
1585
- type LanguageModelV1ToolChoice = {
1586
- type: 'auto';
1587
- } | {
1588
- type: 'none';
1589
- } | {
1590
- type: 'required';
1591
- } | {
1592
- type: 'tool';
1593
- toolName: string;
1594
- };
1595
-
1596
- type LanguageModelV1CallOptions = LanguageModelV1CallSettings & {
1597
- /**
1598
- Whether the user provided the input as messages or as
1599
- a prompt. This can help guide non-chat models in the
1600
- expansion, bc different expansions can be needed for
1601
- chat/non-chat use cases.
1602
- */
1603
- inputFormat: 'messages' | 'prompt';
1604
- /**
1605
- The mode affects the behavior of the language model. It is required to
1606
- support provider-independent streaming and generation of structured objects.
1607
- The model can take this information and e.g. configure json mode, the correct
1608
- low level grammar, etc. It can also be used to optimize the efficiency of the
1609
- streaming, e.g. tool-delta stream parts are only needed in the
1610
- object-tool mode.
1611
-
1612
- @deprecated mode will be removed in v2.
1613
- All necessary settings will be directly supported through the call settings,
1614
- in particular responseFormat, toolChoice, and tools.
1615
- */
1616
- mode: {
1617
- type: 'regular';
1618
- /**
1619
- The tools that are available for the model.
1620
- */
1621
- tools?: Array<LanguageModelV1FunctionTool | LanguageModelV1ProviderDefinedTool>;
1622
- /**
1623
- Specifies how the tool should be selected. Defaults to 'auto'.
1624
- */
1625
- toolChoice?: LanguageModelV1ToolChoice;
1626
- } | {
1627
- type: 'object-json';
1628
- /**
1629
- * JSON schema that the generated output should conform to.
1630
- */
1631
- schema?: JSONSchema7;
1632
- /**
1633
- * Name of output that should be generated. Used by some providers for additional LLM guidance.
1634
- */
1635
- name?: string;
1636
- /**
1637
- * Description of the output that should be generated. Used by some providers for additional LLM guidance.
1638
- */
1639
- description?: string;
1640
- } | {
1641
- type: 'object-tool';
1642
- tool: LanguageModelV1FunctionTool;
1643
- };
1644
- /**
1645
- A language mode prompt is a standardized prompt type.
1646
-
1647
- Note: This is **not** the user-facing prompt. The AI SDK methods will map the
1648
- user-facing prompt types such as chat or instruction prompts to this format.
1649
- That approach allows us to evolve the user facing prompts without breaking
1650
- the language model interface.
1651
- */
1652
- prompt: LanguageModelV1Prompt;
1653
- /**
1654
- Additional provider-specific metadata.
1655
- The metadata is passed through to the provider from the AI SDK and enables
1656
- provider-specific functionality that can be fully encapsulated in the provider.
1657
- */
1658
- providerMetadata?: LanguageModelV1ProviderMetadata;
1659
- };
1660
-
1661
- /**
1662
- Warning from the model provider for this call. The call will proceed, but e.g.
1663
- some settings might not be supported, which can lead to suboptimal results.
1431
+ * Warning from the model provider for this call. The call will proceed, but e.g.
1432
+ * some settings might not be supported, which can lead to suboptimal results.
1664
1433
  */
1665
- type LanguageModelV1CallWarning = {
1434
+ type SpeechModelV2CallWarning = {
1666
1435
  type: 'unsupported-setting';
1667
- setting: keyof LanguageModelV1CallSettings;
1668
- details?: string;
1669
- } | {
1670
- type: 'unsupported-tool';
1671
- tool: LanguageModelV1FunctionTool | LanguageModelV1ProviderDefinedTool;
1436
+ setting: keyof SpeechModelV2CallOptions;
1672
1437
  details?: string;
1673
1438
  } | {
1674
1439
  type: 'other';
@@ -1676,341 +1441,82 @@ type LanguageModelV1CallWarning = {
1676
1441
  };
1677
1442
 
1678
1443
  /**
1679
- Reason why a language model finished generating a response.
1680
-
1681
- Can be one of the following:
1682
- - `stop`: model generated stop sequence
1683
- - `length`: model generated maximum number of tokens
1684
- - `content-filter`: content filter violation stopped the model
1685
- - `tool-calls`: model triggered tool calls
1686
- - `error`: model stopped because of an error
1687
- - `other`: model stopped for other reasons
1688
- - `unknown`: the model has not transmitted a finish reason
1689
- */
1690
- type LanguageModelV1FinishReason = 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other' | 'unknown';
1691
-
1692
- type LanguageModelV1FunctionToolCall = {
1693
- toolCallType: 'function';
1694
- toolCallId: string;
1695
- toolName: string;
1696
- /**
1697
- Stringified JSON object with the tool call arguments. Must match the
1698
- parameters schema of the tool.
1699
- */
1700
- args: string;
1701
- };
1702
-
1703
- /**
1704
- Log probabilities for each token and its top log probabilities.
1705
- */
1706
- type LanguageModelV1LogProbs = Array<{
1707
- token: string;
1708
- logprob: number;
1709
- topLogprobs: Array<{
1710
- token: string;
1711
- logprob: number;
1712
- }>;
1713
- }>;
1714
-
1715
- /**
1716
- Specification for a language model that implements the language model interface version 1.
1444
+ * Speech model specification version 2.
1717
1445
  */
1718
- type LanguageModelV1 = {
1446
+ type SpeechModelV2 = {
1719
1447
  /**
1720
- The language model must specify which language model interface
1721
- version it implements. This will allow us to evolve the language
1722
- model interface and retain backwards compatibility. The different
1723
- implementation versions can be handled as a discriminated union
1724
- on our side.
1448
+ * The speech model must specify which speech model interface
1449
+ * version it implements. This will allow us to evolve the speech
1450
+ * model interface and retain backwards compatibility. The different
1451
+ * implementation versions can be handled as a discriminated union
1452
+ * on our side.
1725
1453
  */
1726
- readonly specificationVersion: 'v1';
1454
+ readonly specificationVersion: 'v2';
1727
1455
  /**
1728
- Name of the provider for logging purposes.
1456
+ * Name of the provider for logging purposes.
1729
1457
  */
1730
1458
  readonly provider: string;
1731
1459
  /**
1732
- Provider-specific model ID for logging purposes.
1460
+ * Provider-specific model ID for logging purposes.
1733
1461
  */
1734
1462
  readonly modelId: string;
1735
1463
  /**
1736
- Default object generation mode that should be used with this model when
1737
- no mode is specified. Should be the mode with the best results for this
1738
- model. `undefined` can be returned if object generation is not supported.
1739
-
1740
- This is needed to generate the best objects possible w/o requiring the
1741
- user to explicitly specify the object generation mode.
1742
- */
1743
- readonly defaultObjectGenerationMode: LanguageModelV1ObjectGenerationMode;
1744
- /**
1745
- Flag whether this model supports image URLs. Default is `true`.
1746
-
1747
- When the flag is set to `false`, the AI SDK will download the image and
1748
- pass the image data to the model.
1749
- */
1750
- readonly supportsImageUrls?: boolean;
1751
- /**
1752
- Flag whether this model supports grammar-guided generation,
1753
- i.e. follows JSON schemas for object generation
1754
- when the response format is set to 'json' or
1755
- when the `object-json` mode is used.
1756
-
1757
- This means that the model guarantees that the generated JSON
1758
- will be a valid JSON object AND that the object will match the
1759
- JSON schema.
1760
-
1761
- Please note that `generateObject` and `streamObject` will work
1762
- regardless of this flag, but might send different prompts and
1763
- use further optimizations if this flag is set to `true`.
1764
-
1765
- Defaults to `false`.
1766
- */
1767
- readonly supportsStructuredOutputs?: boolean;
1768
- /**
1769
- Checks if the model supports the given URL for file parts natively.
1770
- If the model does not support the URL,
1771
- the AI SDK will download the file and pass the file data to the model.
1772
-
1773
- When undefined, the AI SDK will download the file.
1774
- */
1775
- supportsUrl?(url: URL): boolean;
1776
- /**
1777
- Generates a language model output (non-streaming).
1778
-
1779
- Naming: "do" prefix to prevent accidental direct usage of the method
1780
- by the user.
1781
- */
1782
- doGenerate(options: LanguageModelV1CallOptions): PromiseLike<{
1783
- /**
1784
- Text that the model has generated.
1785
- Can be undefined if the model did not generate any text.
1786
- */
1787
- text?: string;
1788
- /**
1789
- Reasoning that the model has generated.
1790
- Can be undefined if the model does not support reasoning.
1791
- */
1792
- reasoning?: string | Array<{
1793
- type: 'text';
1794
- text: string;
1795
- /**
1796
- An optional signature for verifying that the reasoning originated from the model.
1797
- */
1798
- signature?: string;
1799
- } | {
1800
- type: 'redacted';
1801
- data: string;
1802
- }>;
1803
- /**
1804
- Generated files as base64 encoded strings or binary data.
1805
- The files should be returned without any unnecessary conversion.
1806
- If the API returns base64 encoded strings, the files should be returned
1807
- as base64 encoded strings. If the API returns binary data, the files should
1808
- be returned as binary data.
1809
- */
1810
- files?: Array<{
1811
- data: string | Uint8Array;
1812
- mimeType: string;
1813
- }>;
1814
- /**
1815
- Tool calls that the model has generated.
1816
- Can be undefined if the model did not generate any tool calls.
1817
- */
1818
- toolCalls?: Array<LanguageModelV1FunctionToolCall>;
1819
- /**
1820
- Finish reason.
1821
- */
1822
- finishReason: LanguageModelV1FinishReason;
1823
- /**
1824
- Usage information.
1825
- */
1826
- usage: {
1827
- promptTokens: number;
1828
- completionTokens: number;
1829
- };
1830
- /**
1831
- Raw prompt and setting information for observability provider integration.
1832
- */
1833
- rawCall: {
1834
- /**
1835
- Raw prompt after expansion and conversion to the format that the
1836
- provider uses to send the information to their API.
1837
- */
1838
- rawPrompt: unknown;
1839
- /**
1840
- Raw settings that are used for the API call. Includes provider-specific
1841
- settings.
1842
- */
1843
- rawSettings: Record<string, unknown>;
1844
- };
1845
- /**
1846
- Optional response information for telemetry and debugging purposes.
1847
- */
1848
- rawResponse?: {
1849
- /**
1850
- Response headers.
1851
- */
1852
- headers?: Record<string, string>;
1853
- /**
1854
- Response body.
1855
- */
1856
- body?: unknown;
1857
- };
1858
- /**
1859
- Optional request information for telemetry and debugging purposes.
1860
- */
1861
- request?: {
1862
- /**
1863
- Raw request HTTP body that was sent to the provider API as a string (JSON should be stringified).
1864
- Non-HTTP(s) providers should not set this.
1865
- */
1866
- body?: string;
1867
- };
1868
- /**
1869
- Optional response information for telemetry and debugging purposes.
1870
- */
1871
- response?: {
1872
- /**
1873
- ID for the generated response, if the provider sends one.
1874
- */
1875
- id?: string;
1876
- /**
1877
- Timestamp for the start of the generated response, if the provider sends one.
1878
- */
1879
- timestamp?: Date;
1880
- /**
1881
- The ID of the response model that was used to generate the response, if the provider sends one.
1882
- */
1883
- modelId?: string;
1884
- };
1885
- warnings?: LanguageModelV1CallWarning[];
1464
+ * Generates speech audio from text.
1465
+ */
1466
+ doGenerate(options: SpeechModelV2CallOptions): PromiseLike<{
1886
1467
  /**
1887
- Additional provider-specific metadata. They are passed through
1888
- from the provider to the AI SDK and enable provider-specific
1889
- results that can be fully encapsulated in the provider.
1468
+ * Generated audio as an ArrayBuffer.
1469
+ * The audio should be returned without any unnecessary conversion.
1470
+ * If the API returns base64 encoded strings, the audio should be returned
1471
+ * as base64 encoded strings. If the API returns binary data, the audio
1472
+ * should be returned as binary data.
1890
1473
  */
1891
- providerMetadata?: LanguageModelV1ProviderMetadata;
1474
+ audio: string | Uint8Array;
1892
1475
  /**
1893
- Sources that have been used as input to generate the response.
1476
+ * Warnings for the call, e.g. unsupported settings.
1894
1477
  */
1895
- sources?: LanguageModelV1Source[];
1478
+ warnings: Array<SpeechModelV2CallWarning>;
1896
1479
  /**
1897
- Logprobs for the completion.
1898
- `undefined` if the mode does not support logprobs or if was not enabled
1899
-
1900
- @deprecated will be changed into a provider-specific extension in v2
1480
+ * Optional request information for telemetry and debugging purposes.
1901
1481
  */
1902
- logprobs?: LanguageModelV1LogProbs;
1903
- }>;
1904
- /**
1905
- Generates a language model output (streaming).
1906
-
1907
- Naming: "do" prefix to prevent accidental direct usage of the method
1908
- by the user.
1909
- *
1910
- @return A stream of higher-level language model output parts.
1911
- */
1912
- doStream(options: LanguageModelV1CallOptions): PromiseLike<{
1913
- stream: ReadableStream<LanguageModelV1StreamPart>;
1482
+ request?: {
1483
+ /**
1484
+ * Response body (available only for providers that use HTTP requests).
1485
+ */
1486
+ body?: unknown;
1487
+ };
1914
1488
  /**
1915
- Raw prompt and setting information for observability provider integration.
1489
+ * Response information for telemetry and debugging purposes.
1916
1490
  */
1917
- rawCall: {
1491
+ response: {
1918
1492
  /**
1919
- Raw prompt after expansion and conversion to the format that the
1920
- provider uses to send the information to their API.
1493
+ * Timestamp for the start of the generated response.
1921
1494
  */
1922
- rawPrompt: unknown;
1495
+ timestamp: Date;
1923
1496
  /**
1924
- Raw settings that are used for the API call. Includes provider-specific
1925
- settings.
1497
+ * The ID of the response model that was used to generate the response.
1926
1498
  */
1927
- rawSettings: Record<string, unknown>;
1928
- };
1929
- /**
1930
- Optional raw response data.
1931
- */
1932
- rawResponse?: {
1499
+ modelId: string;
1933
1500
  /**
1934
- Response headers.
1501
+ * Response headers.
1935
1502
  */
1936
- headers?: Record<string, string>;
1937
- };
1938
- /**
1939
- Optional request information for telemetry and debugging purposes.
1940
- */
1941
- request?: {
1503
+ headers?: SharedV2Headers;
1942
1504
  /**
1943
- Raw request HTTP body that was sent to the provider API as a string (JSON should be stringified).
1944
- Non-HTTP(s) providers should not set this.
1945
- */
1946
- body?: string;
1505
+ * Response body.
1506
+ */
1507
+ body?: unknown;
1947
1508
  };
1948
1509
  /**
1949
- Warnings for the call, e.g. unsupported settings.
1510
+ * Additional provider-specific metadata. They are passed through
1511
+ * from the provider to the AI SDK and enable provider-specific
1512
+ * results that can be fully encapsulated in the provider.
1950
1513
  */
1951
- warnings?: Array<LanguageModelV1CallWarning>;
1514
+ providerMetadata?: Record<string, Record<string, JSONValue>>;
1952
1515
  }>;
1953
1516
  };
1954
- type LanguageModelV1StreamPart = {
1955
- type: 'text-delta';
1956
- textDelta: string;
1957
- } | {
1958
- type: 'reasoning';
1959
- textDelta: string;
1960
- } | {
1961
- type: 'reasoning-signature';
1962
- signature: string;
1963
- } | {
1964
- type: 'redacted-reasoning';
1965
- data: string;
1966
- } | {
1967
- type: 'source';
1968
- source: LanguageModelV1Source;
1969
- } | {
1970
- type: 'file';
1971
- mimeType: string;
1972
- /**
1973
- Generated file data as base64 encoded strings or binary data.
1974
- The file data should be returned without any unnecessary conversion.
1975
- If the API returns base64 encoded strings, the file data should be returned
1976
- as base64 encoded strings. If the API returns binary data, the file data should
1977
- be returned as binary data.
1978
- */
1979
- data: string | Uint8Array;
1980
- } | ({
1981
- type: 'tool-call';
1982
- } & LanguageModelV1FunctionToolCall) | {
1983
- type: 'tool-call-delta';
1984
- toolCallType: 'function';
1985
- toolCallId: string;
1986
- toolName: string;
1987
- argsTextDelta: string;
1988
- } | {
1989
- type: 'response-metadata';
1990
- id?: string;
1991
- timestamp?: Date;
1992
- modelId?: string;
1993
- } | {
1994
- type: 'finish';
1995
- finishReason: LanguageModelV1FinishReason;
1996
- providerMetadata?: LanguageModelV1ProviderMetadata;
1997
- usage: {
1998
- promptTokens: number;
1999
- completionTokens: number;
2000
- };
2001
- logprobs?: LanguageModelV1LogProbs;
2002
- } | {
2003
- type: 'error';
2004
- error: unknown;
2005
- };
2006
- /**
2007
- The object generation modes available for use with a model. `undefined`
2008
- represents no support for object generation.
2009
- */
2010
- type LanguageModelV1ObjectGenerationMode = 'json' | 'tool' | undefined;
2011
1517
 
2012
- type TranscriptionModelV1ProviderOptions = Record<string, Record<string, JSONValue>>;
2013
- type TranscriptionModelV1CallOptions = {
1518
+ type TranscriptionModelV2ProviderOptions = Record<string, Record<string, JSONValue>>;
1519
+ type TranscriptionModelV2CallOptions = {
2014
1520
  /**
2015
1521
  Audio data to transcribe.
2016
1522
  Accepts a `Uint8Array` or `string`, where `string` is a base64 encoded audio file.
@@ -2036,7 +1542,7 @@ type TranscriptionModelV1CallOptions = {
2036
1542
  }
2037
1543
  ```
2038
1544
  */
2039
- providerOptions?: TranscriptionModelV1ProviderOptions;
1545
+ providerOptions?: TranscriptionModelV2ProviderOptions;
2040
1546
  /**
2041
1547
  Abort signal for cancelling the operation.
2042
1548
  */
@@ -2052,9 +1558,9 @@ type TranscriptionModelV1CallOptions = {
2052
1558
  Warning from the model provider for this call. The call will proceed, but e.g.
2053
1559
  some settings might not be supported, which can lead to suboptimal results.
2054
1560
  */
2055
- type TranscriptionModelV1CallWarning = {
1561
+ type TranscriptionModelV2CallWarning = {
2056
1562
  type: 'unsupported-setting';
2057
- setting: keyof TranscriptionModelV1CallOptions;
1563
+ setting: keyof TranscriptionModelV2CallOptions;
2058
1564
  details?: string;
2059
1565
  } | {
2060
1566
  type: 'other';
@@ -2062,9 +1568,9 @@ type TranscriptionModelV1CallWarning = {
2062
1568
  };
2063
1569
 
2064
1570
  /**
2065
- Transcription model specification version 1.
1571
+ Transcription model specification version 2.
2066
1572
  */
2067
- type TranscriptionModelV1 = {
1573
+ type TranscriptionModelV2 = {
2068
1574
  /**
2069
1575
  The transcription model must specify which transcription model interface
2070
1576
  version it implements. This will allow us to evolve the transcription
@@ -2072,7 +1578,7 @@ type TranscriptionModelV1 = {
2072
1578
  implementation versions can be handled as a discriminated union
2073
1579
  on our side.
2074
1580
  */
2075
- readonly specificationVersion: 'v1';
1581
+ readonly specificationVersion: 'v2';
2076
1582
  /**
2077
1583
  Name of the provider for logging purposes.
2078
1584
  */
@@ -2084,7 +1590,7 @@ type TranscriptionModelV1 = {
2084
1590
  /**
2085
1591
  Generates a transcript.
2086
1592
  */
2087
- doGenerate(options: TranscriptionModelV1CallOptions): PromiseLike<{
1593
+ doGenerate(options: TranscriptionModelV2CallOptions): PromiseLike<{
2088
1594
  /**
2089
1595
  * The complete transcribed text from the audio.
2090
1596
  */
@@ -2120,7 +1626,7 @@ type TranscriptionModelV1 = {
2120
1626
  /**
2121
1627
  Warnings for the call, e.g. unsupported settings.
2122
1628
  */
2123
- warnings: Array<TranscriptionModelV1CallWarning>;
1629
+ warnings: Array<TranscriptionModelV2CallWarning>;
2124
1630
  /**
2125
1631
  Optional request information for telemetry and debugging purposes.
2126
1632
  */
@@ -2161,145 +1667,10 @@ type TranscriptionModelV1 = {
2161
1667
  }>;
2162
1668
  };
2163
1669
 
2164
- type SpeechModelV1ProviderOptions = Record<string, Record<string, JSONValue>>;
2165
- type SpeechModelV1CallOptions = {
2166
- /**
2167
- * Text to convert to speech.
2168
- */
2169
- text: string;
2170
- /**
2171
- * The voice to use for speech synthesis.
2172
- * This is provider-specific and may be a voice ID, name, or other identifier.
2173
- */
2174
- voice?: string;
2175
- /**
2176
- * The desired output format for the audio e.g. "mp3", "wav", etc.
2177
- */
2178
- outputFormat?: string;
2179
- /**
2180
- * Instructions for the speech generation e.g. "Speak in a slow and steady tone".
2181
- */
2182
- instructions?: string;
2183
- /**
2184
- * The speed of the speech generation.
2185
- */
2186
- speed?: number;
2187
- /**
2188
- * Additional provider-specific options that are passed through to the provider
2189
- * as body parameters.
2190
- *
2191
- * The outer record is keyed by the provider name, and the inner
2192
- * record is keyed by the provider-specific metadata key.
2193
- * ```ts
2194
- * {
2195
- * "openai": {}
2196
- * }
2197
- * ```
2198
- */
2199
- providerOptions?: SpeechModelV1ProviderOptions;
2200
- /**
2201
- * Abort signal for cancelling the operation.
2202
- */
2203
- abortSignal?: AbortSignal;
2204
- /**
2205
- * Additional HTTP headers to be sent with the request.
2206
- * Only applicable for HTTP-based providers.
2207
- */
2208
- headers?: Record<string, string | undefined>;
2209
- };
2210
-
2211
- /**
2212
- * Warning from the model provider for this call. The call will proceed, but e.g.
2213
- * some settings might not be supported, which can lead to suboptimal results.
2214
- */
2215
- type SpeechModelV1CallWarning = {
2216
- type: 'unsupported-setting';
2217
- setting: keyof SpeechModelV1CallOptions;
2218
- details?: string;
2219
- } | {
2220
- type: 'other';
2221
- message: string;
2222
- };
2223
-
2224
- /**
2225
- * Speech model specification version 1.
2226
- */
2227
- type SpeechModelV1 = {
2228
- /**
2229
- * The speech model must specify which speech model interface
2230
- * version it implements. This will allow us to evolve the speech
2231
- * model interface and retain backwards compatibility. The different
2232
- * implementation versions can be handled as a discriminated union
2233
- * on our side.
2234
- */
2235
- readonly specificationVersion: 'v1';
2236
- /**
2237
- * Name of the provider for logging purposes.
2238
- */
2239
- readonly provider: string;
2240
- /**
2241
- * Provider-specific model ID for logging purposes.
2242
- */
2243
- readonly modelId: string;
2244
- /**
2245
- * Generates speech audio from text.
2246
- */
2247
- doGenerate(options: SpeechModelV1CallOptions): PromiseLike<{
2248
- /**
2249
- * Generated audio as an ArrayBuffer.
2250
- * The audio should be returned without any unnecessary conversion.
2251
- * If the API returns base64 encoded strings, the audio should be returned
2252
- * as base64 encoded strings. If the API returns binary data, the audio
2253
- * should be returned as binary data.
2254
- */
2255
- audio: string | Uint8Array;
2256
- /**
2257
- * Warnings for the call, e.g. unsupported settings.
2258
- */
2259
- warnings: Array<SpeechModelV1CallWarning>;
2260
- /**
2261
- * Optional request information for telemetry and debugging purposes.
2262
- */
2263
- request?: {
2264
- /**
2265
- * Response body (available only for providers that use HTTP requests).
2266
- */
2267
- body?: unknown;
2268
- };
2269
- /**
2270
- * Response information for telemetry and debugging purposes.
2271
- */
2272
- response: {
2273
- /**
2274
- * Timestamp for the start of the generated response.
2275
- */
2276
- timestamp: Date;
2277
- /**
2278
- * The ID of the response model that was used to generate the response.
2279
- */
2280
- modelId: string;
2281
- /**
2282
- * Response headers.
2283
- */
2284
- headers?: SharedV2Headers;
2285
- /**
2286
- * Response body.
2287
- */
2288
- body?: unknown;
2289
- };
2290
- /**
2291
- * Additional provider-specific metadata. They are passed through
2292
- * from the provider to the AI SDK and enable provider-specific
2293
- * results that can be fully encapsulated in the provider.
2294
- */
2295
- providerMetadata?: Record<string, Record<string, JSONValue>>;
2296
- }>;
2297
- };
2298
-
2299
1670
  /**
2300
1671
  * Provider for language, text embedding, and image generation models.
2301
1672
  */
2302
- interface ProviderV1 {
1673
+ interface ProviderV2 {
2303
1674
  /**
2304
1675
  Returns the language model with the given id.
2305
1676
  The model id is then passed to the provider function to get the model.
@@ -2310,7 +1681,7 @@ interface ProviderV1 {
2310
1681
 
2311
1682
  @throws {NoSuchModelError} If no such model exists.
2312
1683
  */
2313
- languageModel(modelId: string): LanguageModelV1;
1684
+ languageModel(modelId: string): LanguageModelV2;
2314
1685
  /**
2315
1686
  Returns the text embedding model with the given id.
2316
1687
  The model id is then passed to the provider function to get the model.
@@ -2330,7 +1701,7 @@ interface ProviderV1 {
2330
1701
 
2331
1702
  @returns {ImageModel} The image model associated with the id
2332
1703
  */
2333
- readonly imageModel?: (modelId: string) => ImageModelV1;
1704
+ imageModel(modelId: string): ImageModelV2;
2334
1705
  /**
2335
1706
  Returns the transcription model with the given id.
2336
1707
  The model id is then passed to the provider function to get the model.
@@ -2338,8 +1709,8 @@ interface ProviderV1 {
2338
1709
  @param {string} modelId - The id of the model to return.
2339
1710
 
2340
1711
  @returns {TranscriptionModel} The transcription model associated with the id
2341
- */
2342
- readonly transcriptionModel?: (modelId: string) => TranscriptionModelV1;
1712
+ */
1713
+ transcriptionModel?(modelId: string): TranscriptionModelV2;
2343
1714
  /**
2344
1715
  Returns the speech model with the given id.
2345
1716
  The model id is then passed to the provider function to get the model.
@@ -2347,45 +1718,8 @@ interface ProviderV1 {
2347
1718
  @param {string} modelId - The id of the model to return.
2348
1719
 
2349
1720
  @returns {SpeechModel} The speech model associated with the id
2350
- */
2351
- readonly speechModel?: (modelId: string) => SpeechModelV1;
2352
- }
2353
-
2354
- /**
2355
- * Provider for language, text embedding, and image generation models.
2356
- */
2357
- interface ProviderV2 {
2358
- /**
2359
- Returns the language model with the given id.
2360
- The model id is then passed to the provider function to get the model.
2361
-
2362
- @param {string} modelId - The id of the model to return.
2363
-
2364
- @returns {LanguageModel} The language model associated with the id
2365
-
2366
- @throws {NoSuchModelError} If no such model exists.
2367
- */
2368
- languageModel(modelId: string): LanguageModelV2;
2369
- /**
2370
- Returns the text embedding model with the given id.
2371
- The model id is then passed to the provider function to get the model.
2372
-
2373
- @param {string} modelId - The id of the model to return.
2374
-
2375
- @returns {LanguageModel} The language model associated with the id
2376
-
2377
- @throws {NoSuchModelError} If no such model exists.
2378
- */
2379
- textEmbeddingModel(modelId: string): EmbeddingModelV2<string>;
2380
- /**
2381
- Returns the image model with the given id.
2382
- The model id is then passed to the provider function to get the model.
2383
-
2384
- @param {string} modelId - The id of the model to return.
2385
-
2386
- @returns {ImageModel} The image model associated with the id
2387
- */
2388
- readonly imageModel: (modelId: string) => ImageModelV1;
1721
+ */
1722
+ speechModel?(modelId: string): SpeechModelV2;
2389
1723
  }
2390
1724
 
2391
- export { AISDKError, APICallError, type EmbeddingModelV2, type EmbeddingModelV2Embedding, EmptyResponseBodyError, type ImageModelV1, type ImageModelV1CallOptions, type ImageModelV1CallWarning, InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV1, type LanguageModelV1CallOptions, type LanguageModelV1CallWarning, type LanguageModelV1FilePart, type LanguageModelV1FinishReason, type LanguageModelV1FunctionTool, type LanguageModelV1FunctionToolCall, type LanguageModelV1ImagePart, type LanguageModelV1LogProbs, type LanguageModelV1Message, type LanguageModelV1ObjectGenerationMode, type LanguageModelV1Prompt, type LanguageModelV1ProviderDefinedTool, type LanguageModelV1ProviderMetadata, type LanguageModelV1ReasoningPart, type LanguageModelV1RedactedReasoningPart, type LanguageModelV1Source, type LanguageModelV1StreamPart, type LanguageModelV1TextPart, type LanguageModelV1ToolCallPart, type LanguageModelV1ToolChoice, type LanguageModelV1ToolResultPart, 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 LanguageModelV2RedactedReasoningPart, type LanguageModelV2ResponseMetadata, type LanguageModelV2Source, type LanguageModelV2StreamPart, type LanguageModelV2Text, type LanguageModelV2TextPart, type LanguageModelV2ToolCall, type LanguageModelV2ToolCallDelta, type LanguageModelV2ToolCallPart, type LanguageModelV2ToolChoice, type LanguageModelV2ToolResultPart, type LanguageModelV2Usage, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV1, type ProviderV2, type SharedV2Headers, type SharedV2ProviderMetadata, type SharedV2ProviderOptions, type SpeechModelV1, type SpeechModelV1CallOptions, type SpeechModelV1CallWarning, TooManyEmbeddingValuesForCallError, type TranscriptionModelV1, type TranscriptionModelV1CallOptions, type TranscriptionModelV1CallWarning, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };
1725
+ export { AISDKError, APICallError, type EmbeddingModelV2, type EmbeddingModelV2Embedding, EmptyResponseBodyError, type ImageModelV2, type ImageModelV2CallOptions, type ImageModelV2CallWarning, type ImageModelV2ProviderMetadata, 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, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV2, type SharedV2Headers, type SharedV2ProviderMetadata, type SharedV2ProviderOptions, type SpeechModelV2, type SpeechModelV2CallOptions, type SpeechModelV2CallWarning, TooManyEmbeddingValuesForCallError, type TranscriptionModelV2, type TranscriptionModelV2CallOptions, type TranscriptionModelV2CallWarning, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };