@ai-sdk/provider 2.0.0-canary.0 → 2.0.0-canary.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,11 +1,65 @@
1
1
  import { JSONSchema7 } from 'json-schema';
2
2
  export { JSONSchema7, JSONSchema7Definition } from 'json-schema';
3
3
 
4
+ type SharedV2Headers = Record<string, string>;
5
+
6
+ type JSONValue = null | string | number | boolean | JSONObject | JSONArray;
7
+ type JSONObject = {
8
+ [key: string]: JSONValue;
9
+ };
10
+ type JSONArray = JSONValue[];
11
+
12
+ /**
13
+ * Additional provider-specific metadata.
14
+ * Metadata are additional outputs from the provider.
15
+ * They are passed through to the provider from the AI SDK
16
+ * and enable provider-specific functionality
17
+ * that can be fully encapsulated in the provider.
18
+ *
19
+ * This enables us to quickly ship provider-specific functionality
20
+ * without affecting the core AI SDK.
21
+ *
22
+ * The outer record is keyed by the provider name, and the inner
23
+ * record is keyed by the provider-specific metadata key.
24
+ *
25
+ * ```ts
26
+ * {
27
+ * "anthropic": {
28
+ * "cacheControl": { "type": "ephemeral" }
29
+ * }
30
+ * }
31
+ * ```
32
+ */
33
+ type SharedV2ProviderMetadata = Record<string, Record<string, JSONValue>>;
34
+
35
+ /**
36
+ * Additional provider-specific options.
37
+ * Options are additional input to the provider.
38
+ * They are passed through to the provider from the AI SDK
39
+ * and enable provider-specific functionality
40
+ * that can be fully encapsulated in the provider.
41
+ *
42
+ * This enables us to quickly ship provider-specific functionality
43
+ * without affecting the core AI SDK.
44
+ *
45
+ * The outer record is keyed by the provider name, and the inner
46
+ * record is keyed by the provider-specific metadata key.
47
+ *
48
+ * ```ts
49
+ * {
50
+ * "anthropic": {
51
+ * "cacheControl": { "type": "ephemeral" }
52
+ * }
53
+ * }
54
+ * ```
55
+ */
56
+ type SharedV2ProviderOptions = Record<string, Record<string, JSONValue>>;
57
+
4
58
  /**
5
59
  An embedding is a vector, i.e. an array of numbers.
6
60
  It is e.g. used to represent a text as a vector of word embeddings.
7
61
  */
8
- type EmbeddingModelV1Embedding = Array<number>;
62
+ type EmbeddingModelV2Embedding = Array<number>;
9
63
 
10
64
  /**
11
65
  Specification for an embedding model that implements the embedding model
@@ -15,7 +69,7 @@ VALUE is the type of the values that the model can embed.
15
69
  This will allow us to go beyond text embeddings in the future,
16
70
  e.g. to support image embeddings
17
71
  */
18
- type EmbeddingModelV1<VALUE> = {
72
+ type EmbeddingModelV2<VALUE> = {
19
73
  /**
20
74
  The embedding model must specify which embedding model interface
21
75
  version it implements. This will allow us to evolve the embedding
@@ -23,7 +77,7 @@ type EmbeddingModelV1<VALUE> = {
23
77
  implementation versions can be handled as a discriminated union
24
78
  on our side.
25
79
  */
26
- readonly specificationVersion: 'v1';
80
+ readonly specificationVersion: 'v2';
27
81
  /**
28
82
  Name of the provider for logging purposes.
29
83
  */
@@ -56,6 +110,12 @@ type EmbeddingModelV1<VALUE> = {
56
110
  */
57
111
  abortSignal?: AbortSignal;
58
112
  /**
113
+ Additional provider-specific options. They are passed through
114
+ to the provider from the AI SDK and enable provider-specific
115
+ functionality that can be fully encapsulated in the provider.
116
+ */
117
+ providerOptions?: SharedV2ProviderOptions;
118
+ /**
59
119
  Additional HTTP headers to be sent with the request.
60
120
  Only applicable for HTTP-based providers.
61
121
  */
@@ -64,7 +124,7 @@ type EmbeddingModelV1<VALUE> = {
64
124
  /**
65
125
  Generated embeddings. They are in the same order as the input values.
66
126
  */
67
- embeddings: Array<EmbeddingModelV1Embedding>;
127
+ embeddings: Array<EmbeddingModelV2Embedding>;
68
128
  /**
69
129
  Token usage. We only have input tokens for embeddings.
70
130
  */
@@ -72,13 +132,17 @@ type EmbeddingModelV1<VALUE> = {
72
132
  tokens: number;
73
133
  };
74
134
  /**
75
- Optional raw response information for debugging purposes.
135
+ Optional response information for debugging purposes.
76
136
  */
77
- rawResponse?: {
137
+ response?: {
78
138
  /**
79
139
  Response headers.
80
140
  */
81
- headers?: Record<string, string>;
141
+ headers?: SharedV2Headers;
142
+ /**
143
+ The response body.
144
+ */
145
+ body?: unknown;
82
146
  };
83
147
  }>;
84
148
  };
@@ -305,13 +369,7 @@ declare class UnsupportedFunctionalityError extends AISDKError {
305
369
  static isInstance(error: unknown): error is UnsupportedFunctionalityError;
306
370
  }
307
371
 
308
- type JSONValue = null | string | number | boolean | JSONObject | JSONArray;
309
- type JSONObject = {
310
- [key: string]: JSONValue;
311
- };
312
- type JSONArray = JSONValue[];
313
-
314
- type ImageModelV1CallOptions = {
372
+ type ImageModelV2CallOptions = {
315
373
  /**
316
374
  Prompt for the image generation.
317
375
  */
@@ -367,9 +425,9 @@ type ImageModelV1CallOptions = {
367
425
  Warning from the model provider for this call. The call will proceed, but e.g.
368
426
  some settings might not be supported, which can lead to suboptimal results.
369
427
  */
370
- type ImageModelV1CallWarning = {
428
+ type ImageModelV2CallWarning = {
371
429
  type: 'unsupported-setting';
372
- setting: keyof ImageModelV1CallOptions;
430
+ setting: keyof ImageModelV2CallOptions;
373
431
  details?: string;
374
432
  } | {
375
433
  type: 'other';
@@ -379,7 +437,7 @@ type ImageModelV1CallWarning = {
379
437
  /**
380
438
  Image generation model specification version 1.
381
439
  */
382
- type ImageModelV1 = {
440
+ type ImageModelV2 = {
383
441
  /**
384
442
  The image model must specify which image model interface
385
443
  version it implements. This will allow us to evolve the image
@@ -404,7 +462,7 @@ type ImageModelV1 = {
404
462
  /**
405
463
  Generates an array of images.
406
464
  */
407
- doGenerate(options: ImageModelV1CallOptions): PromiseLike<{
465
+ doGenerate(options: ImageModelV2CallOptions): PromiseLike<{
408
466
  /**
409
467
  Generated images as base64 encoded strings or binary data.
410
468
  The images should be returned without any unnecessary conversion.
@@ -416,7 +474,7 @@ type ImageModelV1 = {
416
474
  /**
417
475
  Warnings for the call, e.g. unsupported settings.
418
476
  */
419
- warnings: Array<ImageModelV1CallWarning>;
477
+ warnings: Array<ImageModelV2CallWarning>;
420
478
  /**
421
479
  Response information for telemetry and debugging purposes.
422
480
  */
@@ -426,20 +484,706 @@ type ImageModelV1 = {
426
484
  */
427
485
  timestamp: Date;
428
486
  /**
429
- The ID of the response model that was used to generate the response.
430
- */
431
- modelId: string;
487
+ The ID of the response model that was used to generate the response.
488
+ */
489
+ modelId: string;
490
+ /**
491
+ Response headers.
492
+ */
493
+ headers: Record<string, string> | undefined;
494
+ };
495
+ }>;
496
+ };
497
+
498
+ declare function isJSONValue(value: unknown): value is JSONValue;
499
+ declare function isJSONArray(value: unknown): value is JSONArray;
500
+ declare function isJSONObject(value: unknown): value is JSONObject;
501
+
502
+ /**
503
+ A tool has a name, a description, and a set of parameters.
504
+
505
+ Note: this is **not** the user-facing tool definition. The AI SDK methods will
506
+ map the user-facing tool definitions to this format.
507
+ */
508
+ type LanguageModelV2FunctionTool = {
509
+ /**
510
+ The type of the tool (always 'function').
511
+ */
512
+ type: 'function';
513
+ /**
514
+ The name of the tool. Unique within this model call.
515
+ */
516
+ name: string;
517
+ /**
518
+ A description of the tool. The language model uses this to understand the
519
+ tool's purpose and to provide better completion suggestions.
520
+ */
521
+ description?: string;
522
+ /**
523
+ The parameters that the tool expects. The language model uses this to
524
+ understand the tool's input requirements and to provide matching suggestions.
525
+ */
526
+ parameters: JSONSchema7;
527
+ };
528
+
529
+ /**
530
+ Data content. Can be a Uint8Array, base64 encoded data as a string or a URL.
531
+ */
532
+ type LanguageModelV2DataContent = Uint8Array | string | URL;
533
+
534
+ /**
535
+ A prompt is a list of messages.
536
+
537
+ Note: Not all models and prompt formats support multi-modal inputs and
538
+ tool calls. The validation happens at runtime.
539
+
540
+ Note: This is not a user-facing prompt. The AI SDK methods will map the
541
+ user-facing prompt types such as chat or instruction prompts to this format.
542
+ */
543
+ type LanguageModelV2Prompt = Array<LanguageModelV2Message>;
544
+ type LanguageModelV2Message = ({
545
+ role: 'system';
546
+ content: string;
547
+ } | {
548
+ role: 'user';
549
+ content: Array<LanguageModelV2TextPart | LanguageModelV2FilePart>;
550
+ } | {
551
+ role: 'assistant';
552
+ content: Array<LanguageModelV2TextPart | LanguageModelV2FilePart | LanguageModelV2ReasoningPart | LanguageModelV2ToolCallPart>;
553
+ } | {
554
+ role: 'tool';
555
+ content: Array<LanguageModelV2ToolResultPart>;
556
+ }) & {
557
+ /**
558
+ * Additional provider-specific options. They are passed through
559
+ * to the provider from the AI SDK and enable provider-specific
560
+ * functionality that can be fully encapsulated in the provider.
561
+ */
562
+ providerOptions?: SharedV2ProviderOptions;
563
+ };
564
+ /**
565
+ Text content part of a prompt. It contains a string of text.
566
+ */
567
+ interface LanguageModelV2TextPart {
568
+ type: 'text';
569
+ /**
570
+ The text content.
571
+ */
572
+ text: string;
573
+ /**
574
+ * Additional provider-specific options. They are passed through
575
+ * to the provider from the AI SDK and enable provider-specific
576
+ * functionality that can be fully encapsulated in the provider.
577
+ */
578
+ providerOptions?: SharedV2ProviderOptions;
579
+ }
580
+ /**
581
+ Reasoning content part of a prompt. It contains a string of reasoning text.
582
+ */
583
+ interface LanguageModelV2ReasoningPart {
584
+ type: 'reasoning';
585
+ /**
586
+ The reasoning text.
587
+ */
588
+ text: string;
589
+ /**
590
+ * Additional provider-specific options. They are passed through
591
+ * to the provider from the AI SDK and enable provider-specific
592
+ * functionality that can be fully encapsulated in the provider.
593
+ */
594
+ providerOptions?: SharedV2ProviderOptions;
595
+ }
596
+ /**
597
+ File content part of a prompt. It contains a file.
598
+ */
599
+ interface LanguageModelV2FilePart {
600
+ type: 'file';
601
+ /**
602
+ * Optional filename of the file.
603
+ */
604
+ filename?: string;
605
+ /**
606
+ File data. Can be a Uint8Array, base64 encoded data as a string or a URL.
607
+ */
608
+ data: LanguageModelV2DataContent;
609
+ /**
610
+ IANA media type of the file.
611
+
612
+ Can support wildcards, e.g. `image/*` (in which case the provider needs to take appropriate action).
613
+
614
+ @see https://www.iana.org/assignments/media-types/media-types.xhtml
615
+ */
616
+ mediaType: string;
617
+ /**
618
+ * Additional provider-specific options. They are passed through
619
+ * to the provider from the AI SDK and enable provider-specific
620
+ * functionality that can be fully encapsulated in the provider.
621
+ */
622
+ providerOptions?: SharedV2ProviderOptions;
623
+ }
624
+ /**
625
+ Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
626
+ */
627
+ interface LanguageModelV2ToolCallPart {
628
+ type: 'tool-call';
629
+ /**
630
+ ID of the tool call. This ID is used to match the tool call with the tool result.
631
+ */
632
+ toolCallId: string;
633
+ /**
634
+ Name of the tool that is being called.
635
+ */
636
+ toolName: string;
637
+ /**
638
+ Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
639
+ */
640
+ args: unknown;
641
+ /**
642
+ * Additional provider-specific options. They are passed through
643
+ * to the provider from the AI SDK and enable provider-specific
644
+ * functionality that can be fully encapsulated in the provider.
645
+ */
646
+ providerOptions?: SharedV2ProviderOptions;
647
+ }
648
+ /**
649
+ Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
650
+ */
651
+ interface LanguageModelV2ToolResultPart {
652
+ type: 'tool-result';
653
+ /**
654
+ ID of the tool call that this result is associated with.
655
+ */
656
+ toolCallId: string;
657
+ /**
658
+ Name of the tool that generated this result.
659
+ */
660
+ toolName: string;
661
+ /**
662
+ Result of the tool call. This is a JSON-serializable object.
663
+ */
664
+ result: unknown;
665
+ /**
666
+ Optional flag if the result is an error or an error message.
667
+ */
668
+ isError?: boolean;
669
+ /**
670
+ Tool results as an array of parts. This enables advanced tool results including images.
671
+ When this is used, the `result` field should be ignored (if the provider supports content).
672
+ */
673
+ content?: Array<{
674
+ type: 'text';
675
+ /**
676
+ Text content.
677
+ */
678
+ text: string;
679
+ } | {
680
+ type: 'image';
681
+ /**
682
+ base-64 encoded image data
683
+ */
684
+ data: string;
685
+ /**
686
+ IANA media type of the image.
687
+
688
+ @see https://www.iana.org/assignments/media-types/media-types.xhtml
689
+ */
690
+ mediaType?: string;
691
+ }>;
692
+ /**
693
+ * Additional provider-specific options. They are passed through
694
+ * to the provider from the AI SDK and enable provider-specific
695
+ * functionality that can be fully encapsulated in the provider.
696
+ */
697
+ providerOptions?: SharedV2ProviderOptions;
698
+ }
699
+
700
+ /**
701
+ The configuration of a tool that is defined by the provider.
702
+ */
703
+ type LanguageModelV2ProviderDefinedTool = {
704
+ /**
705
+ The type of the tool (always 'provider-defined').
706
+ */
707
+ type: 'provider-defined';
708
+ /**
709
+ The ID of the tool. Should follow the format `<provider-name>.<tool-name>`.
710
+ */
711
+ id: `${string}.${string}`;
712
+ /**
713
+ The name of the tool. Unique within this model call.
714
+ */
715
+ name: string;
716
+ /**
717
+ The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
718
+ */
719
+ args: Record<string, unknown>;
720
+ };
721
+
722
+ type LanguageModelV2ToolChoice = {
723
+ type: 'auto';
724
+ } | {
725
+ type: 'none';
726
+ } | {
727
+ type: 'required';
728
+ } | {
729
+ type: 'tool';
730
+ toolName: string;
731
+ };
732
+
733
+ type LanguageModelV2CallOptions = {
734
+ /**
735
+ Whether the user provided the input as messages or as
736
+ a prompt. This can help guide non-chat models in the
737
+ expansion, bc different expansions can be needed for
738
+ chat/non-chat use cases.
739
+ */
740
+ inputFormat: 'messages' | 'prompt';
741
+ /**
742
+ A language mode prompt is a standardized prompt type.
743
+
744
+ Note: This is **not** the user-facing prompt. The AI SDK methods will map the
745
+ user-facing prompt types such as chat or instruction prompts to this format.
746
+ That approach allows us to evolve the user facing prompts without breaking
747
+ the language model interface.
748
+ */
749
+ prompt: LanguageModelV2Prompt;
750
+ /**
751
+ Maximum number of tokens to generate.
752
+ */
753
+ maxOutputTokens?: number;
754
+ /**
755
+ Temperature setting.
756
+
757
+ It is recommended to set either `temperature` or `topP`, but not both.
758
+ */
759
+ temperature?: number;
760
+ /**
761
+ Stop sequences.
762
+ If set, the model will stop generating text when one of the stop sequences is generated.
763
+ Providers may have limits on the number of stop sequences.
764
+ */
765
+ stopSequences?: string[];
766
+ /**
767
+ Nucleus sampling.
768
+
769
+ It is recommended to set either `temperature` or `topP`, but not both.
770
+ */
771
+ topP?: number;
772
+ /**
773
+ Only sample from the top K options for each subsequent token.
774
+
775
+ Used to remove "long tail" low probability responses.
776
+ Recommended for advanced use cases only. You usually only need to use temperature.
777
+ */
778
+ topK?: number;
779
+ /**
780
+ Presence penalty setting. It affects the likelihood of the model to
781
+ repeat information that is already in the prompt.
782
+ */
783
+ presencePenalty?: number;
784
+ /**
785
+ Frequency penalty setting. It affects the likelihood of the model
786
+ to repeatedly use the same words or phrases.
787
+ */
788
+ frequencyPenalty?: number;
789
+ /**
790
+ Response format. The output can either be text or JSON. Default is text.
791
+
792
+ If JSON is selected, a schema can optionally be provided to guide the LLM.
793
+ */
794
+ responseFormat?: {
795
+ type: 'text';
796
+ } | {
797
+ type: 'json';
798
+ /**
799
+ * JSON schema that the generated output should conform to.
800
+ */
801
+ schema?: JSONSchema7;
802
+ /**
803
+ * Name of output that should be generated. Used by some providers for additional LLM guidance.
804
+ */
805
+ name?: string;
806
+ /**
807
+ * Description of the output that should be generated. Used by some providers for additional LLM guidance.
808
+ */
809
+ description?: string;
810
+ };
811
+ /**
812
+ The seed (integer) to use for random sampling. If set and supported
813
+ by the model, calls will generate deterministic results.
814
+ */
815
+ seed?: number;
816
+ /**
817
+ The tools that are available for the model.
818
+ */
819
+ tools?: Array<LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool>;
820
+ /**
821
+ Specifies how the tool should be selected. Defaults to 'auto'.
822
+ */
823
+ toolChoice?: LanguageModelV2ToolChoice;
824
+ /**
825
+ Abort signal for cancelling the operation.
826
+ */
827
+ abortSignal?: AbortSignal;
828
+ /**
829
+ Additional HTTP headers to be sent with the request.
830
+ Only applicable for HTTP-based providers.
831
+ */
832
+ headers?: Record<string, string | undefined>;
833
+ /**
834
+ * Additional provider-specific options. They are passed through
835
+ * to the provider from the AI SDK and enable provider-specific
836
+ * functionality that can be fully encapsulated in the provider.
837
+ */
838
+ providerOptions?: SharedV2ProviderOptions;
839
+ };
840
+
841
+ /**
842
+ Warning from the model provider for this call. The call will proceed, but e.g.
843
+ some settings might not be supported, which can lead to suboptimal results.
844
+ */
845
+ type LanguageModelV2CallWarning = {
846
+ type: 'unsupported-setting';
847
+ setting: Omit<keyof LanguageModelV2CallOptions, 'prompt'>;
848
+ details?: string;
849
+ } | {
850
+ type: 'unsupported-tool';
851
+ tool: LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool;
852
+ details?: string;
853
+ } | {
854
+ type: 'other';
855
+ message: string;
856
+ };
857
+
858
+ /**
859
+ A file that has been generated by the model.
860
+ Generated files as base64 encoded strings or binary data.
861
+ The files should be returned without any unnecessary conversion.
862
+ */
863
+ type LanguageModelV2File = {
864
+ type: 'file';
865
+ /**
866
+ The IANA media type of the file, e.g. `image/png` or `audio/mp3`.
867
+
868
+ @see https://www.iana.org/assignments/media-types/media-types.xhtml
869
+ */
870
+ mediaType: string;
871
+ /**
872
+ Generated file data as base64 encoded strings or binary data.
873
+
874
+ The file data should be returned without any unnecessary conversion.
875
+ If the API returns base64 encoded strings, the file data should be returned
876
+ as base64 encoded strings. If the API returns binary data, the file data should
877
+ be returned as binary data.
878
+ */
879
+ data: string | Uint8Array;
880
+ };
881
+
882
+ /**
883
+ Reasoning that the model has generated.
884
+ */
885
+ type LanguageModelV2Reasoning = {
886
+ type: 'reasoning';
887
+ text: string;
888
+ /**
889
+ * Optional provider-specific metadata for the reasoning part.
890
+ */
891
+ providerMetadata?: SharedV2ProviderMetadata;
892
+ };
893
+
894
+ /**
895
+ A source that has been used as input to generate the response.
896
+ */
897
+ type LanguageModelV2Source = {
898
+ type: 'source';
899
+ /**
900
+ * A URL source. This is return by web search RAG models.
901
+ */
902
+ sourceType: 'url';
903
+ /**
904
+ * The ID of the source.
905
+ */
906
+ id: string;
907
+ /**
908
+ * The URL of the source.
909
+ */
910
+ url: string;
911
+ /**
912
+ * The title of the source.
913
+ */
914
+ title?: string;
915
+ /**
916
+ * Additional provider metadata for the source.
917
+ */
918
+ providerMetadata?: SharedV2ProviderMetadata;
919
+ };
920
+
921
+ /**
922
+ Text that the model has generated.
923
+ */
924
+ type LanguageModelV2Text = {
925
+ type: 'text';
926
+ /**
927
+ The text content.
928
+ */
929
+ text: string;
930
+ };
931
+
932
+ /**
933
+ Tool calls that the model has generated.
934
+ */
935
+ type LanguageModelV2ToolCall = {
936
+ type: 'tool-call';
937
+ toolCallType: 'function';
938
+ toolCallId: string;
939
+ toolName: string;
940
+ /**
941
+ Stringified JSON object with the tool call arguments. Must match the
942
+ parameters schema of the tool.
943
+ */
944
+ args: string;
945
+ };
946
+
947
+ type LanguageModelV2Content = LanguageModelV2Text | LanguageModelV2Reasoning | LanguageModelV2File | LanguageModelV2Source | LanguageModelV2ToolCall;
948
+
949
+ /**
950
+ Reason why a language model finished generating a response.
951
+
952
+ Can be one of the following:
953
+ - `stop`: model generated stop sequence
954
+ - `length`: model generated maximum number of tokens
955
+ - `content-filter`: content filter violation stopped the model
956
+ - `tool-calls`: model triggered tool calls
957
+ - `error`: model stopped because of an error
958
+ - `other`: model stopped for other reasons
959
+ - `unknown`: the model has not transmitted a finish reason
960
+ */
961
+ type LanguageModelV2FinishReason = 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other' | 'unknown';
962
+
963
+ interface LanguageModelV2ResponseMetadata {
964
+ /**
965
+ ID for the generated response, if the provider sends one.
966
+ */
967
+ id?: string;
968
+ /**
969
+ Timestamp for the start of the generated response, if the provider sends one.
970
+ */
971
+ timestamp?: Date;
972
+ /**
973
+ The ID of the response model that was used to generate the response, if the provider sends one.
974
+ */
975
+ modelId?: string;
976
+ }
977
+
978
+ type LanguageModelV2ToolCallDelta = {
979
+ type: 'tool-call-delta';
980
+ toolCallType: 'function';
981
+ toolCallId: string;
982
+ toolName: string;
983
+ argsTextDelta: string;
984
+ };
985
+
986
+ /**
987
+ * Usage information for a language model call.
988
+ */
989
+ type LanguageModelV2Usage = {
990
+ /**
991
+ * The number of input (prompt) tokens used.
992
+ */
993
+ inputTokens: number | undefined;
994
+ /**
995
+ * The number of output (completion) tokens used.
996
+ */
997
+ outputTokens: number | undefined;
998
+ };
999
+
1000
+ type LanguageModelV2StreamPart = LanguageModelV2Content | {
1001
+ type: 'reasoning-part-finish';
1002
+ } | LanguageModelV2ToolCallDelta | {
1003
+ type: 'stream-start';
1004
+ warnings: Array<LanguageModelV2CallWarning>;
1005
+ } | ({
1006
+ type: 'response-metadata';
1007
+ } & LanguageModelV2ResponseMetadata) | {
1008
+ type: 'finish';
1009
+ usage: LanguageModelV2Usage;
1010
+ finishReason: LanguageModelV2FinishReason;
1011
+ providerMetadata?: SharedV2ProviderMetadata;
1012
+ } | {
1013
+ type: 'error';
1014
+ error: unknown;
1015
+ };
1016
+
1017
+ /**
1018
+ Specification for a language model that implements the language model interface version 2.
1019
+ */
1020
+ type LanguageModelV2 = {
1021
+ /**
1022
+ The language model must specify which language model interface
1023
+ version it implements. This will allow us to evolve the language
1024
+ model interface and retain backwards compatibility. The different
1025
+ implementation versions can be handled as a discriminated union
1026
+ on our side.
1027
+ */
1028
+ readonly specificationVersion: 'v2';
1029
+ /**
1030
+ Name of the provider for logging purposes.
1031
+ */
1032
+ readonly provider: string;
1033
+ /**
1034
+ Provider-specific model ID for logging purposes.
1035
+ */
1036
+ readonly modelId: string;
1037
+ /**
1038
+ * Returns a map of supported URL patterns for the model.
1039
+ * The keys are media type patterns or full media types (e.g. `*\/*` for everything, `audio/*`, `video/*`, or `application/pdf`).
1040
+ * and the values are arrays of regular expressions that match the URL paths.
1041
+ *
1042
+ * The matching should be against lower-case URLs.
1043
+ *
1044
+ * Matched URLs are supported natively by the model and are not downloaded.
1045
+ *
1046
+ * @returns A promise resolving to a map of supported URL patterns.
1047
+ */
1048
+ getSupportedUrls(): PromiseLike<Record<string, RegExp[]>>;
1049
+ /**
1050
+ Generates a language model output (non-streaming).
1051
+
1052
+ Naming: "do" prefix to prevent accidental direct usage of the method
1053
+ by the user.
1054
+ */
1055
+ doGenerate(options: LanguageModelV2CallOptions): PromiseLike<{
1056
+ /**
1057
+ Ordered content that the model has generated.
1058
+ */
1059
+ content: Array<LanguageModelV2Content>;
1060
+ /**
1061
+ Finish reason.
1062
+ */
1063
+ finishReason: LanguageModelV2FinishReason;
1064
+ /**
1065
+ Usage information.
1066
+ */
1067
+ usage: LanguageModelV2Usage;
1068
+ /**
1069
+ Additional provider-specific metadata. They are passed through
1070
+ from the provider to the AI SDK and enable provider-specific
1071
+ results that can be fully encapsulated in the provider.
1072
+ */
1073
+ providerMetadata?: SharedV2ProviderMetadata;
1074
+ /**
1075
+ Optional request information for telemetry and debugging purposes.
1076
+ */
1077
+ request?: {
1078
+ /**
1079
+ Request HTTP body that was sent to the provider API.
1080
+ */
1081
+ body?: unknown;
1082
+ };
1083
+ /**
1084
+ Optional response information for telemetry and debugging purposes.
1085
+ */
1086
+ response?: LanguageModelV2ResponseMetadata & {
1087
+ /**
1088
+ Response headers.
1089
+ */
1090
+ headers?: SharedV2Headers;
1091
+ /**
1092
+ Response HTTP body.
1093
+ */
1094
+ body?: unknown;
1095
+ };
1096
+ /**
1097
+ Warnings for the call, e.g. unsupported settings.
1098
+ */
1099
+ warnings: Array<LanguageModelV2CallWarning>;
1100
+ }>;
1101
+ /**
1102
+ Generates a language model output (streaming).
1103
+
1104
+ Naming: "do" prefix to prevent accidental direct usage of the method
1105
+ by the user.
1106
+ *
1107
+ @return A stream of higher-level language model output parts.
1108
+ */
1109
+ doStream(options: LanguageModelV2CallOptions): PromiseLike<{
1110
+ stream: ReadableStream<LanguageModelV2StreamPart>;
1111
+ /**
1112
+ Optional request information for telemetry and debugging purposes.
1113
+ */
1114
+ request?: {
1115
+ /**
1116
+ Request HTTP body that was sent to the provider API.
1117
+ */
1118
+ body?: unknown;
1119
+ };
1120
+ /**
1121
+ Optional response data.
1122
+ */
1123
+ response?: {
432
1124
  /**
433
1125
  Response headers.
434
- */
435
- headers: Record<string, string> | undefined;
1126
+ */
1127
+ headers?: SharedV2Headers;
436
1128
  };
437
1129
  }>;
438
1130
  };
439
1131
 
440
- declare function isJSONValue(value: unknown): value is JSONValue;
441
- declare function isJSONArray(value: unknown): value is JSONArray;
442
- declare function isJSONObject(value: unknown): value is JSONObject;
1132
+ /**
1133
+ * Experimental middleware for LanguageModelV2.
1134
+ * This type defines the structure for middleware that can be used to modify
1135
+ * the behavior of LanguageModelV2 operations.
1136
+ */
1137
+ type LanguageModelV2Middleware = {
1138
+ /**
1139
+ * Middleware specification version. Use `v2` for the current version.
1140
+ */
1141
+ middlewareVersion?: 'v2' | undefined;
1142
+ /**
1143
+ * Transforms the parameters before they are passed to the language model.
1144
+ * @param options - Object containing the type of operation and the parameters.
1145
+ * @param options.type - The type of operation ('generate' or 'stream').
1146
+ * @param options.params - The original parameters for the language model call.
1147
+ * @returns A promise that resolves to the transformed parameters.
1148
+ */
1149
+ transformParams?: (options: {
1150
+ type: 'generate' | 'stream';
1151
+ params: LanguageModelV2CallOptions;
1152
+ }) => PromiseLike<LanguageModelV2CallOptions>;
1153
+ /**
1154
+ * Wraps the generate operation of the language model.
1155
+ * @param options - Object containing the generate function, parameters, and model.
1156
+ * @param options.doGenerate - The original generate function.
1157
+ * @param options.doStream - The original stream function.
1158
+ * @param options.params - The parameters for the generate call. If the
1159
+ * `transformParams` middleware is used, this will be the transformed parameters.
1160
+ * @param options.model - The language model instance.
1161
+ * @returns A promise that resolves to the result of the generate operation.
1162
+ */
1163
+ wrapGenerate?: (options: {
1164
+ doGenerate: () => ReturnType<LanguageModelV2['doGenerate']>;
1165
+ doStream: () => ReturnType<LanguageModelV2['doStream']>;
1166
+ params: LanguageModelV2CallOptions;
1167
+ model: LanguageModelV2;
1168
+ }) => Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
1169
+ /**
1170
+ * Wraps the stream operation of the language model.
1171
+ *
1172
+ * @param options - Object containing the stream function, parameters, and model.
1173
+ * @param options.doGenerate - The original generate function.
1174
+ * @param options.doStream - The original stream function.
1175
+ * @param options.params - The parameters for the stream call. If the
1176
+ * `transformParams` middleware is used, this will be the transformed parameters.
1177
+ * @param options.model - The language model instance.
1178
+ * @returns A promise that resolves to the result of the stream operation.
1179
+ */
1180
+ wrapStream?: (options: {
1181
+ doGenerate: () => ReturnType<LanguageModelV2['doGenerate']>;
1182
+ doStream: () => ReturnType<LanguageModelV2['doStream']>;
1183
+ params: LanguageModelV2CallOptions;
1184
+ model: LanguageModelV2;
1185
+ }) => PromiseLike<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
1186
+ };
443
1187
 
444
1188
  /**
445
1189
  * Additional provider-specific metadata. They are passed through
@@ -1242,6 +1986,293 @@ represents no support for object generation.
1242
1986
  */
1243
1987
  type LanguageModelV1ObjectGenerationMode = 'json' | 'tool' | undefined;
1244
1988
 
1989
+ type TranscriptionModelV1ProviderOptions = Record<string, Record<string, JSONValue>>;
1990
+ type TranscriptionModelV1CallOptions = {
1991
+ /**
1992
+ Audio data to transcribe.
1993
+ Accepts a `Uint8Array` or `string`, where `string` is a base64 encoded audio file.
1994
+ */
1995
+ audio: Uint8Array | string;
1996
+ /**
1997
+ The IANA media type of the audio data.
1998
+
1999
+ @see https://www.iana.org/assignments/media-types/media-types.xhtml
2000
+ */
2001
+ mediaType: string;
2002
+ /**
2003
+ Additional provider-specific options that are passed through to the provider
2004
+ as body parameters.
2005
+
2006
+ The outer record is keyed by the provider name, and the inner
2007
+ record is keyed by the provider-specific metadata key.
2008
+ ```ts
2009
+ {
2010
+ "openai": {
2011
+ "timestampGranularities": ["word"]
2012
+ }
2013
+ }
2014
+ ```
2015
+ */
2016
+ providerOptions?: TranscriptionModelV1ProviderOptions;
2017
+ /**
2018
+ Abort signal for cancelling the operation.
2019
+ */
2020
+ abortSignal?: AbortSignal;
2021
+ /**
2022
+ Additional HTTP headers to be sent with the request.
2023
+ Only applicable for HTTP-based providers.
2024
+ */
2025
+ headers?: Record<string, string | undefined>;
2026
+ };
2027
+
2028
+ /**
2029
+ Warning from the model provider for this call. The call will proceed, but e.g.
2030
+ some settings might not be supported, which can lead to suboptimal results.
2031
+ */
2032
+ type TranscriptionModelV1CallWarning = {
2033
+ type: 'unsupported-setting';
2034
+ setting: keyof TranscriptionModelV1CallOptions;
2035
+ details?: string;
2036
+ } | {
2037
+ type: 'other';
2038
+ message: string;
2039
+ };
2040
+
2041
+ /**
2042
+ Transcription model specification version 1.
2043
+ */
2044
+ type TranscriptionModelV1 = {
2045
+ /**
2046
+ The transcription model must specify which transcription model interface
2047
+ version it implements. This will allow us to evolve the transcription
2048
+ model interface and retain backwards compatibility. The different
2049
+ implementation versions can be handled as a discriminated union
2050
+ on our side.
2051
+ */
2052
+ readonly specificationVersion: 'v1';
2053
+ /**
2054
+ Name of the provider for logging purposes.
2055
+ */
2056
+ readonly provider: string;
2057
+ /**
2058
+ Provider-specific model ID for logging purposes.
2059
+ */
2060
+ readonly modelId: string;
2061
+ /**
2062
+ Generates a transcript.
2063
+ */
2064
+ doGenerate(options: TranscriptionModelV1CallOptions): PromiseLike<{
2065
+ /**
2066
+ * The complete transcribed text from the audio.
2067
+ */
2068
+ text: string;
2069
+ /**
2070
+ * Array of transcript segments with timing information.
2071
+ * Each segment represents a portion of the transcribed text with start and end times.
2072
+ */
2073
+ segments: Array<{
2074
+ /**
2075
+ * The text content of this segment.
2076
+ */
2077
+ text: string;
2078
+ /**
2079
+ * The start time of this segment in seconds.
2080
+ */
2081
+ startSecond: number;
2082
+ /**
2083
+ * The end time of this segment in seconds.
2084
+ */
2085
+ endSecond: number;
2086
+ }>;
2087
+ /**
2088
+ * The detected language of the audio content, as an ISO-639-1 code (e.g., 'en' for English).
2089
+ * May be undefined if the language couldn't be detected.
2090
+ */
2091
+ language: string | undefined;
2092
+ /**
2093
+ * The total duration of the audio file in seconds.
2094
+ * May be undefined if the duration couldn't be determined.
2095
+ */
2096
+ durationInSeconds: number | undefined;
2097
+ /**
2098
+ Warnings for the call, e.g. unsupported settings.
2099
+ */
2100
+ warnings: Array<TranscriptionModelV1CallWarning>;
2101
+ /**
2102
+ Optional request information for telemetry and debugging purposes.
2103
+ */
2104
+ request?: {
2105
+ /**
2106
+ Raw request HTTP body that was sent to the provider API as a string (JSON should be stringified).
2107
+ Non-HTTP(s) providers should not set this.
2108
+ */
2109
+ body?: string;
2110
+ };
2111
+ /**
2112
+ Response information for telemetry and debugging purposes.
2113
+ */
2114
+ response: {
2115
+ /**
2116
+ Timestamp for the start of the generated response.
2117
+ */
2118
+ timestamp: Date;
2119
+ /**
2120
+ The ID of the response model that was used to generate the response.
2121
+ */
2122
+ modelId: string;
2123
+ /**
2124
+ Response headers.
2125
+ */
2126
+ headers?: SharedV2Headers;
2127
+ /**
2128
+ Response body.
2129
+ */
2130
+ body?: unknown;
2131
+ };
2132
+ /**
2133
+ Additional provider-specific metadata. They are passed through
2134
+ from the provider to the AI SDK and enable provider-specific
2135
+ results that can be fully encapsulated in the provider.
2136
+ */
2137
+ providerMetadata?: Record<string, Record<string, JSONValue>>;
2138
+ }>;
2139
+ };
2140
+
2141
+ type SpeechModelV1ProviderOptions = Record<string, Record<string, JSONValue>>;
2142
+ type SpeechModelV1CallOptions = {
2143
+ /**
2144
+ * Text to convert to speech.
2145
+ */
2146
+ text: string;
2147
+ /**
2148
+ * The voice to use for speech synthesis.
2149
+ * This is provider-specific and may be a voice ID, name, or other identifier.
2150
+ */
2151
+ voice?: string;
2152
+ /**
2153
+ * The desired output format for the audio e.g. "mp3", "wav", etc.
2154
+ */
2155
+ outputFormat?: string;
2156
+ /**
2157
+ * Instructions for the speech generation e.g. "Speak in a slow and steady tone".
2158
+ */
2159
+ instructions?: string;
2160
+ /**
2161
+ * The speed of the speech generation.
2162
+ */
2163
+ speed?: number;
2164
+ /**
2165
+ * Additional provider-specific options that are passed through to the provider
2166
+ * as body parameters.
2167
+ *
2168
+ * The outer record is keyed by the provider name, and the inner
2169
+ * record is keyed by the provider-specific metadata key.
2170
+ * ```ts
2171
+ * {
2172
+ * "openai": {}
2173
+ * }
2174
+ * ```
2175
+ */
2176
+ providerOptions?: SpeechModelV1ProviderOptions;
2177
+ /**
2178
+ * Abort signal for cancelling the operation.
2179
+ */
2180
+ abortSignal?: AbortSignal;
2181
+ /**
2182
+ * Additional HTTP headers to be sent with the request.
2183
+ * Only applicable for HTTP-based providers.
2184
+ */
2185
+ headers?: Record<string, string | undefined>;
2186
+ };
2187
+
2188
+ /**
2189
+ * Warning from the model provider for this call. The call will proceed, but e.g.
2190
+ * some settings might not be supported, which can lead to suboptimal results.
2191
+ */
2192
+ type SpeechModelV1CallWarning = {
2193
+ type: 'unsupported-setting';
2194
+ setting: keyof SpeechModelV1CallOptions;
2195
+ details?: string;
2196
+ } | {
2197
+ type: 'other';
2198
+ message: string;
2199
+ };
2200
+
2201
+ /**
2202
+ * Speech model specification version 1.
2203
+ */
2204
+ type SpeechModelV1 = {
2205
+ /**
2206
+ * The speech model must specify which speech model interface
2207
+ * version it implements. This will allow us to evolve the speech
2208
+ * model interface and retain backwards compatibility. The different
2209
+ * implementation versions can be handled as a discriminated union
2210
+ * on our side.
2211
+ */
2212
+ readonly specificationVersion: 'v1';
2213
+ /**
2214
+ * Name of the provider for logging purposes.
2215
+ */
2216
+ readonly provider: string;
2217
+ /**
2218
+ * Provider-specific model ID for logging purposes.
2219
+ */
2220
+ readonly modelId: string;
2221
+ /**
2222
+ * Generates speech audio from text.
2223
+ */
2224
+ doGenerate(options: SpeechModelV1CallOptions): PromiseLike<{
2225
+ /**
2226
+ * Generated audio as an ArrayBuffer.
2227
+ * The audio should be returned without any unnecessary conversion.
2228
+ * If the API returns base64 encoded strings, the audio should be returned
2229
+ * as base64 encoded strings. If the API returns binary data, the audio
2230
+ * should be returned as binary data.
2231
+ */
2232
+ audio: string | Uint8Array;
2233
+ /**
2234
+ * Warnings for the call, e.g. unsupported settings.
2235
+ */
2236
+ warnings: Array<SpeechModelV1CallWarning>;
2237
+ /**
2238
+ * Optional request information for telemetry and debugging purposes.
2239
+ */
2240
+ request?: {
2241
+ /**
2242
+ * Response body (available only for providers that use HTTP requests).
2243
+ */
2244
+ body?: unknown;
2245
+ };
2246
+ /**
2247
+ * Response information for telemetry and debugging purposes.
2248
+ */
2249
+ response: {
2250
+ /**
2251
+ * Timestamp for the start of the generated response.
2252
+ */
2253
+ timestamp: Date;
2254
+ /**
2255
+ * The ID of the response model that was used to generate the response.
2256
+ */
2257
+ modelId: string;
2258
+ /**
2259
+ * Response headers.
2260
+ */
2261
+ headers?: SharedV2Headers;
2262
+ /**
2263
+ * Response body.
2264
+ */
2265
+ body?: unknown;
2266
+ };
2267
+ /**
2268
+ * Additional provider-specific metadata. They are passed through
2269
+ * from the provider to the AI SDK and enable provider-specific
2270
+ * results that can be fully encapsulated in the provider.
2271
+ */
2272
+ providerMetadata?: Record<string, Record<string, JSONValue>>;
2273
+ }>;
2274
+ };
2275
+
1245
2276
  /**
1246
2277
  * Provider for language, text embedding, and image generation models.
1247
2278
  */
@@ -1267,7 +2298,62 @@ interface ProviderV1 {
1267
2298
 
1268
2299
  @throws {NoSuchModelError} If no such model exists.
1269
2300
  */
1270
- textEmbeddingModel(modelId: string): EmbeddingModelV1<string>;
2301
+ textEmbeddingModel(modelId: string): EmbeddingModelV2<string>;
2302
+ /**
2303
+ Returns the image model with the given id.
2304
+ The model id is then passed to the provider function to get the model.
2305
+
2306
+ @param {string} modelId - The id of the model to return.
2307
+
2308
+ @returns {ImageModel} The image model associated with the id
2309
+ */
2310
+ readonly imageModel?: (modelId: string) => ImageModelV2;
2311
+ /**
2312
+ Returns the transcription model with the given id.
2313
+ The model id is then passed to the provider function to get the model.
2314
+
2315
+ @param {string} modelId - The id of the model to return.
2316
+
2317
+ @returns {TranscriptionModel} The transcription model associated with the id
2318
+ */
2319
+ readonly transcriptionModel?: (modelId: string) => TranscriptionModelV1;
2320
+ /**
2321
+ Returns the speech model with the given id.
2322
+ The model id is then passed to the provider function to get the model.
2323
+
2324
+ @param {string} modelId - The id of the model to return.
2325
+
2326
+ @returns {SpeechModel} The speech model associated with the id
2327
+ */
2328
+ readonly speechModel?: (modelId: string) => SpeechModelV1;
2329
+ }
2330
+
2331
+ /**
2332
+ * Provider for language, text embedding, and image generation models.
2333
+ */
2334
+ interface ProviderV2 {
2335
+ /**
2336
+ Returns the language model with the given id.
2337
+ The model id is then passed to the provider function to get the model.
2338
+
2339
+ @param {string} modelId - The id of the model to return.
2340
+
2341
+ @returns {LanguageModel} The language model associated with the id
2342
+
2343
+ @throws {NoSuchModelError} If no such model exists.
2344
+ */
2345
+ languageModel(modelId: string): LanguageModelV2;
2346
+ /**
2347
+ Returns the text embedding model with the given id.
2348
+ The model id is then passed to the provider function to get the model.
2349
+
2350
+ @param {string} modelId - The id of the model to return.
2351
+
2352
+ @returns {LanguageModel} The language model associated with the id
2353
+
2354
+ @throws {NoSuchModelError} If no such model exists.
2355
+ */
2356
+ textEmbeddingModel(modelId: string): EmbeddingModelV2<string>;
1271
2357
  /**
1272
2358
  Returns the image model with the given id.
1273
2359
  The model id is then passed to the provider function to get the model.
@@ -1276,7 +2362,7 @@ interface ProviderV1 {
1276
2362
 
1277
2363
  @returns {ImageModel} The image model associated with the id
1278
2364
  */
1279
- readonly imageModel?: (modelId: string) => ImageModelV1;
2365
+ readonly imageModel: (modelId: string) => ImageModelV2;
1280
2366
  }
1281
2367
 
1282
- export { AISDKError, APICallError, type EmbeddingModelV1, type EmbeddingModelV1Embedding, 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, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV1, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };
2368
+ export { AISDKError, APICallError, type EmbeddingModelV2, type EmbeddingModelV2Embedding, EmptyResponseBodyError, type ImageModelV2, type ImageModelV2CallOptions, type ImageModelV2CallWarning, InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV1, type LanguageModelV1CallOptions, type LanguageModelV1CallWarning, type LanguageModelV1FilePart, type LanguageModelV1FinishReason, type LanguageModelV1FunctionTool, type LanguageModelV1FunctionToolCall, type LanguageModelV1ImagePart, type LanguageModelV1LogProbs, type LanguageModelV1Message, type LanguageModelV1ObjectGenerationMode, type LanguageModelV1Prompt, type LanguageModelV1ProviderDefinedTool, type LanguageModelV1ProviderMetadata, type LanguageModelV1ReasoningPart, type LanguageModelV1RedactedReasoningPart, type LanguageModelV1Source, type LanguageModelV1StreamPart, type LanguageModelV1TextPart, type LanguageModelV1ToolCallPart, type LanguageModelV1ToolChoice, type LanguageModelV1ToolResultPart, type LanguageModelV2, type LanguageModelV2CallOptions, type LanguageModelV2CallWarning, type LanguageModelV2Content, type LanguageModelV2DataContent, type LanguageModelV2File, type LanguageModelV2FilePart, type LanguageModelV2FinishReason, type LanguageModelV2FunctionTool, type LanguageModelV2Message, type LanguageModelV2Middleware, type LanguageModelV2Prompt, type LanguageModelV2ProviderDefinedTool, type LanguageModelV2Reasoning, type LanguageModelV2ReasoningPart, type LanguageModelV2ResponseMetadata, type LanguageModelV2Source, type LanguageModelV2StreamPart, type LanguageModelV2Text, type LanguageModelV2TextPart, type LanguageModelV2ToolCall, type LanguageModelV2ToolCallDelta, type LanguageModelV2ToolCallPart, type LanguageModelV2ToolChoice, type LanguageModelV2ToolResultPart, type LanguageModelV2Usage, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV1, type ProviderV2, type SharedV2Headers, type SharedV2ProviderMetadata, type SharedV2ProviderOptions, type SpeechModelV1, type SpeechModelV1CallOptions, type SpeechModelV1CallWarning, TooManyEmbeddingValuesForCallError, type TranscriptionModelV1, type TranscriptionModelV1CallOptions, type TranscriptionModelV1CallWarning, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };