@ai-sdk/provider 2.0.0-canary.5 → 2.0.0-canary.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,11 +1,63 @@
1
1
  import { JSONSchema7 } from 'json-schema';
2
2
  export { JSONSchema7, JSONSchema7Definition } from 'json-schema';
3
3
 
4
+ type JSONValue = null | string | number | boolean | JSONObject | JSONArray;
5
+ type JSONObject = {
6
+ [key: string]: JSONValue;
7
+ };
8
+ type JSONArray = JSONValue[];
9
+
10
+ /**
11
+ * Additional provider-specific metadata.
12
+ * Metadata are additional outputs from the provider.
13
+ * They are passed through to the provider from the AI SDK
14
+ * and enable provider-specific functionality
15
+ * that can be fully encapsulated in the provider.
16
+ *
17
+ * This enables us to quickly ship provider-specific functionality
18
+ * without affecting the core AI SDK.
19
+ *
20
+ * The outer record is keyed by the provider name, and the inner
21
+ * record is keyed by the provider-specific metadata key.
22
+ *
23
+ * ```ts
24
+ * {
25
+ * "anthropic": {
26
+ * "cacheControl": { "type": "ephemeral" }
27
+ * }
28
+ * }
29
+ * ```
30
+ */
31
+ type SharedV2ProviderMetadata = Record<string, Record<string, JSONValue>>;
32
+
33
+ /**
34
+ * Additional provider-specific options.
35
+ * Options are additional input to the provider.
36
+ * They are passed through to the provider from the AI SDK
37
+ * and enable provider-specific functionality
38
+ * that can be fully encapsulated in the provider.
39
+ *
40
+ * This enables us to quickly ship provider-specific functionality
41
+ * without affecting the core AI SDK.
42
+ *
43
+ * The outer record is keyed by the provider name, and the inner
44
+ * record is keyed by the provider-specific metadata key.
45
+ *
46
+ * ```ts
47
+ * {
48
+ * "anthropic": {
49
+ * "cacheControl": { "type": "ephemeral" }
50
+ * }
51
+ * }
52
+ * ```
53
+ */
54
+ type SharedV2ProviderOptions = Record<string, Record<string, JSONValue>>;
55
+
4
56
  /**
5
57
  An embedding is a vector, i.e. an array of numbers.
6
58
  It is e.g. used to represent a text as a vector of word embeddings.
7
59
  */
8
- type EmbeddingModelV1Embedding = Array<number>;
60
+ type EmbeddingModelV2Embedding = Array<number>;
9
61
 
10
62
  /**
11
63
  Specification for an embedding model that implements the embedding model
@@ -15,7 +67,7 @@ VALUE is the type of the values that the model can embed.
15
67
  This will allow us to go beyond text embeddings in the future,
16
68
  e.g. to support image embeddings
17
69
  */
18
- type EmbeddingModelV1<VALUE> = {
70
+ type EmbeddingModelV2<VALUE> = {
19
71
  /**
20
72
  The embedding model must specify which embedding model interface
21
73
  version it implements. This will allow us to evolve the embedding
@@ -23,7 +75,7 @@ type EmbeddingModelV1<VALUE> = {
23
75
  implementation versions can be handled as a discriminated union
24
76
  on our side.
25
77
  */
26
- readonly specificationVersion: 'v1';
78
+ readonly specificationVersion: 'v2';
27
79
  /**
28
80
  Name of the provider for logging purposes.
29
81
  */
@@ -56,6 +108,12 @@ type EmbeddingModelV1<VALUE> = {
56
108
  */
57
109
  abortSignal?: AbortSignal;
58
110
  /**
111
+ Additional provider-specific options. They are passed through
112
+ to the provider from the AI SDK and enable provider-specific
113
+ functionality that can be fully encapsulated in the provider.
114
+ */
115
+ providerOptions?: SharedV2ProviderOptions;
116
+ /**
59
117
  Additional HTTP headers to be sent with the request.
60
118
  Only applicable for HTTP-based providers.
61
119
  */
@@ -64,7 +122,7 @@ type EmbeddingModelV1<VALUE> = {
64
122
  /**
65
123
  Generated embeddings. They are in the same order as the input values.
66
124
  */
67
- embeddings: Array<EmbeddingModelV1Embedding>;
125
+ embeddings: Array<EmbeddingModelV2Embedding>;
68
126
  /**
69
127
  Token usage. We only have input tokens for embeddings.
70
128
  */
@@ -72,13 +130,17 @@ type EmbeddingModelV1<VALUE> = {
72
130
  tokens: number;
73
131
  };
74
132
  /**
75
- Optional raw response information for debugging purposes.
133
+ Optional response information for debugging purposes.
76
134
  */
77
- rawResponse?: {
135
+ response?: {
78
136
  /**
79
137
  Response headers.
80
138
  */
81
139
  headers?: Record<string, string>;
140
+ /**
141
+ The response body.
142
+ */
143
+ body?: unknown;
82
144
  };
83
145
  }>;
84
146
  };
@@ -305,12 +367,6 @@ declare class UnsupportedFunctionalityError extends AISDKError {
305
367
  static isInstance(error: unknown): error is UnsupportedFunctionalityError;
306
368
  }
307
369
 
308
- type JSONValue = null | string | number | boolean | JSONObject | JSONArray;
309
- type JSONObject = {
310
- [key: string]: JSONValue;
311
- };
312
- type JSONArray = JSONValue[];
313
-
314
370
  type ImageModelV1CallOptions = {
315
371
  /**
316
372
  Prompt for the image generation.
@@ -441,138 +497,13 @@ declare function isJSONValue(value: unknown): value is JSONValue;
441
497
  declare function isJSONArray(value: unknown): value is JSONArray;
442
498
  declare function isJSONObject(value: unknown): value is JSONObject;
443
499
 
444
- /**
445
- * Additional provider-specific metadata. They are passed through
446
- * to the provider from the AI SDK and enable provider-specific
447
- * functionality that can be fully encapsulated in the provider.
448
- *
449
- * This enables us to quickly ship provider-specific functionality
450
- * without affecting the core AI SDK.
451
- *
452
- * The outer record is keyed by the provider name, and the inner
453
- * record is keyed by the provider-specific metadata key.
454
- *
455
- * ```ts
456
- * {
457
- * "anthropic": {
458
- * "cacheControl": { "type": "ephemeral" }
459
- * }
460
- * }
461
- * ```
462
- */
463
- type LanguageModelV1ProviderMetadata = Record<string, Record<string, JSONValue>>;
464
-
465
- /**
466
- * A source that has been used as input to generate the response.
467
- */
468
- type LanguageModelV1Source = {
469
- /**
470
- * A URL source. This is return by web search RAG models.
471
- */
472
- sourceType: 'url';
473
- /**
474
- * The ID of the source.
475
- */
476
- id: string;
477
- /**
478
- * The URL of the source.
479
- */
480
- url: string;
481
- /**
482
- * The title of the source.
483
- */
484
- title?: string;
485
- /**
486
- * Additional provider metadata for the source.
487
- */
488
- providerMetadata?: LanguageModelV1ProviderMetadata;
489
- };
490
-
491
- type LanguageModelV1CallSettings = {
492
- /**
493
- Maximum number of tokens to generate.
494
- */
495
- maxTokens?: number;
496
- /**
497
- Temperature setting.
498
-
499
- It is recommended to set either `temperature` or `topP`, but not both.
500
- */
501
- temperature?: number;
502
- /**
503
- Stop sequences.
504
- If set, the model will stop generating text when one of the stop sequences is generated.
505
- Providers may have limits on the number of stop sequences.
506
- */
507
- stopSequences?: string[];
508
- /**
509
- Nucleus sampling.
510
-
511
- It is recommended to set either `temperature` or `topP`, but not both.
512
- */
513
- topP?: number;
514
- /**
515
- Only sample from the top K options for each subsequent token.
516
-
517
- Used to remove "long tail" low probability responses.
518
- Recommended for advanced use cases only. You usually only need to use temperature.
519
- */
520
- topK?: number;
521
- /**
522
- Presence penalty setting. It affects the likelihood of the model to
523
- repeat information that is already in the prompt.
524
- */
525
- presencePenalty?: number;
526
- /**
527
- Frequency penalty setting. It affects the likelihood of the model
528
- to repeatedly use the same words or phrases.
529
- */
530
- frequencyPenalty?: number;
531
- /**
532
- Response format. The output can either be text or JSON. Default is text.
533
-
534
- If JSON is selected, a schema can optionally be provided to guide the LLM.
535
- */
536
- responseFormat?: {
537
- type: 'text';
538
- } | {
539
- type: 'json';
540
- /**
541
- * JSON schema that the generated output should conform to.
542
- */
543
- schema?: JSONSchema7;
544
- /**
545
- * Name of output that should be generated. Used by some providers for additional LLM guidance.
546
- */
547
- name?: string;
548
- /**
549
- * Description of the output that should be generated. Used by some providers for additional LLM guidance.
550
- */
551
- description?: string;
552
- };
553
- /**
554
- The seed (integer) to use for random sampling. If set and supported
555
- by the model, calls will generate deterministic results.
556
- */
557
- seed?: number;
558
- /**
559
- Abort signal for cancelling the operation.
560
- */
561
- abortSignal?: AbortSignal;
562
- /**
563
- Additional HTTP headers to be sent with the request.
564
- Only applicable for HTTP-based providers.
565
- */
566
- headers?: Record<string, string | undefined>;
567
- };
568
-
569
500
  /**
570
501
  A tool has a name, a description, and a set of parameters.
571
502
 
572
503
  Note: this is **not** the user-facing tool definition. The AI SDK methods will
573
504
  map the user-facing tool definitions to this format.
574
505
  */
575
- type LanguageModelV1FunctionTool = {
506
+ type LanguageModelV2FunctionTool = {
576
507
  /**
577
508
  The type of the tool (always 'function').
578
509
  */
@@ -593,6 +524,11 @@ type LanguageModelV1FunctionTool = {
593
524
  parameters: JSONSchema7;
594
525
  };
595
526
 
527
+ /**
528
+ Data content. Can be a Uint8Array, base64 encoded data as a string or a URL.
529
+ */
530
+ type LanguageModelV2DataContent = Uint8Array | string | URL;
531
+
596
532
  /**
597
533
  A prompt is a list of messages.
598
534
 
@@ -602,47 +538,47 @@ tool calls. The validation happens at runtime.
602
538
  Note: This is not a user-facing prompt. The AI SDK methods will map the
603
539
  user-facing prompt types such as chat or instruction prompts to this format.
604
540
  */
605
- type LanguageModelV1Prompt = Array<LanguageModelV1Message>;
606
- type LanguageModelV1Message = ({
541
+ type LanguageModelV2Prompt = Array<LanguageModelV2Message>;
542
+ type LanguageModelV2Message = ({
607
543
  role: 'system';
608
544
  content: string;
609
545
  } | {
610
546
  role: 'user';
611
- content: Array<LanguageModelV1TextPart | LanguageModelV1ImagePart | LanguageModelV1FilePart>;
547
+ content: Array<LanguageModelV2TextPart | LanguageModelV2FilePart>;
612
548
  } | {
613
549
  role: 'assistant';
614
- content: Array<LanguageModelV1TextPart | LanguageModelV1FilePart | LanguageModelV1ReasoningPart | LanguageModelV1RedactedReasoningPart | LanguageModelV1ToolCallPart>;
550
+ content: Array<LanguageModelV2TextPart | LanguageModelV2FilePart | LanguageModelV2ReasoningPart | LanguageModelV2RedactedReasoningPart | LanguageModelV2ToolCallPart>;
615
551
  } | {
616
552
  role: 'tool';
617
- content: Array<LanguageModelV1ToolResultPart>;
553
+ content: Array<LanguageModelV2ToolResultPart>;
618
554
  }) & {
619
555
  /**
620
- * Additional provider-specific metadata. They are passed through
556
+ * Additional provider-specific options. They are passed through
621
557
  * to the provider from the AI SDK and enable provider-specific
622
558
  * functionality that can be fully encapsulated in the provider.
623
559
  */
624
- providerMetadata?: LanguageModelV1ProviderMetadata;
560
+ providerOptions?: SharedV2ProviderOptions;
625
561
  };
626
562
  /**
627
563
  Text content part of a prompt. It contains a string of text.
628
564
  */
629
- interface LanguageModelV1TextPart {
565
+ interface LanguageModelV2TextPart {
630
566
  type: 'text';
631
567
  /**
632
568
  The text content.
633
569
  */
634
570
  text: string;
635
571
  /**
636
- * Additional provider-specific metadata. They are passed through
572
+ * Additional provider-specific options. They are passed through
637
573
  * to the provider from the AI SDK and enable provider-specific
638
574
  * functionality that can be fully encapsulated in the provider.
639
575
  */
640
- providerMetadata?: LanguageModelV1ProviderMetadata;
576
+ providerOptions?: SharedV2ProviderOptions;
641
577
  }
642
578
  /**
643
579
  Reasoning content part of a prompt. It contains a string of reasoning text.
644
580
  */
645
- interface LanguageModelV1ReasoningPart {
581
+ interface LanguageModelV2ReasoningPart {
646
582
  type: 'reasoning';
647
583
  /**
648
584
  The reasoning text.
@@ -653,76 +589,60 @@ interface LanguageModelV1ReasoningPart {
653
589
  */
654
590
  signature?: string;
655
591
  /**
656
- Additional provider-specific metadata. They are passed through
657
- to the provider from the AI SDK and enable provider-specific
658
- functionality that can be fully encapsulated in the provider.
592
+ * Additional provider-specific options. They are passed through
593
+ * to the provider from the AI SDK and enable provider-specific
594
+ * functionality that can be fully encapsulated in the provider.
659
595
  */
660
- providerMetadata?: LanguageModelV1ProviderMetadata;
596
+ providerOptions?: SharedV2ProviderOptions;
661
597
  }
662
598
  /**
663
599
  Redacted reasoning content part of a prompt.
664
600
  */
665
- interface LanguageModelV1RedactedReasoningPart {
601
+ interface LanguageModelV2RedactedReasoningPart {
666
602
  type: 'redacted-reasoning';
667
603
  /**
668
604
  Redacted reasoning data.
669
605
  */
670
606
  data: string;
671
607
  /**
672
- Additional provider-specific metadata. They are passed through
673
- to the provider from the AI SDK and enable provider-specific
674
- functionality that can be fully encapsulated in the provider.
675
- */
676
- providerMetadata?: LanguageModelV1ProviderMetadata;
677
- }
678
- /**
679
- Image content part of a prompt. It contains an image.
680
- */
681
- interface LanguageModelV1ImagePart {
682
- type: 'image';
683
- /**
684
- Image data as a Uint8Array (e.g. from a Blob or Buffer) or a URL.
685
- */
686
- image: Uint8Array | URL;
687
- /**
688
- Optional mime type of the image.
689
- */
690
- mimeType?: string;
691
- /**
692
- * Additional provider-specific metadata. They are passed through
608
+ * Additional provider-specific options. They are passed through
693
609
  * to the provider from the AI SDK and enable provider-specific
694
610
  * functionality that can be fully encapsulated in the provider.
695
611
  */
696
- providerMetadata?: LanguageModelV1ProviderMetadata;
612
+ providerOptions?: SharedV2ProviderOptions;
697
613
  }
698
614
  /**
699
615
  File content part of a prompt. It contains a file.
700
616
  */
701
- interface LanguageModelV1FilePart {
617
+ interface LanguageModelV2FilePart {
702
618
  type: 'file';
703
619
  /**
704
620
  * Optional filename of the file.
705
621
  */
706
622
  filename?: string;
707
623
  /**
708
- File data as base64 encoded string or as a URL.
709
- */
710
- data: string | URL;
711
- /**
712
- Mime type of the file.
624
+ File data. Can be a Uint8Array, base64 encoded data as a string or a URL.
625
+ */
626
+ data: LanguageModelV2DataContent;
627
+ /**
628
+ IANA media type of the file.
629
+
630
+ Can support wildcards, e.g. `image/*` (in which case the provider needs to take appropriate action).
631
+
632
+ @see https://www.iana.org/assignments/media-types/media-types.xhtml
713
633
  */
714
- mimeType: string;
634
+ mediaType: string;
715
635
  /**
716
- * Additional provider-specific metadata. They are passed through
636
+ * Additional provider-specific options. They are passed through
717
637
  * to the provider from the AI SDK and enable provider-specific
718
638
  * functionality that can be fully encapsulated in the provider.
719
639
  */
720
- providerMetadata?: LanguageModelV1ProviderMetadata;
640
+ providerOptions?: SharedV2ProviderOptions;
721
641
  }
722
642
  /**
723
643
  Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
724
644
  */
725
- interface LanguageModelV1ToolCallPart {
645
+ interface LanguageModelV2ToolCallPart {
726
646
  type: 'tool-call';
727
647
  /**
728
648
  ID of the tool call. This ID is used to match the tool call with the tool result.
@@ -737,16 +657,16 @@ interface LanguageModelV1ToolCallPart {
737
657
  */
738
658
  args: unknown;
739
659
  /**
740
- * Additional provider-specific metadata. They are passed through
660
+ * Additional provider-specific options. They are passed through
741
661
  * to the provider from the AI SDK and enable provider-specific
742
662
  * functionality that can be fully encapsulated in the provider.
743
663
  */
744
- providerMetadata?: LanguageModelV1ProviderMetadata;
664
+ providerOptions?: SharedV2ProviderOptions;
745
665
  }
746
666
  /**
747
667
  Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
748
668
  */
749
- interface LanguageModelV1ToolResultPart {
669
+ interface LanguageModelV2ToolResultPart {
750
670
  type: 'tool-result';
751
671
  /**
752
672
  ID of the tool call that this result is associated with.
@@ -781,22 +701,24 @@ base-64 encoded image data
781
701
  */
782
702
  data: string;
783
703
  /**
784
- Mime type of the image.
704
+ IANA media type of the image.
705
+
706
+ @see https://www.iana.org/assignments/media-types/media-types.xhtml
785
707
  */
786
- mimeType?: string;
708
+ mediaType?: string;
787
709
  }>;
788
710
  /**
789
- * Additional provider-specific metadata. They are passed through
711
+ * Additional provider-specific options. They are passed through
790
712
  * to the provider from the AI SDK and enable provider-specific
791
713
  * functionality that can be fully encapsulated in the provider.
792
714
  */
793
- providerMetadata?: LanguageModelV1ProviderMetadata;
715
+ providerOptions?: SharedV2ProviderOptions;
794
716
  }
795
717
 
796
718
  /**
797
719
  The configuration of a tool that is defined by the provider.
798
720
  */
799
- type LanguageModelV1ProviderDefinedTool = {
721
+ type LanguageModelV2ProviderDefinedTool = {
800
722
  /**
801
723
  The type of the tool (always 'provider-defined').
802
724
  */
@@ -815,7 +737,7 @@ type LanguageModelV1ProviderDefinedTool = {
815
737
  args: Record<string, unknown>;
816
738
  };
817
739
 
818
- type LanguageModelV1ToolChoice = {
740
+ type LanguageModelV2ToolChoice = {
819
741
  type: 'auto';
820
742
  } | {
821
743
  type: 'none';
@@ -826,7 +748,7 @@ type LanguageModelV1ToolChoice = {
826
748
  toolName: string;
827
749
  };
828
750
 
829
- type LanguageModelV1CallOptions = LanguageModelV1CallSettings & {
751
+ type LanguageModelV2CallOptions = {
830
752
  /**
831
753
  Whether the user provided the input as messages or as
832
754
  a prompt. This can help guide non-chat models in the
@@ -835,29 +757,62 @@ type LanguageModelV1CallOptions = LanguageModelV1CallSettings & {
835
757
  */
836
758
  inputFormat: 'messages' | 'prompt';
837
759
  /**
838
- The mode affects the behavior of the language model. It is required to
839
- support provider-independent streaming and generation of structured objects.
840
- The model can take this information and e.g. configure json mode, the correct
841
- low level grammar, etc. It can also be used to optimize the efficiency of the
842
- streaming, e.g. tool-delta stream parts are only needed in the
843
- object-tool mode.
760
+ A language mode prompt is a standardized prompt type.
844
761
 
845
- @deprecated mode will be removed in v2.
846
- All necessary settings will be directly supported through the call settings,
847
- in particular responseFormat, toolChoice, and tools.
762
+ Note: This is **not** the user-facing prompt. The AI SDK methods will map the
763
+ user-facing prompt types such as chat or instruction prompts to this format.
764
+ That approach allows us to evolve the user facing prompts without breaking
765
+ the language model interface.
848
766
  */
849
- mode: {
850
- type: 'regular';
851
- /**
852
- The tools that are available for the model.
853
- */
854
- tools?: Array<LanguageModelV1FunctionTool | LanguageModelV1ProviderDefinedTool>;
855
- /**
856
- Specifies how the tool should be selected. Defaults to 'auto'.
857
- */
858
- toolChoice?: LanguageModelV1ToolChoice;
767
+ prompt: LanguageModelV2Prompt;
768
+ /**
769
+ Maximum number of tokens to generate.
770
+ */
771
+ maxOutputTokens?: number;
772
+ /**
773
+ Temperature setting.
774
+
775
+ It is recommended to set either `temperature` or `topP`, but not both.
776
+ */
777
+ temperature?: number;
778
+ /**
779
+ Stop sequences.
780
+ If set, the model will stop generating text when one of the stop sequences is generated.
781
+ Providers may have limits on the number of stop sequences.
782
+ */
783
+ stopSequences?: string[];
784
+ /**
785
+ Nucleus sampling.
786
+
787
+ It is recommended to set either `temperature` or `topP`, but not both.
788
+ */
789
+ topP?: number;
790
+ /**
791
+ Only sample from the top K options for each subsequent token.
792
+
793
+ Used to remove "long tail" low probability responses.
794
+ Recommended for advanced use cases only. You usually only need to use temperature.
795
+ */
796
+ topK?: number;
797
+ /**
798
+ Presence penalty setting. It affects the likelihood of the model to
799
+ repeat information that is already in the prompt.
800
+ */
801
+ presencePenalty?: number;
802
+ /**
803
+ Frequency penalty setting. It affects the likelihood of the model
804
+ to repeatedly use the same words or phrases.
805
+ */
806
+ frequencyPenalty?: number;
807
+ /**
808
+ Response format. The output can either be text or JSON. Default is text.
809
+
810
+ If JSON is selected, a schema can optionally be provided to guide the LLM.
811
+ */
812
+ responseFormat?: {
813
+ type: 'text';
859
814
  } | {
860
- type: 'object-json';
815
+ type: 'json';
861
816
  /**
862
817
  * JSON schema that the generated output should conform to.
863
818
  */
@@ -870,38 +825,48 @@ Specifies how the tool should be selected. Defaults to 'auto'.
870
825
  * Description of the output that should be generated. Used by some providers for additional LLM guidance.
871
826
  */
872
827
  description?: string;
873
- } | {
874
- type: 'object-tool';
875
- tool: LanguageModelV1FunctionTool;
876
828
  };
877
829
  /**
878
- A language mode prompt is a standardized prompt type.
879
-
880
- Note: This is **not** the user-facing prompt. The AI SDK methods will map the
881
- user-facing prompt types such as chat or instruction prompts to this format.
882
- That approach allows us to evolve the user facing prompts without breaking
883
- the language model interface.
884
- */
885
- prompt: LanguageModelV1Prompt;
830
+ The seed (integer) to use for random sampling. If set and supported
831
+ by the model, calls will generate deterministic results.
832
+ */
833
+ seed?: number;
886
834
  /**
887
- Additional provider-specific metadata.
888
- The metadata is passed through to the provider from the AI SDK and enables
889
- provider-specific functionality that can be fully encapsulated in the provider.
835
+ The tools that are available for the model.
836
+ */
837
+ tools?: Array<LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool>;
838
+ /**
839
+ Specifies how the tool should be selected. Defaults to 'auto'.
840
+ */
841
+ toolChoice?: LanguageModelV2ToolChoice;
842
+ /**
843
+ Abort signal for cancelling the operation.
844
+ */
845
+ abortSignal?: AbortSignal;
846
+ /**
847
+ Additional HTTP headers to be sent with the request.
848
+ Only applicable for HTTP-based providers.
849
+ */
850
+ headers?: Record<string, string | undefined>;
851
+ /**
852
+ * Additional provider-specific options. They are passed through
853
+ * to the provider from the AI SDK and enable provider-specific
854
+ * functionality that can be fully encapsulated in the provider.
890
855
  */
891
- providerMetadata?: LanguageModelV1ProviderMetadata;
856
+ providerOptions?: SharedV2ProviderOptions;
892
857
  };
893
858
 
894
859
  /**
895
860
  Warning from the model provider for this call. The call will proceed, but e.g.
896
861
  some settings might not be supported, which can lead to suboptimal results.
897
862
  */
898
- type LanguageModelV1CallWarning = {
863
+ type LanguageModelV2CallWarning = {
899
864
  type: 'unsupported-setting';
900
- setting: keyof LanguageModelV1CallSettings;
865
+ setting: Omit<keyof LanguageModelV2CallOptions, 'prompt'>;
901
866
  details?: string;
902
867
  } | {
903
868
  type: 'unsupported-tool';
904
- tool: LanguageModelV1FunctionTool | LanguageModelV1ProviderDefinedTool;
869
+ tool: LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool;
905
870
  details?: string;
906
871
  } | {
907
872
  type: 'other';
@@ -909,20 +874,89 @@ type LanguageModelV1CallWarning = {
909
874
  };
910
875
 
911
876
  /**
912
- Reason why a language model finished generating a response.
877
+ A file that has been generated by the model.
878
+ Generated files as base64 encoded strings or binary data.
879
+ The files should be returned without any unnecessary conversion.
880
+ */
881
+ type LanguageModelV2File = {
882
+ type: 'file';
883
+ /**
884
+ The IANA media type of the file, e.g. `image/png` or `audio/mp3`.
885
+
886
+ @see https://www.iana.org/assignments/media-types/media-types.xhtml
887
+ */
888
+ mediaType: string;
889
+ /**
890
+ Generated file data as base64 encoded strings or binary data.
891
+
892
+ The file data should be returned without any unnecessary conversion.
893
+ If the API returns base64 encoded strings, the file data should be returned
894
+ as base64 encoded strings. If the API returns binary data, the file data should
895
+ be returned as binary data.
896
+ */
897
+ data: string | Uint8Array;
898
+ };
913
899
 
914
- Can be one of the following:
915
- - `stop`: model generated stop sequence
916
- - `length`: model generated maximum number of tokens
917
- - `content-filter`: content filter violation stopped the model
918
- - `tool-calls`: model triggered tool calls
919
- - `error`: model stopped because of an error
920
- - `other`: model stopped for other reasons
921
- - `unknown`: the model has not transmitted a finish reason
900
+ /**
901
+ Reasoning that the model has generated.
922
902
  */
923
- type LanguageModelV1FinishReason = 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other' | 'unknown';
903
+ type LanguageModelV2Reasoning = {
904
+ type: 'reasoning';
905
+ reasoningType: 'text';
906
+ text: string;
907
+ } | {
908
+ type: 'reasoning';
909
+ reasoningType: 'signature';
910
+ signature: string;
911
+ } | {
912
+ type: 'reasoning';
913
+ reasoningType: 'redacted';
914
+ data: string;
915
+ };
924
916
 
925
- type LanguageModelV1FunctionToolCall = {
917
+ /**
918
+ A source that has been used as input to generate the response.
919
+ */
920
+ type LanguageModelV2Source = {
921
+ type: 'source';
922
+ /**
923
+ * A URL source. This is return by web search RAG models.
924
+ */
925
+ sourceType: 'url';
926
+ /**
927
+ * The ID of the source.
928
+ */
929
+ id: string;
930
+ /**
931
+ * The URL of the source.
932
+ */
933
+ url: string;
934
+ /**
935
+ * The title of the source.
936
+ */
937
+ title?: string;
938
+ /**
939
+ * Additional provider metadata for the source.
940
+ */
941
+ providerMetadata?: SharedV2ProviderMetadata;
942
+ };
943
+
944
+ /**
945
+ Text that the model has generated.
946
+ */
947
+ type LanguageModelV2Text = {
948
+ type: 'text';
949
+ /**
950
+ The text content.
951
+ */
952
+ text: string;
953
+ };
954
+
955
+ /**
956
+ Tool calls that the model has generated.
957
+ */
958
+ type LanguageModelV2ToolCall = {
959
+ type: 'tool-call';
926
960
  toolCallType: 'function';
927
961
  toolCallId: string;
928
962
  toolName: string;
@@ -933,10 +967,26 @@ type LanguageModelV1FunctionToolCall = {
933
967
  args: string;
934
968
  };
935
969
 
970
+ type LanguageModelV2Content = LanguageModelV2Text | LanguageModelV2Reasoning | LanguageModelV2File | LanguageModelV2Source | LanguageModelV2ToolCall;
971
+
972
+ /**
973
+ Reason why a language model finished generating a response.
974
+
975
+ Can be one of the following:
976
+ - `stop`: model generated stop sequence
977
+ - `length`: model generated maximum number of tokens
978
+ - `content-filter`: content filter violation stopped the model
979
+ - `tool-calls`: model triggered tool calls
980
+ - `error`: model stopped because of an error
981
+ - `other`: model stopped for other reasons
982
+ - `unknown`: the model has not transmitted a finish reason
983
+ */
984
+ type LanguageModelV2FinishReason = 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other' | 'unknown';
985
+
936
986
  /**
937
987
  Log probabilities for each token and its top log probabilities.
938
988
  */
939
- type LanguageModelV1LogProbs = Array<{
989
+ type LanguageModelV2LogProbs = Array<{
940
990
  token: string;
941
991
  logprob: number;
942
992
  topLogprobs: Array<{
@@ -945,10 +995,32 @@ type LanguageModelV1LogProbs = Array<{
945
995
  }>;
946
996
  }>;
947
997
 
998
+ type LanguageModelV2ToolCallDelta = {
999
+ type: 'tool-call-delta';
1000
+ toolCallType: 'function';
1001
+ toolCallId: string;
1002
+ toolName: string;
1003
+ argsTextDelta: string;
1004
+ };
1005
+
948
1006
  /**
949
- Specification for a language model that implements the language model interface version 1.
1007
+ * Usage information for a language model call.
950
1008
  */
951
- type LanguageModelV1 = {
1009
+ type LanguageModelV2Usage = {
1010
+ /**
1011
+ * The number of input (prompt) tokens used.
1012
+ */
1013
+ inputTokens: number | undefined;
1014
+ /**
1015
+ * The number of output (completion) tokens used.
1016
+ */
1017
+ outputTokens: number | undefined;
1018
+ };
1019
+
1020
+ /**
1021
+ Specification for a language model that implements the language model interface version 2.
1022
+ */
1023
+ type LanguageModelV2 = {
952
1024
  /**
953
1025
  The language model must specify which language model interface
954
1026
  version it implements. This will allow us to evolve the language
@@ -956,7 +1028,7 @@ type LanguageModelV1 = {
956
1028
  implementation versions can be handled as a discriminated union
957
1029
  on our side.
958
1030
  */
959
- readonly specificationVersion: 'v1';
1031
+ readonly specificationVersion: 'v2';
960
1032
  /**
961
1033
  Name of the provider for logging purposes.
962
1034
  */
@@ -973,7 +1045,7 @@ type LanguageModelV1 = {
973
1045
  This is needed to generate the best objects possible w/o requiring the
974
1046
  user to explicitly specify the object generation mode.
975
1047
  */
976
- readonly defaultObjectGenerationMode: LanguageModelV1ObjectGenerationMode;
1048
+ readonly defaultObjectGenerationMode: LanguageModelV2ObjectGenerationMode;
977
1049
  /**
978
1050
  Flag whether this model supports image URLs. Default is `true`.
979
1051
 
@@ -1012,91 +1084,40 @@ type LanguageModelV1 = {
1012
1084
  Naming: "do" prefix to prevent accidental direct usage of the method
1013
1085
  by the user.
1014
1086
  */
1015
- doGenerate(options: LanguageModelV1CallOptions): PromiseLike<{
1016
- /**
1017
- Text that the model has generated.
1018
- Can be undefined if the model did not generate any text.
1019
- */
1020
- text?: string;
1021
- /**
1022
- Reasoning that the model has generated.
1023
- Can be undefined if the model does not support reasoning.
1024
- */
1025
- reasoning?: string | Array<{
1026
- type: 'text';
1027
- text: string;
1028
- /**
1029
- An optional signature for verifying that the reasoning originated from the model.
1030
- */
1031
- signature?: string;
1032
- } | {
1033
- type: 'redacted';
1034
- data: string;
1035
- }>;
1087
+ doGenerate(options: LanguageModelV2CallOptions): PromiseLike<{
1036
1088
  /**
1037
- Generated files as base64 encoded strings or binary data.
1038
- The files should be returned without any unnecessary conversion.
1039
- If the API returns base64 encoded strings, the files should be returned
1040
- as base64 encoded strings. If the API returns binary data, the files should
1041
- be returned as binary data.
1089
+ Ordered content that the model has generated.
1042
1090
  */
1043
- files?: Array<{
1044
- data: string | Uint8Array;
1045
- mimeType: string;
1046
- }>;
1091
+ content: Array<LanguageModelV2Content>;
1047
1092
  /**
1048
- Tool calls that the model has generated.
1049
- Can be undefined if the model did not generate any tool calls.
1050
- */
1051
- toolCalls?: Array<LanguageModelV1FunctionToolCall>;
1093
+ Logprobs for the completion.
1094
+ `undefined` if the mode does not support logprobs or if was not enabled
1095
+
1096
+ @deprecated will be changed into a provider-specific extension in v2
1097
+ */
1098
+ logprobs?: LanguageModelV2LogProbs;
1052
1099
  /**
1053
1100
  Finish reason.
1054
1101
  */
1055
- finishReason: LanguageModelV1FinishReason;
1102
+ finishReason: LanguageModelV2FinishReason;
1056
1103
  /**
1057
1104
  Usage information.
1058
1105
  */
1059
- usage: {
1060
- promptTokens: number;
1061
- completionTokens: number;
1062
- };
1063
- /**
1064
- Raw prompt and setting information for observability provider integration.
1065
- */
1066
- rawCall: {
1067
- /**
1068
- Raw prompt after expansion and conversion to the format that the
1069
- provider uses to send the information to their API.
1070
- */
1071
- rawPrompt: unknown;
1072
- /**
1073
- Raw settings that are used for the API call. Includes provider-specific
1074
- settings.
1075
- */
1076
- rawSettings: Record<string, unknown>;
1077
- };
1106
+ usage: LanguageModelV2Usage;
1078
1107
  /**
1079
- Optional response information for telemetry and debugging purposes.
1108
+ Additional provider-specific metadata. They are passed through
1109
+ from the provider to the AI SDK and enable provider-specific
1110
+ results that can be fully encapsulated in the provider.
1080
1111
  */
1081
- rawResponse?: {
1082
- /**
1083
- Response headers.
1084
- */
1085
- headers?: Record<string, string>;
1086
- /**
1087
- Response body.
1088
- */
1089
- body?: unknown;
1090
- };
1112
+ providerMetadata?: SharedV2ProviderMetadata;
1091
1113
  /**
1092
1114
  Optional request information for telemetry and debugging purposes.
1093
1115
  */
1094
1116
  request?: {
1095
1117
  /**
1096
- Raw request HTTP body that was sent to the provider API as a string (JSON should be stringified).
1097
- Non-HTTP(s) providers should not set this.
1118
+ Request HTTP body that was sent to the provider API.
1098
1119
  */
1099
- body?: string;
1120
+ body?: unknown;
1100
1121
  };
1101
1122
  /**
1102
1123
  Optional response information for telemetry and debugging purposes.
@@ -1114,133 +1135,254 @@ An optional signature for verifying that the reasoning originated from the model
1114
1135
  The ID of the response model that was used to generate the response, if the provider sends one.
1115
1136
  */
1116
1137
  modelId?: string;
1138
+ /**
1139
+ Response headers.
1140
+ */
1141
+ headers?: Record<string, string>;
1142
+ /**
1143
+ Response HTTP body.
1144
+ */
1145
+ body?: unknown;
1117
1146
  };
1118
- warnings?: LanguageModelV1CallWarning[];
1119
1147
  /**
1120
- Additional provider-specific metadata. They are passed through
1121
- from the provider to the AI SDK and enable provider-specific
1122
- results that can be fully encapsulated in the provider.
1148
+ Warnings for the call, e.g. unsupported settings.
1123
1149
  */
1124
- providerMetadata?: LanguageModelV1ProviderMetadata;
1150
+ warnings: Array<LanguageModelV2CallWarning>;
1151
+ }>;
1152
+ /**
1153
+ Generates a language model output (streaming).
1154
+
1155
+ Naming: "do" prefix to prevent accidental direct usage of the method
1156
+ by the user.
1157
+ *
1158
+ @return A stream of higher-level language model output parts.
1159
+ */
1160
+ doStream(options: LanguageModelV2CallOptions): PromiseLike<{
1161
+ stream: ReadableStream<LanguageModelV2StreamPart>;
1125
1162
  /**
1126
- Sources that have been used as input to generate the response.
1163
+ Optional request information for telemetry and debugging purposes.
1127
1164
  */
1128
- sources?: LanguageModelV1Source[];
1165
+ request?: {
1166
+ /**
1167
+ Request HTTP body that was sent to the provider API.
1168
+ */
1169
+ body?: unknown;
1170
+ };
1129
1171
  /**
1130
- Logprobs for the completion.
1131
- `undefined` if the mode does not support logprobs or if was not enabled
1132
-
1133
- @deprecated will be changed into a provider-specific extension in v2
1172
+ Optional response data.
1134
1173
  */
1135
- logprobs?: LanguageModelV1LogProbs;
1174
+ response?: {
1175
+ /**
1176
+ Response headers.
1177
+ */
1178
+ headers?: Record<string, string>;
1179
+ };
1136
1180
  }>;
1181
+ };
1182
+ type LanguageModelV2StreamPart = LanguageModelV2Content | LanguageModelV2ToolCallDelta | {
1183
+ type: 'stream-start';
1184
+ warnings: Array<LanguageModelV2CallWarning>;
1185
+ } | {
1186
+ type: 'response-metadata';
1187
+ id?: string;
1188
+ timestamp?: Date;
1189
+ modelId?: string;
1190
+ } | {
1191
+ type: 'finish';
1192
+ finishReason: LanguageModelV2FinishReason;
1193
+ providerMetadata?: SharedV2ProviderMetadata;
1194
+ usage: LanguageModelV2Usage;
1195
+ logprobs?: LanguageModelV2LogProbs;
1196
+ } | {
1197
+ type: 'error';
1198
+ error: unknown;
1199
+ };
1200
+ /**
1201
+ The object generation modes available for use with a model. `undefined`
1202
+ represents no support for object generation.
1203
+ */
1204
+ type LanguageModelV2ObjectGenerationMode = 'json' | 'tool' | undefined;
1205
+
1206
+ /**
1207
+ * Experimental middleware for LanguageModelV2.
1208
+ * This type defines the structure for middleware that can be used to modify
1209
+ * the behavior of LanguageModelV2 operations.
1210
+ */
1211
+ type LanguageModelV2Middleware = {
1212
+ /**
1213
+ * Middleware specification version. Use `v2` for the current version.
1214
+ */
1215
+ middlewareVersion?: 'v2' | undefined;
1216
+ /**
1217
+ * Transforms the parameters before they are passed to the language model.
1218
+ * @param options - Object containing the type of operation and the parameters.
1219
+ * @param options.type - The type of operation ('generate' or 'stream').
1220
+ * @param options.params - The original parameters for the language model call.
1221
+ * @returns A promise that resolves to the transformed parameters.
1222
+ */
1223
+ transformParams?: (options: {
1224
+ type: 'generate' | 'stream';
1225
+ params: LanguageModelV2CallOptions;
1226
+ }) => PromiseLike<LanguageModelV2CallOptions>;
1227
+ /**
1228
+ * Wraps the generate operation of the language model.
1229
+ * @param options - Object containing the generate function, parameters, and model.
1230
+ * @param options.doGenerate - The original generate function.
1231
+ * @param options.doStream - The original stream function.
1232
+ * @param options.params - The parameters for the generate call. If the
1233
+ * `transformParams` middleware is used, this will be the transformed parameters.
1234
+ * @param options.model - The language model instance.
1235
+ * @returns A promise that resolves to the result of the generate operation.
1236
+ */
1237
+ wrapGenerate?: (options: {
1238
+ doGenerate: () => ReturnType<LanguageModelV2['doGenerate']>;
1239
+ doStream: () => ReturnType<LanguageModelV2['doStream']>;
1240
+ params: LanguageModelV2CallOptions;
1241
+ model: LanguageModelV2;
1242
+ }) => Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
1243
+ /**
1244
+ * Wraps the stream operation of the language model.
1245
+ *
1246
+ * @param options - Object containing the stream function, parameters, and model.
1247
+ * @param options.doGenerate - The original generate function.
1248
+ * @param options.doStream - The original stream function.
1249
+ * @param options.params - The parameters for the stream call. If the
1250
+ * `transformParams` middleware is used, this will be the transformed parameters.
1251
+ * @param options.model - The language model instance.
1252
+ * @returns A promise that resolves to the result of the stream operation.
1253
+ */
1254
+ wrapStream?: (options: {
1255
+ doGenerate: () => ReturnType<LanguageModelV2['doGenerate']>;
1256
+ doStream: () => ReturnType<LanguageModelV2['doStream']>;
1257
+ params: LanguageModelV2CallOptions;
1258
+ model: LanguageModelV2;
1259
+ }) => PromiseLike<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
1260
+ };
1261
+
1262
+ /**
1263
+ * Additional provider-specific metadata. They are passed through
1264
+ * to the provider from the AI SDK and enable provider-specific
1265
+ * functionality that can be fully encapsulated in the provider.
1266
+ *
1267
+ * This enables us to quickly ship provider-specific functionality
1268
+ * without affecting the core AI SDK.
1269
+ *
1270
+ * The outer record is keyed by the provider name, and the inner
1271
+ * record is keyed by the provider-specific metadata key.
1272
+ *
1273
+ * ```ts
1274
+ * {
1275
+ * "anthropic": {
1276
+ * "cacheControl": { "type": "ephemeral" }
1277
+ * }
1278
+ * }
1279
+ * ```
1280
+ */
1281
+ type LanguageModelV1ProviderMetadata = Record<string, Record<string, JSONValue>>;
1282
+
1283
+ /**
1284
+ * A source that has been used as input to generate the response.
1285
+ */
1286
+ type LanguageModelV1Source = {
1287
+ /**
1288
+ * A URL source. This is return by web search RAG models.
1289
+ */
1290
+ sourceType: 'url';
1291
+ /**
1292
+ * The ID of the source.
1293
+ */
1294
+ id: string;
1295
+ /**
1296
+ * The URL of the source.
1297
+ */
1298
+ url: string;
1299
+ /**
1300
+ * The title of the source.
1301
+ */
1302
+ title?: string;
1303
+ /**
1304
+ * Additional provider metadata for the source.
1305
+ */
1306
+ providerMetadata?: LanguageModelV1ProviderMetadata;
1307
+ };
1308
+
1309
+ type LanguageModelV1CallSettings = {
1310
+ /**
1311
+ Maximum number of tokens to generate.
1312
+ */
1313
+ maxTokens?: number;
1314
+ /**
1315
+ Temperature setting.
1316
+
1317
+ It is recommended to set either `temperature` or `topP`, but not both.
1318
+ */
1319
+ temperature?: number;
1320
+ /**
1321
+ Stop sequences.
1322
+ If set, the model will stop generating text when one of the stop sequences is generated.
1323
+ Providers may have limits on the number of stop sequences.
1324
+ */
1325
+ stopSequences?: string[];
1137
1326
  /**
1138
- Generates a language model output (streaming).
1327
+ Nucleus sampling.
1139
1328
 
1140
- Naming: "do" prefix to prevent accidental direct usage of the method
1141
- by the user.
1142
- *
1143
- @return A stream of higher-level language model output parts.
1329
+ It is recommended to set either `temperature` or `topP`, but not both.
1144
1330
  */
1145
- doStream(options: LanguageModelV1CallOptions): PromiseLike<{
1146
- stream: ReadableStream<LanguageModelV1StreamPart>;
1147
- /**
1148
- Raw prompt and setting information for observability provider integration.
1149
- */
1150
- rawCall: {
1151
- /**
1152
- Raw prompt after expansion and conversion to the format that the
1153
- provider uses to send the information to their API.
1154
- */
1155
- rawPrompt: unknown;
1156
- /**
1157
- Raw settings that are used for the API call. Includes provider-specific
1158
- settings.
1159
- */
1160
- rawSettings: Record<string, unknown>;
1161
- };
1331
+ topP?: number;
1332
+ /**
1333
+ Only sample from the top K options for each subsequent token.
1334
+
1335
+ Used to remove "long tail" low probability responses.
1336
+ Recommended for advanced use cases only. You usually only need to use temperature.
1337
+ */
1338
+ topK?: number;
1339
+ /**
1340
+ Presence penalty setting. It affects the likelihood of the model to
1341
+ repeat information that is already in the prompt.
1342
+ */
1343
+ presencePenalty?: number;
1344
+ /**
1345
+ Frequency penalty setting. It affects the likelihood of the model
1346
+ to repeatedly use the same words or phrases.
1347
+ */
1348
+ frequencyPenalty?: number;
1349
+ /**
1350
+ Response format. The output can either be text or JSON. Default is text.
1351
+
1352
+ If JSON is selected, a schema can optionally be provided to guide the LLM.
1353
+ */
1354
+ responseFormat?: {
1355
+ type: 'text';
1356
+ } | {
1357
+ type: 'json';
1162
1358
  /**
1163
- Optional raw response data.
1359
+ * JSON schema that the generated output should conform to.
1164
1360
  */
1165
- rawResponse?: {
1166
- /**
1167
- Response headers.
1168
- */
1169
- headers?: Record<string, string>;
1170
- };
1361
+ schema?: JSONSchema7;
1171
1362
  /**
1172
- Optional request information for telemetry and debugging purposes.
1173
- */
1174
- request?: {
1175
- /**
1176
- Raw request HTTP body that was sent to the provider API as a string (JSON should be stringified).
1177
- Non-HTTP(s) providers should not set this.
1363
+ * Name of output that should be generated. Used by some providers for additional LLM guidance.
1178
1364
  */
1179
- body?: string;
1180
- };
1365
+ name?: string;
1181
1366
  /**
1182
- Warnings for the call, e.g. unsupported settings.
1367
+ * Description of the output that should be generated. Used by some providers for additional LLM guidance.
1183
1368
  */
1184
- warnings?: Array<LanguageModelV1CallWarning>;
1185
- }>;
1186
- };
1187
- type LanguageModelV1StreamPart = {
1188
- type: 'text-delta';
1189
- textDelta: string;
1190
- } | {
1191
- type: 'reasoning';
1192
- textDelta: string;
1193
- } | {
1194
- type: 'reasoning-signature';
1195
- signature: string;
1196
- } | {
1197
- type: 'redacted-reasoning';
1198
- data: string;
1199
- } | {
1200
- type: 'source';
1201
- source: LanguageModelV1Source;
1202
- } | {
1203
- type: 'file';
1204
- mimeType: string;
1369
+ description?: string;
1370
+ };
1205
1371
  /**
1206
- Generated file data as base64 encoded strings or binary data.
1207
- The file data should be returned without any unnecessary conversion.
1208
- If the API returns base64 encoded strings, the file data should be returned
1209
- as base64 encoded strings. If the API returns binary data, the file data should
1210
- be returned as binary data.
1372
+ The seed (integer) to use for random sampling. If set and supported
1373
+ by the model, calls will generate deterministic results.
1211
1374
  */
1212
- data: string | Uint8Array;
1213
- } | ({
1214
- type: 'tool-call';
1215
- } & LanguageModelV1FunctionToolCall) | {
1216
- type: 'tool-call-delta';
1217
- toolCallType: 'function';
1218
- toolCallId: string;
1219
- toolName: string;
1220
- argsTextDelta: string;
1221
- } | {
1222
- type: 'response-metadata';
1223
- id?: string;
1224
- timestamp?: Date;
1225
- modelId?: string;
1226
- } | {
1227
- type: 'finish';
1228
- finishReason: LanguageModelV1FinishReason;
1229
- providerMetadata?: LanguageModelV1ProviderMetadata;
1230
- usage: {
1231
- promptTokens: number;
1232
- completionTokens: number;
1233
- };
1234
- logprobs?: LanguageModelV1LogProbs;
1235
- } | {
1236
- type: 'error';
1237
- error: unknown;
1375
+ seed?: number;
1376
+ /**
1377
+ Abort signal for cancelling the operation.
1378
+ */
1379
+ abortSignal?: AbortSignal;
1380
+ /**
1381
+ Additional HTTP headers to be sent with the request.
1382
+ Only applicable for HTTP-based providers.
1383
+ */
1384
+ headers?: Record<string, string | undefined>;
1238
1385
  };
1239
- /**
1240
- The object generation modes available for use with a model. `undefined`
1241
- represents no support for object generation.
1242
- */
1243
- type LanguageModelV1ObjectGenerationMode = 'json' | 'tool' | undefined;
1244
1386
 
1245
1387
  /**
1246
1388
  A tool has a name, a description, and a set of parameters.
@@ -1248,7 +1390,7 @@ A tool has a name, a description, and a set of parameters.
1248
1390
  Note: this is **not** the user-facing tool definition. The AI SDK methods will
1249
1391
  map the user-facing tool definitions to this format.
1250
1392
  */
1251
- type LanguageModelV2FunctionTool = {
1393
+ type LanguageModelV1FunctionTool = {
1252
1394
  /**
1253
1395
  The type of the tool (always 'function').
1254
1396
  */
@@ -1269,34 +1411,6 @@ type LanguageModelV2FunctionTool = {
1269
1411
  parameters: JSONSchema7;
1270
1412
  };
1271
1413
 
1272
- /**
1273
- Data content. Can be a Uint8Array, base64 encoded data as a string or a URL.
1274
- */
1275
- type LanguageModelV2DataContent = Uint8Array | string | URL;
1276
-
1277
- /**
1278
- * Additional provider-specific options.
1279
- * Options are additional input to the provider.
1280
- * They are passed through to the provider from the AI SDK
1281
- * and enable provider-specific functionality
1282
- * that can be fully encapsulated in the provider.
1283
- *
1284
- * This enables us to quickly ship provider-specific functionality
1285
- * without affecting the core AI SDK.
1286
- *
1287
- * The outer record is keyed by the provider name, and the inner
1288
- * record is keyed by the provider-specific metadata key.
1289
- *
1290
- * ```ts
1291
- * {
1292
- * "anthropic": {
1293
- * "cacheControl": { "type": "ephemeral" }
1294
- * }
1295
- * }
1296
- * ```
1297
- */
1298
- type LanguageModelV2ProviderOptions = Record<string, Record<string, JSONValue>>;
1299
-
1300
1414
  /**
1301
1415
  A prompt is a list of messages.
1302
1416
 
@@ -1306,47 +1420,47 @@ tool calls. The validation happens at runtime.
1306
1420
  Note: This is not a user-facing prompt. The AI SDK methods will map the
1307
1421
  user-facing prompt types such as chat or instruction prompts to this format.
1308
1422
  */
1309
- type LanguageModelV2Prompt = Array<LanguageModelV2Message>;
1310
- type LanguageModelV2Message = ({
1423
+ type LanguageModelV1Prompt = Array<LanguageModelV1Message>;
1424
+ type LanguageModelV1Message = ({
1311
1425
  role: 'system';
1312
1426
  content: string;
1313
1427
  } | {
1314
1428
  role: 'user';
1315
- content: Array<LanguageModelV2TextPart | LanguageModelV2FilePart>;
1429
+ content: Array<LanguageModelV1TextPart | LanguageModelV1ImagePart | LanguageModelV1FilePart>;
1316
1430
  } | {
1317
1431
  role: 'assistant';
1318
- content: Array<LanguageModelV2TextPart | LanguageModelV2FilePart | LanguageModelV2ReasoningPart | LanguageModelV2RedactedReasoningPart | LanguageModelV2ToolCallPart>;
1432
+ content: Array<LanguageModelV1TextPart | LanguageModelV1FilePart | LanguageModelV1ReasoningPart | LanguageModelV1RedactedReasoningPart | LanguageModelV1ToolCallPart>;
1319
1433
  } | {
1320
1434
  role: 'tool';
1321
- content: Array<LanguageModelV2ToolResultPart>;
1435
+ content: Array<LanguageModelV1ToolResultPart>;
1322
1436
  }) & {
1323
1437
  /**
1324
- * Additional provider-specific options. They are passed through
1438
+ * Additional provider-specific metadata. They are passed through
1325
1439
  * to the provider from the AI SDK and enable provider-specific
1326
1440
  * functionality that can be fully encapsulated in the provider.
1327
1441
  */
1328
- providerOptions?: LanguageModelV2ProviderOptions;
1442
+ providerMetadata?: LanguageModelV1ProviderMetadata;
1329
1443
  };
1330
1444
  /**
1331
1445
  Text content part of a prompt. It contains a string of text.
1332
1446
  */
1333
- interface LanguageModelV2TextPart {
1447
+ interface LanguageModelV1TextPart {
1334
1448
  type: 'text';
1335
1449
  /**
1336
1450
  The text content.
1337
1451
  */
1338
1452
  text: string;
1339
1453
  /**
1340
- * Additional provider-specific options. They are passed through
1454
+ * Additional provider-specific metadata. They are passed through
1341
1455
  * to the provider from the AI SDK and enable provider-specific
1342
1456
  * functionality that can be fully encapsulated in the provider.
1343
1457
  */
1344
- providerOptions?: LanguageModelV2ProviderOptions;
1458
+ providerMetadata?: LanguageModelV1ProviderMetadata;
1345
1459
  }
1346
1460
  /**
1347
1461
  Reasoning content part of a prompt. It contains a string of reasoning text.
1348
1462
  */
1349
- interface LanguageModelV2ReasoningPart {
1463
+ interface LanguageModelV1ReasoningPart {
1350
1464
  type: 'reasoning';
1351
1465
  /**
1352
1466
  The reasoning text.
@@ -1357,60 +1471,76 @@ interface LanguageModelV2ReasoningPart {
1357
1471
  */
1358
1472
  signature?: string;
1359
1473
  /**
1360
- * Additional provider-specific options. They are passed through
1361
- * to the provider from the AI SDK and enable provider-specific
1362
- * functionality that can be fully encapsulated in the provider.
1474
+ Additional provider-specific metadata. They are passed through
1475
+ to the provider from the AI SDK and enable provider-specific
1476
+ functionality that can be fully encapsulated in the provider.
1363
1477
  */
1364
- providerOptions?: LanguageModelV2ProviderOptions;
1478
+ providerMetadata?: LanguageModelV1ProviderMetadata;
1365
1479
  }
1366
1480
  /**
1367
1481
  Redacted reasoning content part of a prompt.
1368
1482
  */
1369
- interface LanguageModelV2RedactedReasoningPart {
1483
+ interface LanguageModelV1RedactedReasoningPart {
1370
1484
  type: 'redacted-reasoning';
1371
1485
  /**
1372
1486
  Redacted reasoning data.
1373
1487
  */
1374
1488
  data: string;
1375
1489
  /**
1376
- * Additional provider-specific options. They are passed through
1490
+ Additional provider-specific metadata. They are passed through
1491
+ to the provider from the AI SDK and enable provider-specific
1492
+ functionality that can be fully encapsulated in the provider.
1493
+ */
1494
+ providerMetadata?: LanguageModelV1ProviderMetadata;
1495
+ }
1496
+ /**
1497
+ Image content part of a prompt. It contains an image.
1498
+ */
1499
+ interface LanguageModelV1ImagePart {
1500
+ type: 'image';
1501
+ /**
1502
+ Image data as a Uint8Array (e.g. from a Blob or Buffer) or a URL.
1503
+ */
1504
+ image: Uint8Array | URL;
1505
+ /**
1506
+ Optional mime type of the image.
1507
+ */
1508
+ mimeType?: string;
1509
+ /**
1510
+ * Additional provider-specific metadata. They are passed through
1377
1511
  * to the provider from the AI SDK and enable provider-specific
1378
1512
  * functionality that can be fully encapsulated in the provider.
1379
1513
  */
1380
- providerOptions?: LanguageModelV2ProviderOptions;
1514
+ providerMetadata?: LanguageModelV1ProviderMetadata;
1381
1515
  }
1382
1516
  /**
1383
1517
  File content part of a prompt. It contains a file.
1384
1518
  */
1385
- interface LanguageModelV2FilePart {
1519
+ interface LanguageModelV1FilePart {
1386
1520
  type: 'file';
1387
1521
  /**
1388
1522
  * Optional filename of the file.
1389
1523
  */
1390
1524
  filename?: string;
1391
1525
  /**
1392
- File data. Can be a Uint8Array, base64 encoded data as a string or a URL.
1393
- */
1394
- data: LanguageModelV2DataContent;
1526
+ File data as base64 encoded string or as a URL.
1527
+ */
1528
+ data: string | URL;
1395
1529
  /**
1396
- IANA media type of the file.
1397
-
1398
- Can support wildcards, e.g. `image/*` (in which case the provider needs to take appropriate action).
1399
-
1400
- @see https://www.iana.org/assignments/media-types/media-types.xhtml
1530
+ Mime type of the file.
1401
1531
  */
1402
- mediaType: string;
1532
+ mimeType: string;
1403
1533
  /**
1404
- * Additional provider-specific options. They are passed through
1534
+ * Additional provider-specific metadata. They are passed through
1405
1535
  * to the provider from the AI SDK and enable provider-specific
1406
1536
  * functionality that can be fully encapsulated in the provider.
1407
1537
  */
1408
- providerOptions?: LanguageModelV2ProviderOptions;
1538
+ providerMetadata?: LanguageModelV1ProviderMetadata;
1409
1539
  }
1410
1540
  /**
1411
1541
  Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
1412
1542
  */
1413
- interface LanguageModelV2ToolCallPart {
1543
+ interface LanguageModelV1ToolCallPart {
1414
1544
  type: 'tool-call';
1415
1545
  /**
1416
1546
  ID of the tool call. This ID is used to match the tool call with the tool result.
@@ -1425,16 +1555,16 @@ interface LanguageModelV2ToolCallPart {
1425
1555
  */
1426
1556
  args: unknown;
1427
1557
  /**
1428
- * Additional provider-specific options. They are passed through
1558
+ * Additional provider-specific metadata. They are passed through
1429
1559
  * to the provider from the AI SDK and enable provider-specific
1430
1560
  * functionality that can be fully encapsulated in the provider.
1431
1561
  */
1432
- providerOptions?: LanguageModelV2ProviderOptions;
1562
+ providerMetadata?: LanguageModelV1ProviderMetadata;
1433
1563
  }
1434
1564
  /**
1435
1565
  Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
1436
1566
  */
1437
- interface LanguageModelV2ToolResultPart {
1567
+ interface LanguageModelV1ToolResultPart {
1438
1568
  type: 'tool-result';
1439
1569
  /**
1440
1570
  ID of the tool call that this result is associated with.
@@ -1469,24 +1599,22 @@ base-64 encoded image data
1469
1599
  */
1470
1600
  data: string;
1471
1601
  /**
1472
- IANA media type of the image.
1473
-
1474
- @see https://www.iana.org/assignments/media-types/media-types.xhtml
1602
+ Mime type of the image.
1475
1603
  */
1476
- mediaType?: string;
1604
+ mimeType?: string;
1477
1605
  }>;
1478
1606
  /**
1479
- * Additional provider-specific options. They are passed through
1607
+ * Additional provider-specific metadata. They are passed through
1480
1608
  * to the provider from the AI SDK and enable provider-specific
1481
1609
  * functionality that can be fully encapsulated in the provider.
1482
1610
  */
1483
- providerOptions?: LanguageModelV2ProviderOptions;
1611
+ providerMetadata?: LanguageModelV1ProviderMetadata;
1484
1612
  }
1485
1613
 
1486
1614
  /**
1487
1615
  The configuration of a tool that is defined by the provider.
1488
1616
  */
1489
- type LanguageModelV2ProviderDefinedTool = {
1617
+ type LanguageModelV1ProviderDefinedTool = {
1490
1618
  /**
1491
1619
  The type of the tool (always 'provider-defined').
1492
1620
  */
@@ -1505,7 +1633,7 @@ type LanguageModelV2ProviderDefinedTool = {
1505
1633
  args: Record<string, unknown>;
1506
1634
  };
1507
1635
 
1508
- type LanguageModelV2ToolChoice = {
1636
+ type LanguageModelV1ToolChoice = {
1509
1637
  type: 'auto';
1510
1638
  } | {
1511
1639
  type: 'none';
@@ -1516,7 +1644,7 @@ type LanguageModelV2ToolChoice = {
1516
1644
  toolName: string;
1517
1645
  };
1518
1646
 
1519
- type LanguageModelV2CallOptions = {
1647
+ type LanguageModelV1CallOptions = LanguageModelV1CallSettings & {
1520
1648
  /**
1521
1649
  Whether the user provided the input as messages or as
1522
1650
  a prompt. This can help guide non-chat models in the
@@ -1525,62 +1653,29 @@ type LanguageModelV2CallOptions = {
1525
1653
  */
1526
1654
  inputFormat: 'messages' | 'prompt';
1527
1655
  /**
1528
- A language mode prompt is a standardized prompt type.
1656
+ The mode affects the behavior of the language model. It is required to
1657
+ support provider-independent streaming and generation of structured objects.
1658
+ The model can take this information and e.g. configure json mode, the correct
1659
+ low level grammar, etc. It can also be used to optimize the efficiency of the
1660
+ streaming, e.g. tool-delta stream parts are only needed in the
1661
+ object-tool mode.
1529
1662
 
1530
- Note: This is **not** the user-facing prompt. The AI SDK methods will map the
1531
- user-facing prompt types such as chat or instruction prompts to this format.
1532
- That approach allows us to evolve the user facing prompts without breaking
1533
- the language model interface.
1534
- */
1535
- prompt: LanguageModelV2Prompt;
1536
- /**
1537
- Maximum number of tokens to generate.
1663
+ @deprecated mode will be removed in v2.
1664
+ All necessary settings will be directly supported through the call settings,
1665
+ in particular responseFormat, toolChoice, and tools.
1538
1666
  */
1539
- maxOutputTokens?: number;
1540
- /**
1541
- Temperature setting.
1542
-
1543
- It is recommended to set either `temperature` or `topP`, but not both.
1544
- */
1545
- temperature?: number;
1546
- /**
1547
- Stop sequences.
1548
- If set, the model will stop generating text when one of the stop sequences is generated.
1549
- Providers may have limits on the number of stop sequences.
1550
- */
1551
- stopSequences?: string[];
1552
- /**
1553
- Nucleus sampling.
1554
-
1555
- It is recommended to set either `temperature` or `topP`, but not both.
1556
- */
1557
- topP?: number;
1558
- /**
1559
- Only sample from the top K options for each subsequent token.
1560
-
1561
- Used to remove "long tail" low probability responses.
1562
- Recommended for advanced use cases only. You usually only need to use temperature.
1563
- */
1564
- topK?: number;
1565
- /**
1566
- Presence penalty setting. It affects the likelihood of the model to
1567
- repeat information that is already in the prompt.
1568
- */
1569
- presencePenalty?: number;
1570
- /**
1571
- Frequency penalty setting. It affects the likelihood of the model
1572
- to repeatedly use the same words or phrases.
1573
- */
1574
- frequencyPenalty?: number;
1575
- /**
1576
- Response format. The output can either be text or JSON. Default is text.
1577
-
1578
- If JSON is selected, a schema can optionally be provided to guide the LLM.
1579
- */
1580
- responseFormat?: {
1581
- type: 'text';
1667
+ mode: {
1668
+ type: 'regular';
1669
+ /**
1670
+ The tools that are available for the model.
1671
+ */
1672
+ tools?: Array<LanguageModelV1FunctionTool | LanguageModelV1ProviderDefinedTool>;
1673
+ /**
1674
+ Specifies how the tool should be selected. Defaults to 'auto'.
1675
+ */
1676
+ toolChoice?: LanguageModelV1ToolChoice;
1582
1677
  } | {
1583
- type: 'json';
1678
+ type: 'object-json';
1584
1679
  /**
1585
1680
  * JSON schema that the generated output should conform to.
1586
1681
  */
@@ -1593,75 +1688,44 @@ type LanguageModelV2CallOptions = {
1593
1688
  * Description of the output that should be generated. Used by some providers for additional LLM guidance.
1594
1689
  */
1595
1690
  description?: string;
1691
+ } | {
1692
+ type: 'object-tool';
1693
+ tool: LanguageModelV1FunctionTool;
1596
1694
  };
1597
1695
  /**
1598
- The seed (integer) to use for random sampling. If set and supported
1599
- by the model, calls will generate deterministic results.
1600
- */
1601
- seed?: number;
1602
- /**
1603
- The tools that are available for the model.
1604
- */
1605
- tools?: Array<LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool>;
1606
- /**
1607
- Specifies how the tool should be selected. Defaults to 'auto'.
1608
- */
1609
- toolChoice?: LanguageModelV2ToolChoice;
1610
- /**
1611
- Abort signal for cancelling the operation.
1612
- */
1613
- abortSignal?: AbortSignal;
1614
- /**
1615
- Additional HTTP headers to be sent with the request.
1616
- Only applicable for HTTP-based providers.
1617
- */
1618
- headers?: Record<string, string | undefined>;
1696
+ A language mode prompt is a standardized prompt type.
1697
+
1698
+ Note: This is **not** the user-facing prompt. The AI SDK methods will map the
1699
+ user-facing prompt types such as chat or instruction prompts to this format.
1700
+ That approach allows us to evolve the user facing prompts without breaking
1701
+ the language model interface.
1702
+ */
1703
+ prompt: LanguageModelV1Prompt;
1619
1704
  /**
1620
- * Additional provider-specific options. They are passed through
1621
- * to the provider from the AI SDK and enable provider-specific
1622
- * functionality that can be fully encapsulated in the provider.
1705
+ Additional provider-specific metadata.
1706
+ The metadata is passed through to the provider from the AI SDK and enables
1707
+ provider-specific functionality that can be fully encapsulated in the provider.
1623
1708
  */
1624
- providerOptions?: LanguageModelV2ProviderOptions;
1709
+ providerMetadata?: LanguageModelV1ProviderMetadata;
1625
1710
  };
1626
1711
 
1627
1712
  /**
1628
1713
  Warning from the model provider for this call. The call will proceed, but e.g.
1629
1714
  some settings might not be supported, which can lead to suboptimal results.
1630
1715
  */
1631
- type LanguageModelV2CallWarning = {
1716
+ type LanguageModelV1CallWarning = {
1632
1717
  type: 'unsupported-setting';
1633
- setting: Omit<keyof LanguageModelV2CallOptions, 'prompt'>;
1718
+ setting: keyof LanguageModelV1CallSettings;
1634
1719
  details?: string;
1635
1720
  } | {
1636
1721
  type: 'unsupported-tool';
1637
- tool: LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool;
1722
+ tool: LanguageModelV1FunctionTool | LanguageModelV1ProviderDefinedTool;
1638
1723
  details?: string;
1639
1724
  } | {
1640
1725
  type: 'other';
1641
1726
  message: string;
1642
1727
  };
1643
1728
 
1644
- /**
1645
- A file that has been generated by the model.
1646
- */
1647
- type LanguageModelV2File = {
1648
- /**
1649
- The IANA media type of the file, e.g. `image/png` or `audio/mp3`.
1650
-
1651
- @see https://www.iana.org/assignments/media-types/media-types.xhtml
1652
- */
1653
- mediaType: string;
1654
- /**
1655
- Generated file data as base64 encoded strings or binary data.
1656
-
1657
- The file data should be returned without any unnecessary conversion.
1658
- If the API returns base64 encoded strings, the file data should be returned
1659
- as base64 encoded strings. If the API returns binary data, the file data should
1660
- be returned as binary data.
1661
- */
1662
- data: string | Uint8Array;
1663
- };
1664
-
1665
1729
  /**
1666
1730
  Reason why a language model finished generating a response.
1667
1731
 
@@ -1674,9 +1738,9 @@ Can be one of the following:
1674
1738
  - `other`: model stopped for other reasons
1675
1739
  - `unknown`: the model has not transmitted a finish reason
1676
1740
  */
1677
- type LanguageModelV2FinishReason = 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other' | 'unknown';
1741
+ type LanguageModelV1FinishReason = 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other' | 'unknown';
1678
1742
 
1679
- type LanguageModelV2FunctionToolCall = {
1743
+ type LanguageModelV1FunctionToolCall = {
1680
1744
  toolCallType: 'function';
1681
1745
  toolCallId: string;
1682
1746
  toolName: string;
@@ -1690,7 +1754,7 @@ type LanguageModelV2FunctionToolCall = {
1690
1754
  /**
1691
1755
  Log probabilities for each token and its top log probabilities.
1692
1756
  */
1693
- type LanguageModelV2LogProbs = Array<{
1757
+ type LanguageModelV1LogProbs = Array<{
1694
1758
  token: string;
1695
1759
  logprob: number;
1696
1760
  topLogprobs: Array<{
@@ -1700,72 +1764,9 @@ type LanguageModelV2LogProbs = Array<{
1700
1764
  }>;
1701
1765
 
1702
1766
  /**
1703
- * Additional provider-specific metadata.
1704
- * Metadata are additional outputs from the provider.
1705
- * They are passed through to the provider from the AI SDK
1706
- * and enable provider-specific functionality
1707
- * that can be fully encapsulated in the provider.
1708
- *
1709
- * This enables us to quickly ship provider-specific functionality
1710
- * without affecting the core AI SDK.
1711
- *
1712
- * The outer record is keyed by the provider name, and the inner
1713
- * record is keyed by the provider-specific metadata key.
1714
- *
1715
- * ```ts
1716
- * {
1717
- * "anthropic": {
1718
- * "cacheControl": { "type": "ephemeral" }
1719
- * }
1720
- * }
1721
- * ```
1722
- */
1723
- type LanguageModelV2ProviderMetadata = Record<string, Record<string, JSONValue>>;
1724
-
1725
- /**
1726
- * A source that has been used as input to generate the response.
1727
- */
1728
- type LanguageModelV2Source = {
1729
- /**
1730
- * A URL source. This is return by web search RAG models.
1731
- */
1732
- sourceType: 'url';
1733
- /**
1734
- * The ID of the source.
1735
- */
1736
- id: string;
1737
- /**
1738
- * The URL of the source.
1739
- */
1740
- url: string;
1741
- /**
1742
- * The title of the source.
1743
- */
1744
- title?: string;
1745
- /**
1746
- * Additional provider metadata for the source.
1747
- */
1748
- providerMetadata?: LanguageModelV2ProviderMetadata;
1749
- };
1750
-
1751
- /**
1752
- * Usage information for a language model call.
1753
- */
1754
- type LanguageModelV2Usage = {
1755
- /**
1756
- * The number of input (prompt) tokens used.
1757
- */
1758
- inputTokens: number | undefined;
1759
- /**
1760
- * The number of output (completion) tokens used.
1761
- */
1762
- outputTokens: number | undefined;
1763
- };
1764
-
1765
- /**
1766
- Specification for a language model that implements the language model interface version 2.
1767
+ Specification for a language model that implements the language model interface version 1.
1767
1768
  */
1768
- type LanguageModelV2 = {
1769
+ type LanguageModelV1 = {
1769
1770
  /**
1770
1771
  The language model must specify which language model interface
1771
1772
  version it implements. This will allow us to evolve the language
@@ -1773,7 +1774,7 @@ type LanguageModelV2 = {
1773
1774
  implementation versions can be handled as a discriminated union
1774
1775
  on our side.
1775
1776
  */
1776
- readonly specificationVersion: 'v2';
1777
+ readonly specificationVersion: 'v1';
1777
1778
  /**
1778
1779
  Name of the provider for logging purposes.
1779
1780
  */
@@ -1790,7 +1791,7 @@ type LanguageModelV2 = {
1790
1791
  This is needed to generate the best objects possible w/o requiring the
1791
1792
  user to explicitly specify the object generation mode.
1792
1793
  */
1793
- readonly defaultObjectGenerationMode: LanguageModelV2ObjectGenerationMode;
1794
+ readonly defaultObjectGenerationMode: LanguageModelV1ObjectGenerationMode;
1794
1795
  /**
1795
1796
  Flag whether this model supports image URLs. Default is `true`.
1796
1797
 
@@ -1829,7 +1830,7 @@ type LanguageModelV2 = {
1829
1830
  Naming: "do" prefix to prevent accidental direct usage of the method
1830
1831
  by the user.
1831
1832
  */
1832
- doGenerate(options: LanguageModelV2CallOptions): PromiseLike<{
1833
+ doGenerate(options: LanguageModelV1CallOptions): PromiseLike<{
1833
1834
  /**
1834
1835
  Text that the model has generated.
1835
1836
  Can be undefined if the model did not generate any text.
@@ -1853,46 +1854,67 @@ An optional signature for verifying that the reasoning originated from the model
1853
1854
  /**
1854
1855
  Generated files as base64 encoded strings or binary data.
1855
1856
  The files should be returned without any unnecessary conversion.
1857
+ If the API returns base64 encoded strings, the files should be returned
1858
+ as base64 encoded strings. If the API returns binary data, the files should
1859
+ be returned as binary data.
1856
1860
  */
1857
- files?: Array<LanguageModelV2File>;
1858
- /**
1859
- Sources that have been used as input to generate the response.
1860
- */
1861
- sources?: LanguageModelV2Source[];
1861
+ files?: Array<{
1862
+ data: string | Uint8Array;
1863
+ mimeType: string;
1864
+ }>;
1862
1865
  /**
1863
1866
  Tool calls that the model has generated.
1864
1867
  Can be undefined if the model did not generate any tool calls.
1865
1868
  */
1866
- toolCalls?: Array<LanguageModelV2FunctionToolCall>;
1867
- /**
1868
- Logprobs for the completion.
1869
- `undefined` if the mode does not support logprobs or if was not enabled
1870
-
1871
- @deprecated will be changed into a provider-specific extension in v2
1872
- */
1873
- logprobs?: LanguageModelV2LogProbs;
1869
+ toolCalls?: Array<LanguageModelV1FunctionToolCall>;
1874
1870
  /**
1875
1871
  Finish reason.
1876
1872
  */
1877
- finishReason: LanguageModelV2FinishReason;
1873
+ finishReason: LanguageModelV1FinishReason;
1878
1874
  /**
1879
1875
  Usage information.
1880
1876
  */
1881
- usage: LanguageModelV2Usage;
1877
+ usage: {
1878
+ promptTokens: number;
1879
+ completionTokens: number;
1880
+ };
1881
+ /**
1882
+ Raw prompt and setting information for observability provider integration.
1883
+ */
1884
+ rawCall: {
1885
+ /**
1886
+ Raw prompt after expansion and conversion to the format that the
1887
+ provider uses to send the information to their API.
1888
+ */
1889
+ rawPrompt: unknown;
1890
+ /**
1891
+ Raw settings that are used for the API call. Includes provider-specific
1892
+ settings.
1893
+ */
1894
+ rawSettings: Record<string, unknown>;
1895
+ };
1882
1896
  /**
1883
- Additional provider-specific metadata. They are passed through
1884
- from the provider to the AI SDK and enable provider-specific
1885
- results that can be fully encapsulated in the provider.
1897
+ Optional response information for telemetry and debugging purposes.
1886
1898
  */
1887
- providerMetadata?: LanguageModelV2ProviderMetadata;
1899
+ rawResponse?: {
1900
+ /**
1901
+ Response headers.
1902
+ */
1903
+ headers?: Record<string, string>;
1904
+ /**
1905
+ Response body.
1906
+ */
1907
+ body?: unknown;
1908
+ };
1888
1909
  /**
1889
1910
  Optional request information for telemetry and debugging purposes.
1890
1911
  */
1891
1912
  request?: {
1892
1913
  /**
1893
- Request HTTP body that was sent to the provider API.
1914
+ Raw request HTTP body that was sent to the provider API as a string (JSON should be stringified).
1915
+ Non-HTTP(s) providers should not set this.
1894
1916
  */
1895
- body?: unknown;
1917
+ body?: string;
1896
1918
  };
1897
1919
  /**
1898
1920
  Optional response information for telemetry and debugging purposes.
@@ -1910,19 +1932,25 @@ An optional signature for verifying that the reasoning originated from the model
1910
1932
  The ID of the response model that was used to generate the response, if the provider sends one.
1911
1933
  */
1912
1934
  modelId?: string;
1913
- /**
1914
- Response headers.
1915
- */
1916
- headers?: Record<string, string>;
1917
- /**
1918
- Response HTTP body.
1919
- */
1920
- body?: unknown;
1921
1935
  };
1936
+ warnings?: LanguageModelV1CallWarning[];
1922
1937
  /**
1923
- Warnings for the call, e.g. unsupported settings.
1938
+ Additional provider-specific metadata. They are passed through
1939
+ from the provider to the AI SDK and enable provider-specific
1940
+ results that can be fully encapsulated in the provider.
1941
+ */
1942
+ providerMetadata?: LanguageModelV1ProviderMetadata;
1943
+ /**
1944
+ Sources that have been used as input to generate the response.
1945
+ */
1946
+ sources?: LanguageModelV1Source[];
1947
+ /**
1948
+ Logprobs for the completion.
1949
+ `undefined` if the mode does not support logprobs or if was not enabled
1950
+
1951
+ @deprecated will be changed into a provider-specific extension in v2
1924
1952
  */
1925
- warnings?: LanguageModelV2CallWarning[];
1953
+ logprobs?: LanguageModelV1LogProbs;
1926
1954
  }>;
1927
1955
  /**
1928
1956
  Generates a language model output (streaming).
@@ -1932,33 +1960,49 @@ An optional signature for verifying that the reasoning originated from the model
1932
1960
  *
1933
1961
  @return A stream of higher-level language model output parts.
1934
1962
  */
1935
- doStream(options: LanguageModelV2CallOptions): PromiseLike<{
1936
- stream: ReadableStream<LanguageModelV2StreamPart>;
1963
+ doStream(options: LanguageModelV1CallOptions): PromiseLike<{
1964
+ stream: ReadableStream<LanguageModelV1StreamPart>;
1937
1965
  /**
1938
- Optional request information for telemetry and debugging purposes.
1966
+ Raw prompt and setting information for observability provider integration.
1939
1967
  */
1940
- request?: {
1968
+ rawCall: {
1941
1969
  /**
1942
- Request HTTP body that was sent to the provider API.
1943
- */
1944
- body?: unknown;
1970
+ Raw prompt after expansion and conversion to the format that the
1971
+ provider uses to send the information to their API.
1972
+ */
1973
+ rawPrompt: unknown;
1974
+ /**
1975
+ Raw settings that are used for the API call. Includes provider-specific
1976
+ settings.
1977
+ */
1978
+ rawSettings: Record<string, unknown>;
1945
1979
  };
1946
1980
  /**
1947
1981
  Optional raw response data.
1948
1982
  */
1949
- response?: {
1983
+ rawResponse?: {
1950
1984
  /**
1951
1985
  Response headers.
1952
1986
  */
1953
1987
  headers?: Record<string, string>;
1954
1988
  };
1955
1989
  /**
1990
+ Optional request information for telemetry and debugging purposes.
1991
+ */
1992
+ request?: {
1993
+ /**
1994
+ Raw request HTTP body that was sent to the provider API as a string (JSON should be stringified).
1995
+ Non-HTTP(s) providers should not set this.
1996
+ */
1997
+ body?: string;
1998
+ };
1999
+ /**
1956
2000
  Warnings for the call, e.g. unsupported settings.
1957
2001
  */
1958
- warnings?: Array<LanguageModelV2CallWarning>;
2002
+ warnings?: Array<LanguageModelV1CallWarning>;
1959
2003
  }>;
1960
2004
  };
1961
- type LanguageModelV2StreamPart = {
2005
+ type LanguageModelV1StreamPart = {
1962
2006
  type: 'text-delta';
1963
2007
  textDelta: string;
1964
2008
  } | {
@@ -1972,12 +2016,21 @@ type LanguageModelV2StreamPart = {
1972
2016
  data: string;
1973
2017
  } | {
1974
2018
  type: 'source';
1975
- source: LanguageModelV2Source;
1976
- } | ({
2019
+ source: LanguageModelV1Source;
2020
+ } | {
1977
2021
  type: 'file';
1978
- } & LanguageModelV2File) | ({
2022
+ mimeType: string;
2023
+ /**
2024
+ Generated file data as base64 encoded strings or binary data.
2025
+ The file data should be returned without any unnecessary conversion.
2026
+ If the API returns base64 encoded strings, the file data should be returned
2027
+ as base64 encoded strings. If the API returns binary data, the file data should
2028
+ be returned as binary data.
2029
+ */
2030
+ data: string | Uint8Array;
2031
+ } | ({
1979
2032
  type: 'tool-call';
1980
- } & LanguageModelV2FunctionToolCall) | {
2033
+ } & LanguageModelV1FunctionToolCall) | {
1981
2034
  type: 'tool-call-delta';
1982
2035
  toolCallType: 'function';
1983
2036
  toolCallId: string;
@@ -1990,10 +2043,13 @@ type LanguageModelV2StreamPart = {
1990
2043
  modelId?: string;
1991
2044
  } | {
1992
2045
  type: 'finish';
1993
- finishReason: LanguageModelV2FinishReason;
1994
- providerMetadata?: LanguageModelV2ProviderMetadata;
1995
- usage: LanguageModelV2Usage;
1996
- logprobs?: LanguageModelV2LogProbs;
2046
+ finishReason: LanguageModelV1FinishReason;
2047
+ providerMetadata?: LanguageModelV1ProviderMetadata;
2048
+ usage: {
2049
+ promptTokens: number;
2050
+ completionTokens: number;
2051
+ };
2052
+ logprobs?: LanguageModelV1LogProbs;
1997
2053
  } | {
1998
2054
  type: 'error';
1999
2055
  error: unknown;
@@ -2002,67 +2058,7 @@ type LanguageModelV2StreamPart = {
2002
2058
  The object generation modes available for use with a model. `undefined`
2003
2059
  represents no support for object generation.
2004
2060
  */
2005
- type LanguageModelV2ObjectGenerationMode = 'json' | 'tool' | undefined;
2006
-
2007
- /**
2008
- * Experimental middleware for LanguageModelV2.
2009
- * This type defines the structure for middleware that can be used to modify
2010
- * the behavior of LanguageModelV2 operations.
2011
- */
2012
- type LanguageModelV2Middleware = {
2013
- /**
2014
- * Middleware specification version. Use `v2` for the current version.
2015
- */
2016
- middlewareVersion?: 'v2' | undefined;
2017
- /**
2018
- * Transforms the parameters before they are passed to the language model.
2019
- * @param options - Object containing the type of operation and the parameters.
2020
- * @param options.type - The type of operation ('generate' or 'stream').
2021
- * @param options.params - The original parameters for the language model call.
2022
- * @returns A promise that resolves to the transformed parameters.
2023
- */
2024
- transformParams?: (options: {
2025
- type: 'generate' | 'stream';
2026
- params: LanguageModelV2CallOptions;
2027
- }) => PromiseLike<LanguageModelV2CallOptions>;
2028
- /**
2029
- * Wraps the generate operation of the language model.
2030
- * @param options - Object containing the generate function, parameters, and model.
2031
- * @param options.doGenerate - The original generate function.
2032
- * @param options.doStream - The original stream function.
2033
- * @param options.params - The parameters for the generate call. If the
2034
- * `transformParams` middleware is used, this will be the transformed parameters.
2035
- * @param options.model - The language model instance.
2036
- * @returns A promise that resolves to the result of the generate operation.
2037
- */
2038
- wrapGenerate?: (options: {
2039
- doGenerate: () => ReturnType<LanguageModelV2['doGenerate']>;
2040
- doStream: () => ReturnType<LanguageModelV2['doStream']>;
2041
- params: LanguageModelV2CallOptions;
2042
- model: LanguageModelV2;
2043
- }) => Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
2044
- /**
2045
- * Wraps the stream operation of the language model.
2046
- *
2047
- * @param options - Object containing the stream function, parameters, and model.
2048
- * @param options.doGenerate - The original generate function.
2049
- * @param options.doStream - The original stream function.
2050
- * @param options.params - The parameters for the stream call. If the
2051
- * `transformParams` middleware is used, this will be the transformed parameters.
2052
- * @param options.model - The language model instance.
2053
- * @returns A promise that resolves to the result of the stream operation.
2054
- */
2055
- wrapStream?: (options: {
2056
- doGenerate: () => ReturnType<LanguageModelV2['doGenerate']>;
2057
- doStream: () => ReturnType<LanguageModelV2['doStream']>;
2058
- params: LanguageModelV2CallOptions;
2059
- model: LanguageModelV2;
2060
- }) => PromiseLike<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
2061
- };
2062
- /**
2063
- * @deprecated Use `LanguageModelV2Middleware` instead.
2064
- */
2065
- type Experimental_LanguageModelV2Middleware = LanguageModelV2Middleware;
2061
+ type LanguageModelV1ObjectGenerationMode = 'json' | 'tool' | undefined;
2066
2062
 
2067
2063
  type TranscriptionModelV1ProviderOptions = Record<string, Record<string, JSONValue>>;
2068
2064
  type TranscriptionModelV1CallOptions = {
@@ -2216,6 +2212,141 @@ type TranscriptionModelV1 = {
2216
2212
  }>;
2217
2213
  };
2218
2214
 
2215
+ type SpeechModelV1ProviderOptions = Record<string, Record<string, JSONValue>>;
2216
+ type SpeechModelV1CallOptions = {
2217
+ /**
2218
+ * Text to convert to speech.
2219
+ */
2220
+ text: string;
2221
+ /**
2222
+ * The voice to use for speech synthesis.
2223
+ * This is provider-specific and may be a voice ID, name, or other identifier.
2224
+ */
2225
+ voice?: string;
2226
+ /**
2227
+ * The desired output format for the audio e.g. "mp3", "wav", etc.
2228
+ */
2229
+ outputFormat?: string;
2230
+ /**
2231
+ * Instructions for the speech generation e.g. "Speak in a slow and steady tone".
2232
+ */
2233
+ instructions?: string;
2234
+ /**
2235
+ * The speed of the speech generation.
2236
+ */
2237
+ speed?: number;
2238
+ /**
2239
+ * Additional provider-specific options that are passed through to the provider
2240
+ * as body parameters.
2241
+ *
2242
+ * The outer record is keyed by the provider name, and the inner
2243
+ * record is keyed by the provider-specific metadata key.
2244
+ * ```ts
2245
+ * {
2246
+ * "openai": {}
2247
+ * }
2248
+ * ```
2249
+ */
2250
+ providerOptions?: SpeechModelV1ProviderOptions;
2251
+ /**
2252
+ * Abort signal for cancelling the operation.
2253
+ */
2254
+ abortSignal?: AbortSignal;
2255
+ /**
2256
+ * Additional HTTP headers to be sent with the request.
2257
+ * Only applicable for HTTP-based providers.
2258
+ */
2259
+ headers?: Record<string, string | undefined>;
2260
+ };
2261
+
2262
+ /**
2263
+ * Warning from the model provider for this call. The call will proceed, but e.g.
2264
+ * some settings might not be supported, which can lead to suboptimal results.
2265
+ */
2266
+ type SpeechModelV1CallWarning = {
2267
+ type: 'unsupported-setting';
2268
+ setting: keyof SpeechModelV1CallOptions;
2269
+ details?: string;
2270
+ } | {
2271
+ type: 'other';
2272
+ message: string;
2273
+ };
2274
+
2275
+ /**
2276
+ * Speech model specification version 1.
2277
+ */
2278
+ type SpeechModelV1 = {
2279
+ /**
2280
+ * The speech model must specify which speech model interface
2281
+ * version it implements. This will allow us to evolve the speech
2282
+ * model interface and retain backwards compatibility. The different
2283
+ * implementation versions can be handled as a discriminated union
2284
+ * on our side.
2285
+ */
2286
+ readonly specificationVersion: 'v1';
2287
+ /**
2288
+ * Name of the provider for logging purposes.
2289
+ */
2290
+ readonly provider: string;
2291
+ /**
2292
+ * Provider-specific model ID for logging purposes.
2293
+ */
2294
+ readonly modelId: string;
2295
+ /**
2296
+ * Generates speech audio from text.
2297
+ */
2298
+ doGenerate(options: SpeechModelV1CallOptions): PromiseLike<{
2299
+ /**
2300
+ * Generated audio as an ArrayBuffer.
2301
+ * The audio should be returned without any unnecessary conversion.
2302
+ * If the API returns base64 encoded strings, the audio should be returned
2303
+ * as base64 encoded strings. If the API returns binary data, the audio
2304
+ * should be returned as binary data.
2305
+ */
2306
+ audio: string | Uint8Array;
2307
+ /**
2308
+ * Warnings for the call, e.g. unsupported settings.
2309
+ */
2310
+ warnings: Array<SpeechModelV1CallWarning>;
2311
+ /**
2312
+ * Optional request information for telemetry and debugging purposes.
2313
+ */
2314
+ request?: {
2315
+ /**
2316
+ * Response body (available only for providers that use HTTP requests).
2317
+ */
2318
+ body?: unknown;
2319
+ };
2320
+ /**
2321
+ * Response information for telemetry and debugging purposes.
2322
+ */
2323
+ response: {
2324
+ /**
2325
+ * Timestamp for the start of the generated response.
2326
+ */
2327
+ timestamp: Date;
2328
+ /**
2329
+ * The ID of the response model that was used to generate the response.
2330
+ */
2331
+ modelId: string;
2332
+ /**
2333
+ * Response headers.
2334
+ */
2335
+ headers: Record<string, string> | undefined;
2336
+ /**
2337
+ * Response body.
2338
+ */
2339
+ body?: unknown;
2340
+ };
2341
+ /**
2342
+ * Additional provider-specific metadata. They are passed through
2343
+ * from the provider to the AI SDK and enable provider-specific
2344
+ * results that can be fully encapsulated in the provider.
2345
+ */
2346
+ providerMetadata?: Record<string, Record<string, JSONValue>>;
2347
+ }>;
2348
+ };
2349
+
2219
2350
  /**
2220
2351
  * Provider for language, text embedding, and image generation models.
2221
2352
  */
@@ -2241,7 +2372,7 @@ interface ProviderV1 {
2241
2372
 
2242
2373
  @throws {NoSuchModelError} If no such model exists.
2243
2374
  */
2244
- textEmbeddingModel(modelId: string): EmbeddingModelV1<string>;
2375
+ textEmbeddingModel(modelId: string): EmbeddingModelV2<string>;
2245
2376
  /**
2246
2377
  Returns the image model with the given id.
2247
2378
  The model id is then passed to the provider function to get the model.
@@ -2260,6 +2391,15 @@ interface ProviderV1 {
2260
2391
  @returns {TranscriptionModel} The transcription model associated with the id
2261
2392
  */
2262
2393
  readonly transcriptionModel?: (modelId: string) => TranscriptionModelV1;
2394
+ /**
2395
+ Returns the speech model with the given id.
2396
+ The model id is then passed to the provider function to get the model.
2397
+
2398
+ @param {string} modelId - The id of the model to return.
2399
+
2400
+ @returns {SpeechModel} The speech model associated with the id
2401
+ */
2402
+ readonly speechModel?: (modelId: string) => SpeechModelV1;
2263
2403
  }
2264
2404
 
2265
2405
  /**
@@ -2287,7 +2427,7 @@ interface ProviderV2 {
2287
2427
 
2288
2428
  @throws {NoSuchModelError} If no such model exists.
2289
2429
  */
2290
- textEmbeddingModel(modelId: string): EmbeddingModelV1<string>;
2430
+ textEmbeddingModel(modelId: string): EmbeddingModelV2<string>;
2291
2431
  /**
2292
2432
  Returns the image model with the given id.
2293
2433
  The model id is then passed to the provider function to get the model.
@@ -2299,4 +2439,4 @@ interface ProviderV2 {
2299
2439
  readonly imageModel: (modelId: string) => ImageModelV1;
2300
2440
  }
2301
2441
 
2302
- export { AISDKError, APICallError, type EmbeddingModelV1, type EmbeddingModelV1Embedding, EmptyResponseBodyError, type Experimental_LanguageModelV2Middleware, 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 LanguageModelV2DataContent, type LanguageModelV2File, type LanguageModelV2FilePart, type LanguageModelV2FinishReason, type LanguageModelV2FunctionTool, type LanguageModelV2FunctionToolCall, type LanguageModelV2LogProbs, type LanguageModelV2Message, type LanguageModelV2Middleware, type LanguageModelV2ObjectGenerationMode, type LanguageModelV2Prompt, type LanguageModelV2ProviderDefinedTool, type LanguageModelV2ProviderMetadata, type LanguageModelV2ProviderOptions, type LanguageModelV2ReasoningPart, type LanguageModelV2RedactedReasoningPart, type LanguageModelV2Source, type LanguageModelV2StreamPart, type LanguageModelV2TextPart, type LanguageModelV2ToolCallPart, type LanguageModelV2ToolChoice, type LanguageModelV2ToolResultPart, type LanguageModelV2Usage, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV1, type ProviderV2, TooManyEmbeddingValuesForCallError, type TranscriptionModelV1, type TranscriptionModelV1CallOptions, type TranscriptionModelV1CallWarning, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };
2442
+ 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 LanguageModelV2LogProbs, type LanguageModelV2Message, type LanguageModelV2Middleware, type LanguageModelV2ObjectGenerationMode, type LanguageModelV2Prompt, type LanguageModelV2ProviderDefinedTool, type LanguageModelV2Reasoning, type LanguageModelV2ReasoningPart, type LanguageModelV2RedactedReasoningPart, 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 SharedV2ProviderMetadata, type SharedV2ProviderOptions, type SpeechModelV1, type SpeechModelV1CallOptions, type SpeechModelV1CallWarning, TooManyEmbeddingValuesForCallError, type TranscriptionModelV1, type TranscriptionModelV1CallOptions, type TranscriptionModelV1CallWarning, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };