@ai-sdk/provider 3.0.8 → 4.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.mts +2710 -436
- package/dist/index.d.ts +2710 -436
- package/package.json +1 -1
- package/src/embedding-model/index.ts +1 -0
- package/src/embedding-model/v4/embedding-model-v4-call-options.ts +26 -0
- package/src/embedding-model/v4/embedding-model-v4-embedding.ts +5 -0
- package/src/embedding-model/v4/embedding-model-v4-result.ts +48 -0
- package/src/embedding-model/v4/embedding-model-v4.ts +54 -0
- package/src/embedding-model/v4/index.ts +4 -0
- package/src/embedding-model-middleware/index.ts +1 -0
- package/src/embedding-model-middleware/v4/embedding-model-v4-middleware.ts +69 -0
- package/src/embedding-model-middleware/v4/index.ts +1 -0
- package/src/image-model/index.ts +1 -0
- package/src/image-model/v4/image-model-v4-call-options.ts +74 -0
- package/src/image-model/v4/image-model-v4-file.ts +44 -0
- package/src/image-model/v4/image-model-v4-usage.ts +19 -0
- package/src/image-model/v4/image-model-v4.ts +110 -0
- package/src/image-model/v4/index.ts +7 -0
- package/src/image-model-middleware/index.ts +1 -0
- package/src/image-model-middleware/v4/image-model-v4-middleware.ts +61 -0
- package/src/image-model-middleware/v4/index.ts +1 -0
- package/src/language-model/index.ts +1 -0
- package/src/language-model/v4/index.ts +21 -0
- package/src/language-model/v4/language-model-v4-call-options.ts +125 -0
- package/src/language-model/v4/language-model-v4-content.ts +16 -0
- package/src/language-model/v4/language-model-v4-data-content.ts +4 -0
- package/src/language-model/v4/language-model-v4-file.ts +32 -0
- package/src/language-model/v4/language-model-v4-finish-reason.ts +33 -0
- package/src/language-model/v4/language-model-v4-function-tool.ts +53 -0
- package/src/language-model/v4/language-model-v4-generate-result.ts +63 -0
- package/src/language-model/v4/language-model-v4-prompt.ts +422 -0
- package/src/language-model/v4/language-model-v4-provider-tool.ts +28 -0
- package/src/language-model/v4/language-model-v4-reasoning.ts +14 -0
- package/src/language-model/v4/language-model-v4-response-metadata.ts +16 -0
- package/src/language-model/v4/language-model-v4-source.ts +67 -0
- package/src/language-model/v4/language-model-v4-stream-part.ts +106 -0
- package/src/language-model/v4/language-model-v4-stream-result.ts +32 -0
- package/src/language-model/v4/language-model-v4-text.ts +15 -0
- package/src/language-model/v4/language-model-v4-tool-approval-request.ts +27 -0
- package/src/language-model/v4/language-model-v4-tool-call.ts +41 -0
- package/src/language-model/v4/language-model-v4-tool-choice.ts +5 -0
- package/src/language-model/v4/language-model-v4-tool-result.ts +51 -0
- package/src/language-model/v4/language-model-v4-usage.ts +59 -0
- package/src/language-model/v4/language-model-v4.ts +61 -0
- package/src/language-model-middleware/index.ts +1 -0
- package/src/language-model-middleware/v4/index.ts +1 -0
- package/src/language-model-middleware/v4/language-model-v4-middleware.ts +84 -0
- package/src/provider/index.ts +1 -0
- package/src/provider/v4/index.ts +1 -0
- package/src/provider/v4/provider-v4.ts +79 -0
- package/src/reranking-model/index.ts +1 -0
- package/src/reranking-model/v4/index.ts +2 -0
- package/src/reranking-model/v4/reranking-model-v4-call-options.ts +40 -0
- package/src/reranking-model/v4/reranking-model-v4.ts +90 -0
- package/src/shared/index.ts +1 -0
- package/src/shared/v4/index.ts +4 -0
- package/src/shared/v4/shared-v4-headers.ts +1 -0
- package/src/shared/v4/shared-v4-provider-metadata.ts +24 -0
- package/src/shared/v4/shared-v4-provider-options.ts +24 -0
- package/src/shared/v4/shared-v4-warning.ts +50 -0
- package/src/speech-model/index.ts +2 -1
- package/src/speech-model/v4/index.ts +2 -0
- package/src/speech-model/v4/speech-model-v4-call-options.ts +62 -0
- package/src/speech-model/v4/speech-model-v4.ts +89 -0
- package/src/transcription-model/index.ts +2 -1
- package/src/transcription-model/v4/index.ts +2 -0
- package/src/transcription-model/v4/transcription-model-v4-call-options.ts +45 -0
- package/src/transcription-model/v4/transcription-model-v4.ts +117 -0
- package/src/video-model/index.ts +1 -0
- package/src/video-model/v4/index.ts +6 -0
- package/src/video-model/v4/video-model-v4-call-options.ts +81 -0
- package/src/video-model/v4/video-model-v4-file.ts +40 -0
- package/src/video-model/v4/video-model-v4.ts +132 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { JSONSchema7 } from 'json-schema';
|
|
2
2
|
export { JSONSchema7, JSONSchema7Definition } from 'json-schema';
|
|
3
3
|
|
|
4
|
-
type
|
|
4
|
+
type SharedV4Headers = Record<string, string>;
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* A JSON value can be a string, number, boolean, object, array, or null.
|
|
@@ -13,6 +13,97 @@ type JSONObject = {
|
|
|
13
13
|
};
|
|
14
14
|
type JSONArray = JSONValue[];
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Additional provider-specific metadata.
|
|
18
|
+
* Metadata are additional outputs from the provider.
|
|
19
|
+
* They are passed through to the provider from the AI SDK
|
|
20
|
+
* and enable provider-specific functionality
|
|
21
|
+
* that can be fully encapsulated in the provider.
|
|
22
|
+
*
|
|
23
|
+
* This enables us to quickly ship provider-specific functionality
|
|
24
|
+
* without affecting the core AI SDK.
|
|
25
|
+
*
|
|
26
|
+
* The outer record is keyed by the provider name, and the inner
|
|
27
|
+
* record is keyed by the provider-specific metadata key.
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* {
|
|
31
|
+
* "anthropic": {
|
|
32
|
+
* "cacheControl": { "type": "ephemeral" }
|
|
33
|
+
* }
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
type SharedV4ProviderMetadata = Record<string, JSONObject>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Additional provider-specific options.
|
|
41
|
+
* Options are additional input to the provider.
|
|
42
|
+
* They are passed through to the provider from the AI SDK
|
|
43
|
+
* and enable provider-specific functionality
|
|
44
|
+
* that can be fully encapsulated in the provider.
|
|
45
|
+
*
|
|
46
|
+
* This enables us to quickly ship provider-specific functionality
|
|
47
|
+
* without affecting the core AI SDK.
|
|
48
|
+
*
|
|
49
|
+
* The outer record is keyed by the provider name, and the inner
|
|
50
|
+
* record is keyed by the provider-specific metadata key.
|
|
51
|
+
*
|
|
52
|
+
* ```ts
|
|
53
|
+
* {
|
|
54
|
+
* "anthropic": {
|
|
55
|
+
* "cacheControl": { "type": "ephemeral" }
|
|
56
|
+
* }
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
type SharedV4ProviderOptions = Record<string, JSONObject>;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Warning from the model.
|
|
64
|
+
*
|
|
65
|
+
* For example, that certain features are unsupported or compatibility
|
|
66
|
+
* functionality is used (which might lead to suboptimal results).
|
|
67
|
+
*/
|
|
68
|
+
type SharedV4Warning = {
|
|
69
|
+
/**
|
|
70
|
+
* A feature is not supported by the model.
|
|
71
|
+
*/
|
|
72
|
+
type: 'unsupported';
|
|
73
|
+
/**
|
|
74
|
+
* The feature that is not supported.
|
|
75
|
+
*/
|
|
76
|
+
feature: string;
|
|
77
|
+
/**
|
|
78
|
+
* Additional details about the warning.
|
|
79
|
+
*/
|
|
80
|
+
details?: string;
|
|
81
|
+
} | {
|
|
82
|
+
/**
|
|
83
|
+
* A compatibility feature is used that might lead to suboptimal results.
|
|
84
|
+
*/
|
|
85
|
+
type: 'compatibility';
|
|
86
|
+
/**
|
|
87
|
+
* The feature that is used in a compatibility mode.
|
|
88
|
+
*/
|
|
89
|
+
feature: string;
|
|
90
|
+
/**
|
|
91
|
+
* Additional details about the warning.
|
|
92
|
+
*/
|
|
93
|
+
details?: string;
|
|
94
|
+
} | {
|
|
95
|
+
/**
|
|
96
|
+
* Other warning.
|
|
97
|
+
*/
|
|
98
|
+
type: 'other';
|
|
99
|
+
/**
|
|
100
|
+
* The message of the warning.
|
|
101
|
+
*/
|
|
102
|
+
message: string;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
type SharedV3Headers = Record<string, string>;
|
|
106
|
+
|
|
16
107
|
/**
|
|
17
108
|
* Additional provider-specific metadata.
|
|
18
109
|
* Metadata are additional outputs from the provider.
|
|
@@ -150,6 +241,115 @@ type SharedV2ProviderMetadata = Record<string, Record<string, JSONValue>>;
|
|
|
150
241
|
*/
|
|
151
242
|
type SharedV2ProviderOptions = Record<string, Record<string, JSONValue>>;
|
|
152
243
|
|
|
244
|
+
type EmbeddingModelV4CallOptions = {
|
|
245
|
+
/**
|
|
246
|
+
* List of text values to generate embeddings for.
|
|
247
|
+
*/
|
|
248
|
+
values: Array<string>;
|
|
249
|
+
/**
|
|
250
|
+
* Abort signal for cancelling the operation.
|
|
251
|
+
*/
|
|
252
|
+
abortSignal?: AbortSignal;
|
|
253
|
+
/**
|
|
254
|
+
* Additional provider-specific options. They are passed through
|
|
255
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
256
|
+
* functionality that can be fully encapsulated in the provider.
|
|
257
|
+
*/
|
|
258
|
+
providerOptions?: SharedV4ProviderOptions;
|
|
259
|
+
/**
|
|
260
|
+
* Additional HTTP headers to be sent with the request.
|
|
261
|
+
* Only applicable for HTTP-based providers.
|
|
262
|
+
*/
|
|
263
|
+
headers?: SharedV4Headers;
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* An embedding is a vector, i.e. an array of numbers.
|
|
268
|
+
* It is e.g. used to represent a text as a vector of word embeddings.
|
|
269
|
+
*/
|
|
270
|
+
type EmbeddingModelV4Embedding = Array<number>;
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* The result of a embedding model doEmbed call.
|
|
274
|
+
*/
|
|
275
|
+
type EmbeddingModelV4Result = {
|
|
276
|
+
/**
|
|
277
|
+
* Generated embeddings. They are in the same order as the input values.
|
|
278
|
+
*/
|
|
279
|
+
embeddings: Array<EmbeddingModelV4Embedding>;
|
|
280
|
+
/**
|
|
281
|
+
* Token usage. We only have input tokens for embeddings.
|
|
282
|
+
*/
|
|
283
|
+
usage?: {
|
|
284
|
+
tokens: number;
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* Additional provider-specific metadata. They are passed through
|
|
288
|
+
* from the provider to the AI SDK and enable provider-specific
|
|
289
|
+
* results that can be fully encapsulated in the provider.
|
|
290
|
+
*/
|
|
291
|
+
providerMetadata?: SharedV4ProviderMetadata;
|
|
292
|
+
/**
|
|
293
|
+
* Optional response information for debugging purposes.
|
|
294
|
+
*/
|
|
295
|
+
response?: {
|
|
296
|
+
/**
|
|
297
|
+
* Response headers.
|
|
298
|
+
*/
|
|
299
|
+
headers?: SharedV4Headers;
|
|
300
|
+
/**
|
|
301
|
+
* The response body.
|
|
302
|
+
*/
|
|
303
|
+
body?: unknown;
|
|
304
|
+
};
|
|
305
|
+
/**
|
|
306
|
+
* Warnings for the call, e.g. unsupported settings.
|
|
307
|
+
*/
|
|
308
|
+
warnings: Array<SharedV4Warning>;
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Specification for an embedding model that implements the embedding model
|
|
313
|
+
* interface version 3.
|
|
314
|
+
*
|
|
315
|
+
* It is specific to text embeddings.
|
|
316
|
+
*/
|
|
317
|
+
type EmbeddingModelV4 = {
|
|
318
|
+
/**
|
|
319
|
+
* The embedding model must specify which embedding model interface
|
|
320
|
+
* version it implements. This will allow us to evolve the embedding
|
|
321
|
+
* model interface and retain backwards compatibility. The different
|
|
322
|
+
* implementation versions can be handled as a discriminated union
|
|
323
|
+
* on our side.
|
|
324
|
+
*/
|
|
325
|
+
readonly specificationVersion: 'v4';
|
|
326
|
+
/**
|
|
327
|
+
* Name of the provider for logging purposes.
|
|
328
|
+
*/
|
|
329
|
+
readonly provider: string;
|
|
330
|
+
/**
|
|
331
|
+
* Provider-specific model ID for logging purposes.
|
|
332
|
+
*/
|
|
333
|
+
readonly modelId: string;
|
|
334
|
+
/**
|
|
335
|
+
* Limit of how many embeddings can be generated in a single API call.
|
|
336
|
+
*
|
|
337
|
+
* Use Infinity for models that do not have a limit.
|
|
338
|
+
*/
|
|
339
|
+
readonly maxEmbeddingsPerCall: PromiseLike<number | undefined> | number | undefined;
|
|
340
|
+
/**
|
|
341
|
+
* True if the model can handle multiple embedding calls in parallel.
|
|
342
|
+
*/
|
|
343
|
+
readonly supportsParallelCalls: PromiseLike<boolean> | boolean;
|
|
344
|
+
/**
|
|
345
|
+
* Generates a list of embeddings for the given input text.
|
|
346
|
+
*
|
|
347
|
+
* Naming: "do" prefix to prevent accidental direct usage of the method
|
|
348
|
+
* by the user.
|
|
349
|
+
*/
|
|
350
|
+
doEmbed(options: EmbeddingModelV4CallOptions): PromiseLike<EmbeddingModelV4Result>;
|
|
351
|
+
};
|
|
352
|
+
|
|
153
353
|
type EmbeddingModelV3CallOptions = {
|
|
154
354
|
/**
|
|
155
355
|
* List of text values to generate embeddings for.
|
|
@@ -606,7 +806,7 @@ declare function isJSONObject(value: unknown): value is JSONObject;
|
|
|
606
806
|
/**
|
|
607
807
|
* Usage information for an image model call.
|
|
608
808
|
*/
|
|
609
|
-
type
|
|
809
|
+
type ImageModelV4Usage = {
|
|
610
810
|
/**
|
|
611
811
|
* The number of input (prompt) tokens used.
|
|
612
812
|
*/
|
|
@@ -624,7 +824,7 @@ type ImageModelV3Usage = {
|
|
|
624
824
|
/**
|
|
625
825
|
* An image file that can be used for image editing or variation generation.
|
|
626
826
|
*/
|
|
627
|
-
type
|
|
827
|
+
type ImageModelV4File = {
|
|
628
828
|
type: 'file';
|
|
629
829
|
/**
|
|
630
830
|
* The IANA media type of the file, e.g. `image/png`. Any string is supported.
|
|
@@ -644,7 +844,7 @@ type ImageModelV3File = {
|
|
|
644
844
|
/**
|
|
645
845
|
* Optional provider-specific metadata for the file part.
|
|
646
846
|
*/
|
|
647
|
-
providerOptions?:
|
|
847
|
+
providerOptions?: SharedV4ProviderMetadata;
|
|
648
848
|
} | {
|
|
649
849
|
type: 'url';
|
|
650
850
|
/**
|
|
@@ -654,10 +854,10 @@ type ImageModelV3File = {
|
|
|
654
854
|
/**
|
|
655
855
|
* Optional provider-specific metadata for the file part.
|
|
656
856
|
*/
|
|
657
|
-
providerOptions?:
|
|
857
|
+
providerOptions?: SharedV4ProviderMetadata;
|
|
658
858
|
};
|
|
659
859
|
|
|
660
|
-
type
|
|
860
|
+
type ImageModelV4CallOptions = {
|
|
661
861
|
/**
|
|
662
862
|
* Prompt for the image generation. Some operations, like upscaling, may not require a prompt.
|
|
663
863
|
*/
|
|
@@ -687,12 +887,12 @@ type ImageModelV3CallOptions = {
|
|
|
687
887
|
* Array of images for image editing or variation generation.
|
|
688
888
|
* The images should be provided as base64 encoded strings or binary data.
|
|
689
889
|
*/
|
|
690
|
-
files:
|
|
890
|
+
files: ImageModelV4File[] | undefined;
|
|
691
891
|
/**
|
|
692
892
|
* Mask image for inpainting operations.
|
|
693
893
|
* The mask should be provided as base64 encoded strings or binary data.
|
|
694
894
|
*/
|
|
695
|
-
mask:
|
|
895
|
+
mask: ImageModelV4File | undefined;
|
|
696
896
|
/**
|
|
697
897
|
* Additional provider-specific options that are passed through to the provider
|
|
698
898
|
* as body parameters.
|
|
@@ -708,7 +908,7 @@ type ImageModelV3CallOptions = {
|
|
|
708
908
|
* }
|
|
709
909
|
* ```
|
|
710
910
|
*/
|
|
711
|
-
providerOptions:
|
|
911
|
+
providerOptions: SharedV4ProviderOptions;
|
|
712
912
|
/**
|
|
713
913
|
* Abort signal for cancelling the operation.
|
|
714
914
|
*/
|
|
@@ -720,16 +920,16 @@ type ImageModelV3CallOptions = {
|
|
|
720
920
|
headers?: Record<string, string | undefined>;
|
|
721
921
|
};
|
|
722
922
|
|
|
723
|
-
type
|
|
923
|
+
type ImageModelV4ProviderMetadata = Record<string, {
|
|
724
924
|
images: JSONArray;
|
|
725
925
|
} & JSONValue>;
|
|
726
|
-
type GetMaxImagesPerCallFunction$
|
|
926
|
+
type GetMaxImagesPerCallFunction$2 = (options: {
|
|
727
927
|
modelId: string;
|
|
728
928
|
}) => PromiseLike<number | undefined> | number | undefined;
|
|
729
929
|
/**
|
|
730
930
|
* Image generation model specification version 3.
|
|
731
931
|
*/
|
|
732
|
-
type
|
|
932
|
+
type ImageModelV4 = {
|
|
733
933
|
/**
|
|
734
934
|
* The image model must specify which image model interface
|
|
735
935
|
* version it implements. This will allow us to evolve the image
|
|
@@ -737,7 +937,7 @@ type ImageModelV3 = {
|
|
|
737
937
|
* implementation versions can be handled as a discriminated union
|
|
738
938
|
* on our side.
|
|
739
939
|
*/
|
|
740
|
-
readonly specificationVersion: '
|
|
940
|
+
readonly specificationVersion: 'v4';
|
|
741
941
|
/**
|
|
742
942
|
* Name of the provider for logging purposes.
|
|
743
943
|
*/
|
|
@@ -752,11 +952,11 @@ type ImageModelV3 = {
|
|
|
752
952
|
* the global limit, or a function that returns a number or undefined,
|
|
753
953
|
* optionally as a promise.
|
|
754
954
|
*/
|
|
755
|
-
readonly maxImagesPerCall: number | undefined | GetMaxImagesPerCallFunction$
|
|
955
|
+
readonly maxImagesPerCall: number | undefined | GetMaxImagesPerCallFunction$2;
|
|
756
956
|
/**
|
|
757
957
|
* Generates an array of images.
|
|
758
958
|
*/
|
|
759
|
-
doGenerate(options:
|
|
959
|
+
doGenerate(options: ImageModelV4CallOptions): PromiseLike<{
|
|
760
960
|
/**
|
|
761
961
|
* Generated images as base64 encoded strings or binary data.
|
|
762
962
|
* The images should be returned without any unnecessary conversion.
|
|
@@ -768,7 +968,7 @@ type ImageModelV3 = {
|
|
|
768
968
|
/**
|
|
769
969
|
* Warnings for the call, e.g. unsupported features.
|
|
770
970
|
*/
|
|
771
|
-
warnings: Array<
|
|
971
|
+
warnings: Array<SharedV4Warning>;
|
|
772
972
|
/**
|
|
773
973
|
* Additional provider-specific metadata. They are passed through
|
|
774
974
|
* from the provider to the AI SDK and enable provider-specific
|
|
@@ -786,7 +986,7 @@ type ImageModelV3 = {
|
|
|
786
986
|
* }
|
|
787
987
|
* ```
|
|
788
988
|
*/
|
|
789
|
-
providerMetadata?:
|
|
989
|
+
providerMetadata?: ImageModelV4ProviderMetadata;
|
|
790
990
|
/**
|
|
791
991
|
* Response information for telemetry and debugging purposes.
|
|
792
992
|
*/
|
|
@@ -807,46 +1007,254 @@ type ImageModelV3 = {
|
|
|
807
1007
|
/**
|
|
808
1008
|
* Optional token usage for the image generation call (if the provider reports it).
|
|
809
1009
|
*/
|
|
810
|
-
usage?:
|
|
1010
|
+
usage?: ImageModelV4Usage;
|
|
811
1011
|
}>;
|
|
812
1012
|
};
|
|
813
1013
|
|
|
814
|
-
|
|
1014
|
+
/**
|
|
1015
|
+
* Usage information for an image model call.
|
|
1016
|
+
*/
|
|
1017
|
+
type ImageModelV3Usage = {
|
|
815
1018
|
/**
|
|
816
|
-
*
|
|
1019
|
+
* The number of input (prompt) tokens used.
|
|
817
1020
|
*/
|
|
818
|
-
|
|
1021
|
+
inputTokens: number | undefined;
|
|
819
1022
|
/**
|
|
820
|
-
*
|
|
1023
|
+
* The number of output tokens used, if reported by the provider.
|
|
821
1024
|
*/
|
|
822
|
-
|
|
1025
|
+
outputTokens: number | undefined;
|
|
823
1026
|
/**
|
|
824
|
-
*
|
|
825
|
-
* Must have the format `{width}x{height}`.
|
|
826
|
-
* `undefined` will use the provider's default size.
|
|
1027
|
+
* The total number of tokens as reported by the provider.
|
|
827
1028
|
*/
|
|
828
|
-
|
|
1029
|
+
totalTokens: number | undefined;
|
|
1030
|
+
};
|
|
1031
|
+
|
|
1032
|
+
/**
|
|
1033
|
+
* An image file that can be used for image editing or variation generation.
|
|
1034
|
+
*/
|
|
1035
|
+
type ImageModelV3File = {
|
|
1036
|
+
type: 'file';
|
|
829
1037
|
/**
|
|
830
|
-
*
|
|
831
|
-
*
|
|
832
|
-
*
|
|
1038
|
+
* The IANA media type of the file, e.g. `image/png`. Any string is supported.
|
|
1039
|
+
*
|
|
1040
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
833
1041
|
*/
|
|
834
|
-
|
|
1042
|
+
mediaType: string;
|
|
835
1043
|
/**
|
|
836
|
-
*
|
|
837
|
-
*
|
|
1044
|
+
* Generated file data as base64 encoded strings or binary data.
|
|
1045
|
+
*
|
|
1046
|
+
* The file data should be returned without any unnecessary conversion.
|
|
1047
|
+
* If the API returns base64 encoded strings, the file data should be returned
|
|
1048
|
+
* as base64 encoded strings. If the API returns binary data, the file data should
|
|
1049
|
+
* be returned as binary data.
|
|
838
1050
|
*/
|
|
839
|
-
|
|
1051
|
+
data: string | Uint8Array;
|
|
840
1052
|
/**
|
|
841
|
-
*
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
*
|
|
848
|
-
|
|
849
|
-
|
|
1053
|
+
* Optional provider-specific metadata for the file part.
|
|
1054
|
+
*/
|
|
1055
|
+
providerOptions?: SharedV3ProviderMetadata;
|
|
1056
|
+
} | {
|
|
1057
|
+
type: 'url';
|
|
1058
|
+
/**
|
|
1059
|
+
* The URL of the image file.
|
|
1060
|
+
*/
|
|
1061
|
+
url: string;
|
|
1062
|
+
/**
|
|
1063
|
+
* Optional provider-specific metadata for the file part.
|
|
1064
|
+
*/
|
|
1065
|
+
providerOptions?: SharedV3ProviderMetadata;
|
|
1066
|
+
};
|
|
1067
|
+
|
|
1068
|
+
type ImageModelV3CallOptions = {
|
|
1069
|
+
/**
|
|
1070
|
+
* Prompt for the image generation. Some operations, like upscaling, may not require a prompt.
|
|
1071
|
+
*/
|
|
1072
|
+
prompt: string | undefined;
|
|
1073
|
+
/**
|
|
1074
|
+
* Number of images to generate.
|
|
1075
|
+
*/
|
|
1076
|
+
n: number;
|
|
1077
|
+
/**
|
|
1078
|
+
* Size of the images to generate.
|
|
1079
|
+
* Must have the format `{width}x{height}`.
|
|
1080
|
+
* `undefined` will use the provider's default size.
|
|
1081
|
+
*/
|
|
1082
|
+
size: `${number}x${number}` | undefined;
|
|
1083
|
+
/**
|
|
1084
|
+
* Aspect ratio of the images to generate.
|
|
1085
|
+
* Must have the format `{width}:{height}`.
|
|
1086
|
+
* `undefined` will use the provider's default aspect ratio.
|
|
1087
|
+
*/
|
|
1088
|
+
aspectRatio: `${number}:${number}` | undefined;
|
|
1089
|
+
/**
|
|
1090
|
+
* Seed for the image generation.
|
|
1091
|
+
* `undefined` will use the provider's default seed.
|
|
1092
|
+
*/
|
|
1093
|
+
seed: number | undefined;
|
|
1094
|
+
/**
|
|
1095
|
+
* Array of images for image editing or variation generation.
|
|
1096
|
+
* The images should be provided as base64 encoded strings or binary data.
|
|
1097
|
+
*/
|
|
1098
|
+
files: ImageModelV3File[] | undefined;
|
|
1099
|
+
/**
|
|
1100
|
+
* Mask image for inpainting operations.
|
|
1101
|
+
* The mask should be provided as base64 encoded strings or binary data.
|
|
1102
|
+
*/
|
|
1103
|
+
mask: ImageModelV3File | undefined;
|
|
1104
|
+
/**
|
|
1105
|
+
* Additional provider-specific options that are passed through to the provider
|
|
1106
|
+
* as body parameters.
|
|
1107
|
+
*
|
|
1108
|
+
* The outer record is keyed by the provider name, and the inner
|
|
1109
|
+
* record is keyed by the provider-specific metadata key.
|
|
1110
|
+
*
|
|
1111
|
+
* ```ts
|
|
1112
|
+
* {
|
|
1113
|
+
* "openai": {
|
|
1114
|
+
* "style": "vivid"
|
|
1115
|
+
* }
|
|
1116
|
+
* }
|
|
1117
|
+
* ```
|
|
1118
|
+
*/
|
|
1119
|
+
providerOptions: SharedV3ProviderOptions;
|
|
1120
|
+
/**
|
|
1121
|
+
* Abort signal for cancelling the operation.
|
|
1122
|
+
*/
|
|
1123
|
+
abortSignal?: AbortSignal;
|
|
1124
|
+
/**
|
|
1125
|
+
* Additional HTTP headers to be sent with the request.
|
|
1126
|
+
* Only applicable for HTTP-based providers.
|
|
1127
|
+
*/
|
|
1128
|
+
headers?: Record<string, string | undefined>;
|
|
1129
|
+
};
|
|
1130
|
+
|
|
1131
|
+
type ImageModelV3ProviderMetadata = Record<string, {
|
|
1132
|
+
images: JSONArray;
|
|
1133
|
+
} & JSONValue>;
|
|
1134
|
+
type GetMaxImagesPerCallFunction$1 = (options: {
|
|
1135
|
+
modelId: string;
|
|
1136
|
+
}) => PromiseLike<number | undefined> | number | undefined;
|
|
1137
|
+
/**
|
|
1138
|
+
* Image generation model specification version 3.
|
|
1139
|
+
*/
|
|
1140
|
+
type ImageModelV3 = {
|
|
1141
|
+
/**
|
|
1142
|
+
* The image model must specify which image model interface
|
|
1143
|
+
* version it implements. This will allow us to evolve the image
|
|
1144
|
+
* model interface and retain backwards compatibility. The different
|
|
1145
|
+
* implementation versions can be handled as a discriminated union
|
|
1146
|
+
* on our side.
|
|
1147
|
+
*/
|
|
1148
|
+
readonly specificationVersion: 'v3';
|
|
1149
|
+
/**
|
|
1150
|
+
* Name of the provider for logging purposes.
|
|
1151
|
+
*/
|
|
1152
|
+
readonly provider: string;
|
|
1153
|
+
/**
|
|
1154
|
+
* Provider-specific model ID for logging purposes.
|
|
1155
|
+
*/
|
|
1156
|
+
readonly modelId: string;
|
|
1157
|
+
/**
|
|
1158
|
+
* Limit of how many images can be generated in a single API call.
|
|
1159
|
+
* Can be set to a number for a fixed limit, to undefined to use
|
|
1160
|
+
* the global limit, or a function that returns a number or undefined,
|
|
1161
|
+
* optionally as a promise.
|
|
1162
|
+
*/
|
|
1163
|
+
readonly maxImagesPerCall: number | undefined | GetMaxImagesPerCallFunction$1;
|
|
1164
|
+
/**
|
|
1165
|
+
* Generates an array of images.
|
|
1166
|
+
*/
|
|
1167
|
+
doGenerate(options: ImageModelV3CallOptions): PromiseLike<{
|
|
1168
|
+
/**
|
|
1169
|
+
* Generated images as base64 encoded strings or binary data.
|
|
1170
|
+
* The images should be returned without any unnecessary conversion.
|
|
1171
|
+
* If the API returns base64 encoded strings, the images should be returned
|
|
1172
|
+
* as base64 encoded strings. If the API returns binary data, the images should
|
|
1173
|
+
* be returned as binary data.
|
|
1174
|
+
*/
|
|
1175
|
+
images: Array<string> | Array<Uint8Array>;
|
|
1176
|
+
/**
|
|
1177
|
+
* Warnings for the call, e.g. unsupported features.
|
|
1178
|
+
*/
|
|
1179
|
+
warnings: Array<SharedV3Warning>;
|
|
1180
|
+
/**
|
|
1181
|
+
* Additional provider-specific metadata. They are passed through
|
|
1182
|
+
* from the provider to the AI SDK and enable provider-specific
|
|
1183
|
+
* results that can be fully encapsulated in the provider.
|
|
1184
|
+
*
|
|
1185
|
+
* The outer record is keyed by the provider name, and the inner
|
|
1186
|
+
* record is provider-specific metadata. It always includes an
|
|
1187
|
+
* `images` key with image-specific metadata
|
|
1188
|
+
*
|
|
1189
|
+
* ```ts
|
|
1190
|
+
* {
|
|
1191
|
+
* "openai": {
|
|
1192
|
+
* "images": ["revisedPrompt": "Revised prompt here."]
|
|
1193
|
+
* }
|
|
1194
|
+
* }
|
|
1195
|
+
* ```
|
|
1196
|
+
*/
|
|
1197
|
+
providerMetadata?: ImageModelV3ProviderMetadata;
|
|
1198
|
+
/**
|
|
1199
|
+
* Response information for telemetry and debugging purposes.
|
|
1200
|
+
*/
|
|
1201
|
+
response: {
|
|
1202
|
+
/**
|
|
1203
|
+
* Timestamp for the start of the generated response.
|
|
1204
|
+
*/
|
|
1205
|
+
timestamp: Date;
|
|
1206
|
+
/**
|
|
1207
|
+
* The ID of the response model that was used to generate the response.
|
|
1208
|
+
*/
|
|
1209
|
+
modelId: string;
|
|
1210
|
+
/**
|
|
1211
|
+
* Response headers.
|
|
1212
|
+
*/
|
|
1213
|
+
headers: Record<string, string> | undefined;
|
|
1214
|
+
};
|
|
1215
|
+
/**
|
|
1216
|
+
* Optional token usage for the image generation call (if the provider reports it).
|
|
1217
|
+
*/
|
|
1218
|
+
usage?: ImageModelV3Usage;
|
|
1219
|
+
}>;
|
|
1220
|
+
};
|
|
1221
|
+
|
|
1222
|
+
type ImageModelV2CallOptions = {
|
|
1223
|
+
/**
|
|
1224
|
+
* Prompt for the image generation.
|
|
1225
|
+
*/
|
|
1226
|
+
prompt: string;
|
|
1227
|
+
/**
|
|
1228
|
+
* Number of images to generate.
|
|
1229
|
+
*/
|
|
1230
|
+
n: number;
|
|
1231
|
+
/**
|
|
1232
|
+
* Size of the images to generate.
|
|
1233
|
+
* Must have the format `{width}x{height}`.
|
|
1234
|
+
* `undefined` will use the provider's default size.
|
|
1235
|
+
*/
|
|
1236
|
+
size: `${number}x${number}` | undefined;
|
|
1237
|
+
/**
|
|
1238
|
+
* Aspect ratio of the images to generate.
|
|
1239
|
+
* Must have the format `{width}:{height}`.
|
|
1240
|
+
* `undefined` will use the provider's default aspect ratio.
|
|
1241
|
+
*/
|
|
1242
|
+
aspectRatio: `${number}:${number}` | undefined;
|
|
1243
|
+
/**
|
|
1244
|
+
* Seed for the image generation.
|
|
1245
|
+
* `undefined` will use the provider's default seed.
|
|
1246
|
+
*/
|
|
1247
|
+
seed: number | undefined;
|
|
1248
|
+
/**
|
|
1249
|
+
* Additional provider-specific options that are passed through to the provider
|
|
1250
|
+
* as body parameters.
|
|
1251
|
+
*
|
|
1252
|
+
* The outer record is keyed by the provider name, and the inner
|
|
1253
|
+
* record is keyed by the provider-specific metadata key.
|
|
1254
|
+
* ```ts
|
|
1255
|
+
* {
|
|
1256
|
+
* "openai": {
|
|
1257
|
+
* "style": "vivid"
|
|
850
1258
|
* }
|
|
851
1259
|
* }
|
|
852
1260
|
* ```
|
|
@@ -963,6 +1371,64 @@ type ImageModelV2 = {
|
|
|
963
1371
|
}>;
|
|
964
1372
|
};
|
|
965
1373
|
|
|
1374
|
+
/**
|
|
1375
|
+
* Middleware for ImageModelV4.
|
|
1376
|
+
* This type defines the structure for middleware that can be used to modify
|
|
1377
|
+
* the behavior of ImageModelV4 operations.
|
|
1378
|
+
*/
|
|
1379
|
+
type ImageModelV4Middleware = {
|
|
1380
|
+
/**
|
|
1381
|
+
* Middleware specification version. Use `v4` for the current version.
|
|
1382
|
+
*/
|
|
1383
|
+
readonly specificationVersion: 'v4';
|
|
1384
|
+
/**
|
|
1385
|
+
* Override the provider name if desired.
|
|
1386
|
+
* @param options.model - The image model instance.
|
|
1387
|
+
*/
|
|
1388
|
+
overrideProvider?: (options: {
|
|
1389
|
+
model: ImageModelV4;
|
|
1390
|
+
}) => string;
|
|
1391
|
+
/**
|
|
1392
|
+
* Override the model ID if desired.
|
|
1393
|
+
* @param options.model - The image model instance.
|
|
1394
|
+
*/
|
|
1395
|
+
overrideModelId?: (options: {
|
|
1396
|
+
model: ImageModelV4;
|
|
1397
|
+
}) => string;
|
|
1398
|
+
/**
|
|
1399
|
+
* Override the limit of how many images can be generated in a single API call if desired.
|
|
1400
|
+
* @param options.model - The image model instance.
|
|
1401
|
+
*/
|
|
1402
|
+
overrideMaxImagesPerCall?: (options: {
|
|
1403
|
+
model: ImageModelV4;
|
|
1404
|
+
}) => ImageModelV4['maxImagesPerCall'];
|
|
1405
|
+
/**
|
|
1406
|
+
* Transforms the parameters before they are passed to the image model.
|
|
1407
|
+
* @param options - Object containing the parameters.
|
|
1408
|
+
* @param options.params - The original parameters for the image model call.
|
|
1409
|
+
* @returns A promise that resolves to the transformed parameters.
|
|
1410
|
+
*/
|
|
1411
|
+
transformParams?: (options: {
|
|
1412
|
+
params: ImageModelV4CallOptions;
|
|
1413
|
+
model: ImageModelV4;
|
|
1414
|
+
}) => PromiseLike<ImageModelV4CallOptions>;
|
|
1415
|
+
/**
|
|
1416
|
+
* Wraps the generate operation of the image model.
|
|
1417
|
+
*
|
|
1418
|
+
* @param options - Object containing the generate function, parameters, and model.
|
|
1419
|
+
* @param options.doGenerate - The original generate function.
|
|
1420
|
+
* @param options.params - The parameters for the generate call. If the
|
|
1421
|
+
* `transformParams` middleware is used, this will be the transformed parameters.
|
|
1422
|
+
* @param options.model - The image model instance.
|
|
1423
|
+
* @returns A promise that resolves to the result of the generate operation.
|
|
1424
|
+
*/
|
|
1425
|
+
wrapGenerate?: (options: {
|
|
1426
|
+
doGenerate: () => ReturnType<ImageModelV4['doGenerate']>;
|
|
1427
|
+
params: ImageModelV4CallOptions;
|
|
1428
|
+
model: ImageModelV4;
|
|
1429
|
+
}) => Promise<Awaited<ReturnType<ImageModelV4['doGenerate']>>>;
|
|
1430
|
+
};
|
|
1431
|
+
|
|
966
1432
|
/**
|
|
967
1433
|
* Middleware for ImageModelV3.
|
|
968
1434
|
* This type defines the structure for middleware that can be used to modify
|
|
@@ -1027,7 +1493,7 @@ type ImageModelV3Middleware = {
|
|
|
1027
1493
|
* Note: this is **not** the user-facing tool definition. The AI SDK methods will
|
|
1028
1494
|
* map the user-facing tool definitions to this format.
|
|
1029
1495
|
*/
|
|
1030
|
-
type
|
|
1496
|
+
type LanguageModelV4FunctionTool = {
|
|
1031
1497
|
/**
|
|
1032
1498
|
* The type of the tool (always 'function').
|
|
1033
1499
|
*/
|
|
@@ -1070,7 +1536,7 @@ type LanguageModelV3FunctionTool = {
|
|
|
1070
1536
|
/**
|
|
1071
1537
|
* Data content. Can be a Uint8Array, base64 encoded data as a string or a URL.
|
|
1072
1538
|
*/
|
|
1073
|
-
type
|
|
1539
|
+
type LanguageModelV4DataContent = Uint8Array | string | URL;
|
|
1074
1540
|
|
|
1075
1541
|
/**
|
|
1076
1542
|
* A prompt is a list of messages.
|
|
@@ -1081,19 +1547,19 @@ type LanguageModelV3DataContent = Uint8Array | string | URL;
|
|
|
1081
1547
|
* Note: This is not a user-facing prompt. The AI SDK methods will map the
|
|
1082
1548
|
* user-facing prompt types such as chat or instruction prompts to this format.
|
|
1083
1549
|
*/
|
|
1084
|
-
type
|
|
1085
|
-
type
|
|
1550
|
+
type LanguageModelV4Prompt = Array<LanguageModelV4Message>;
|
|
1551
|
+
type LanguageModelV4Message = ({
|
|
1086
1552
|
role: 'system';
|
|
1087
1553
|
content: string;
|
|
1088
1554
|
} | {
|
|
1089
1555
|
role: 'user';
|
|
1090
|
-
content: Array<
|
|
1556
|
+
content: Array<LanguageModelV4TextPart | LanguageModelV4FilePart>;
|
|
1091
1557
|
} | {
|
|
1092
1558
|
role: 'assistant';
|
|
1093
|
-
content: Array<
|
|
1559
|
+
content: Array<LanguageModelV4TextPart | LanguageModelV4FilePart | LanguageModelV4ReasoningPart | LanguageModelV4ToolCallPart | LanguageModelV4ToolResultPart>;
|
|
1094
1560
|
} | {
|
|
1095
1561
|
role: 'tool';
|
|
1096
|
-
content: Array<
|
|
1562
|
+
content: Array<LanguageModelV4ToolResultPart | LanguageModelV4ToolApprovalResponsePart>;
|
|
1097
1563
|
}) & {
|
|
1098
1564
|
/**
|
|
1099
1565
|
* Additional provider-specific options. They are passed through
|
|
@@ -1105,7 +1571,7 @@ type LanguageModelV3Message = ({
|
|
|
1105
1571
|
/**
|
|
1106
1572
|
* Text content part of a prompt. It contains a string of text.
|
|
1107
1573
|
*/
|
|
1108
|
-
interface
|
|
1574
|
+
interface LanguageModelV4TextPart {
|
|
1109
1575
|
type: 'text';
|
|
1110
1576
|
/**
|
|
1111
1577
|
* The text content.
|
|
@@ -1121,7 +1587,7 @@ interface LanguageModelV3TextPart {
|
|
|
1121
1587
|
/**
|
|
1122
1588
|
* Reasoning content part of a prompt. It contains a string of reasoning text.
|
|
1123
1589
|
*/
|
|
1124
|
-
interface
|
|
1590
|
+
interface LanguageModelV4ReasoningPart {
|
|
1125
1591
|
type: 'reasoning';
|
|
1126
1592
|
/**
|
|
1127
1593
|
* The reasoning text.
|
|
@@ -1137,7 +1603,7 @@ interface LanguageModelV3ReasoningPart {
|
|
|
1137
1603
|
/**
|
|
1138
1604
|
* File content part of a prompt. It contains a file.
|
|
1139
1605
|
*/
|
|
1140
|
-
interface
|
|
1606
|
+
interface LanguageModelV4FilePart {
|
|
1141
1607
|
type: 'file';
|
|
1142
1608
|
/**
|
|
1143
1609
|
* Optional filename of the file.
|
|
@@ -1146,7 +1612,7 @@ interface LanguageModelV3FilePart {
|
|
|
1146
1612
|
/**
|
|
1147
1613
|
* File data. Can be a Uint8Array, base64 encoded data as a string or a URL.
|
|
1148
1614
|
*/
|
|
1149
|
-
data:
|
|
1615
|
+
data: LanguageModelV4DataContent;
|
|
1150
1616
|
/**
|
|
1151
1617
|
* IANA media type of the file.
|
|
1152
1618
|
*
|
|
@@ -1165,7 +1631,7 @@ interface LanguageModelV3FilePart {
|
|
|
1165
1631
|
/**
|
|
1166
1632
|
* Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
|
|
1167
1633
|
*/
|
|
1168
|
-
interface
|
|
1634
|
+
interface LanguageModelV4ToolCallPart {
|
|
1169
1635
|
type: 'tool-call';
|
|
1170
1636
|
/**
|
|
1171
1637
|
* ID of the tool call. This ID is used to match the tool call with the tool result.
|
|
@@ -1194,7 +1660,7 @@ interface LanguageModelV3ToolCallPart {
|
|
|
1194
1660
|
/**
|
|
1195
1661
|
* Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
|
|
1196
1662
|
*/
|
|
1197
|
-
interface
|
|
1663
|
+
interface LanguageModelV4ToolResultPart {
|
|
1198
1664
|
type: 'tool-result';
|
|
1199
1665
|
/**
|
|
1200
1666
|
* ID of the tool call that this result is associated with.
|
|
@@ -1207,7 +1673,7 @@ interface LanguageModelV3ToolResultPart {
|
|
|
1207
1673
|
/**
|
|
1208
1674
|
* Result of the tool call.
|
|
1209
1675
|
*/
|
|
1210
|
-
output:
|
|
1676
|
+
output: LanguageModelV4ToolResultOutput;
|
|
1211
1677
|
/**
|
|
1212
1678
|
* Additional provider-specific options. They are passed through
|
|
1213
1679
|
* to the provider from the AI SDK and enable provider-specific
|
|
@@ -1219,7 +1685,7 @@ interface LanguageModelV3ToolResultPart {
|
|
|
1219
1685
|
* Tool approval response content part of a prompt. It contains the user's
|
|
1220
1686
|
* decision to approve or deny a provider-executed tool call.
|
|
1221
1687
|
*/
|
|
1222
|
-
interface
|
|
1688
|
+
interface LanguageModelV4ToolApprovalResponsePart {
|
|
1223
1689
|
type: 'tool-approval-response';
|
|
1224
1690
|
/**
|
|
1225
1691
|
* ID of the approval request that this response refers to.
|
|
@@ -1243,7 +1709,7 @@ interface LanguageModelV3ToolApprovalResponsePart {
|
|
|
1243
1709
|
/**
|
|
1244
1710
|
* Result of a tool call.
|
|
1245
1711
|
*/
|
|
1246
|
-
type
|
|
1712
|
+
type LanguageModelV4ToolResultOutput = {
|
|
1247
1713
|
/**
|
|
1248
1714
|
* Text tool output that should be directly sent to the API.
|
|
1249
1715
|
*/
|
|
@@ -1412,7 +1878,7 @@ type LanguageModelV3ToolResultOutput = {
|
|
|
1412
1878
|
* The input and output schemas are defined be the provider, and
|
|
1413
1879
|
* some of the tools are also executed on the provider systems.
|
|
1414
1880
|
*/
|
|
1415
|
-
type
|
|
1881
|
+
type LanguageModelV4ProviderTool = {
|
|
1416
1882
|
/**
|
|
1417
1883
|
* The type of the tool (always 'provider').
|
|
1418
1884
|
*/
|
|
@@ -1431,7 +1897,7 @@ type LanguageModelV3ProviderTool = {
|
|
|
1431
1897
|
args: Record<string, unknown>;
|
|
1432
1898
|
};
|
|
1433
1899
|
|
|
1434
|
-
type
|
|
1900
|
+
type LanguageModelV4ToolChoice = {
|
|
1435
1901
|
type: 'auto';
|
|
1436
1902
|
} | {
|
|
1437
1903
|
type: 'none';
|
|
@@ -1442,7 +1908,7 @@ type LanguageModelV3ToolChoice = {
|
|
|
1442
1908
|
toolName: string;
|
|
1443
1909
|
};
|
|
1444
1910
|
|
|
1445
|
-
type
|
|
1911
|
+
type LanguageModelV4CallOptions = {
|
|
1446
1912
|
/**
|
|
1447
1913
|
* A language mode prompt is a standardized prompt type.
|
|
1448
1914
|
*
|
|
@@ -1451,7 +1917,7 @@ type LanguageModelV3CallOptions = {
|
|
|
1451
1917
|
* That approach allows us to evolve the user facing prompts without breaking
|
|
1452
1918
|
* the language model interface.
|
|
1453
1919
|
*/
|
|
1454
|
-
prompt:
|
|
1920
|
+
prompt: LanguageModelV4Prompt;
|
|
1455
1921
|
/**
|
|
1456
1922
|
* Maximum number of tokens to generate.
|
|
1457
1923
|
*/
|
|
@@ -1517,11 +1983,11 @@ type LanguageModelV3CallOptions = {
|
|
|
1517
1983
|
/**
|
|
1518
1984
|
* The tools that are available for the model.
|
|
1519
1985
|
*/
|
|
1520
|
-
tools?: Array<
|
|
1986
|
+
tools?: Array<LanguageModelV4FunctionTool | LanguageModelV4ProviderTool>;
|
|
1521
1987
|
/**
|
|
1522
1988
|
* Specifies how the tool should be selected. Defaults to 'auto'.
|
|
1523
1989
|
*/
|
|
1524
|
-
toolChoice?:
|
|
1990
|
+
toolChoice?: LanguageModelV4ToolChoice;
|
|
1525
1991
|
/**
|
|
1526
1992
|
* Include raw chunks in the stream. Only applicable for streaming calls.
|
|
1527
1993
|
*/
|
|
@@ -1548,7 +2014,7 @@ type LanguageModelV3CallOptions = {
|
|
|
1548
2014
|
* Generated files as base64 encoded strings or binary data.
|
|
1549
2015
|
* The files should be returned without any unnecessary conversion.
|
|
1550
2016
|
*/
|
|
1551
|
-
type
|
|
2017
|
+
type LanguageModelV4File = {
|
|
1552
2018
|
type: 'file';
|
|
1553
2019
|
/**
|
|
1554
2020
|
* The IANA media type of the file, e.g. `image/png` or `audio/mp3`.
|
|
@@ -1574,7 +2040,7 @@ type LanguageModelV3File = {
|
|
|
1574
2040
|
/**
|
|
1575
2041
|
* Reasoning that the model has generated.
|
|
1576
2042
|
*/
|
|
1577
|
-
type
|
|
2043
|
+
type LanguageModelV4Reasoning = {
|
|
1578
2044
|
type: 'reasoning';
|
|
1579
2045
|
text: string;
|
|
1580
2046
|
/**
|
|
@@ -1586,7 +2052,7 @@ type LanguageModelV3Reasoning = {
|
|
|
1586
2052
|
/**
|
|
1587
2053
|
* A source that has been used as input to generate the response.
|
|
1588
2054
|
*/
|
|
1589
|
-
type
|
|
2055
|
+
type LanguageModelV4Source = {
|
|
1590
2056
|
type: 'source';
|
|
1591
2057
|
/**
|
|
1592
2058
|
* The type of source - URL sources reference web content.
|
|
@@ -1639,7 +2105,7 @@ type LanguageModelV3Source = {
|
|
|
1639
2105
|
/**
|
|
1640
2106
|
* Text that the model has generated.
|
|
1641
2107
|
*/
|
|
1642
|
-
type
|
|
2108
|
+
type LanguageModelV4Text = {
|
|
1643
2109
|
type: 'text';
|
|
1644
2110
|
/**
|
|
1645
2111
|
* The text content.
|
|
@@ -1654,7 +2120,7 @@ type LanguageModelV3Text = {
|
|
|
1654
2120
|
* This is used for flows where the provider executes the tool (e.g. MCP tools)
|
|
1655
2121
|
* but requires an explicit user approval before continuing.
|
|
1656
2122
|
*/
|
|
1657
|
-
type
|
|
2123
|
+
type LanguageModelV4ToolApprovalRequest = {
|
|
1658
2124
|
type: 'tool-approval-request';
|
|
1659
2125
|
/**
|
|
1660
2126
|
* ID of the approval request. This ID is referenced by the subsequent
|
|
@@ -1674,7 +2140,7 @@ type LanguageModelV3ToolApprovalRequest = {
|
|
|
1674
2140
|
/**
|
|
1675
2141
|
* Tool calls that the model has generated.
|
|
1676
2142
|
*/
|
|
1677
|
-
type
|
|
2143
|
+
type LanguageModelV4ToolCall = {
|
|
1678
2144
|
type: 'tool-call';
|
|
1679
2145
|
/**
|
|
1680
2146
|
* The identifier of the tool call. It must be unique across all tool calls.
|
|
@@ -1708,7 +2174,7 @@ type LanguageModelV3ToolCall = {
|
|
|
1708
2174
|
/**
|
|
1709
2175
|
* Result of a tool call that has been executed by the provider.
|
|
1710
2176
|
*/
|
|
1711
|
-
type
|
|
2177
|
+
type LanguageModelV4ToolResult = {
|
|
1712
2178
|
type: 'tool-result';
|
|
1713
2179
|
/**
|
|
1714
2180
|
* The ID of the tool call that this result is associated with.
|
|
@@ -1747,7 +2213,7 @@ type LanguageModelV3ToolResult = {
|
|
|
1747
2213
|
providerMetadata?: SharedV3ProviderMetadata;
|
|
1748
2214
|
};
|
|
1749
2215
|
|
|
1750
|
-
type
|
|
2216
|
+
type LanguageModelV4Content = LanguageModelV4Text | LanguageModelV4Reasoning | LanguageModelV4File | LanguageModelV4ToolApprovalRequest | LanguageModelV4Source | LanguageModelV4ToolCall | LanguageModelV4ToolResult;
|
|
1751
2217
|
|
|
1752
2218
|
/**
|
|
1753
2219
|
* Reason why a language model finished generating a response.
|
|
@@ -1756,7 +2222,7 @@ type LanguageModelV3Content = LanguageModelV3Text | LanguageModelV3Reasoning | L
|
|
|
1756
2222
|
* The unified finish reason is used to provide a consistent finish reason across different providers.
|
|
1757
2223
|
* The raw finish reason is used to provide the original finish reason from the provider.
|
|
1758
2224
|
*/
|
|
1759
|
-
type
|
|
2225
|
+
type LanguageModelV4FinishReason = {
|
|
1760
2226
|
/**
|
|
1761
2227
|
* Unified finish reason. This enables using the same finish reason across different providers.
|
|
1762
2228
|
*
|
|
@@ -1776,7 +2242,7 @@ type LanguageModelV3FinishReason = {
|
|
|
1776
2242
|
raw: string | undefined;
|
|
1777
2243
|
};
|
|
1778
2244
|
|
|
1779
|
-
interface
|
|
2245
|
+
interface LanguageModelV4ResponseMetadata {
|
|
1780
2246
|
/**
|
|
1781
2247
|
* ID for the generated response, if the provider sends one.
|
|
1782
2248
|
*/
|
|
@@ -1794,7 +2260,7 @@ interface LanguageModelV3ResponseMetadata {
|
|
|
1794
2260
|
/**
|
|
1795
2261
|
* Usage information for a language model call.
|
|
1796
2262
|
*/
|
|
1797
|
-
type
|
|
2263
|
+
type LanguageModelV4Usage = {
|
|
1798
2264
|
/**
|
|
1799
2265
|
* Information about the input tokens.
|
|
1800
2266
|
*/
|
|
@@ -1845,19 +2311,19 @@ type LanguageModelV3Usage = {
|
|
|
1845
2311
|
/**
|
|
1846
2312
|
* The result of a language model doGenerate call.
|
|
1847
2313
|
*/
|
|
1848
|
-
type
|
|
2314
|
+
type LanguageModelV4GenerateResult = {
|
|
1849
2315
|
/**
|
|
1850
2316
|
* Ordered content that the model has generated.
|
|
1851
2317
|
*/
|
|
1852
|
-
content: Array<
|
|
2318
|
+
content: Array<LanguageModelV4Content>;
|
|
1853
2319
|
/**
|
|
1854
2320
|
* The finish reason.
|
|
1855
2321
|
*/
|
|
1856
|
-
finishReason:
|
|
2322
|
+
finishReason: LanguageModelV4FinishReason;
|
|
1857
2323
|
/**
|
|
1858
2324
|
* The usage information.
|
|
1859
2325
|
*/
|
|
1860
|
-
usage:
|
|
2326
|
+
usage: LanguageModelV4Usage;
|
|
1861
2327
|
/**
|
|
1862
2328
|
* Additional provider-specific metadata. They are passed through
|
|
1863
2329
|
* from the provider to the AI SDK and enable provider-specific
|
|
@@ -1876,7 +2342,7 @@ type LanguageModelV3GenerateResult = {
|
|
|
1876
2342
|
/**
|
|
1877
2343
|
* Optional response information for telemetry and debugging purposes.
|
|
1878
2344
|
*/
|
|
1879
|
-
response?:
|
|
2345
|
+
response?: LanguageModelV4ResponseMetadata & {
|
|
1880
2346
|
/**
|
|
1881
2347
|
* Response headers.
|
|
1882
2348
|
*/
|
|
@@ -1892,7 +2358,7 @@ type LanguageModelV3GenerateResult = {
|
|
|
1892
2358
|
warnings: Array<SharedV3Warning>;
|
|
1893
2359
|
};
|
|
1894
2360
|
|
|
1895
|
-
type
|
|
2361
|
+
type LanguageModelV4StreamPart = {
|
|
1896
2362
|
type: 'text-start';
|
|
1897
2363
|
providerMetadata?: SharedV3ProviderMetadata;
|
|
1898
2364
|
id: string;
|
|
@@ -1935,15 +2401,15 @@ type LanguageModelV3StreamPart = {
|
|
|
1935
2401
|
type: 'tool-input-end';
|
|
1936
2402
|
id: string;
|
|
1937
2403
|
providerMetadata?: SharedV3ProviderMetadata;
|
|
1938
|
-
} |
|
|
2404
|
+
} | LanguageModelV4ToolApprovalRequest | LanguageModelV4ToolCall | LanguageModelV4ToolResult | LanguageModelV4File | LanguageModelV4Source | {
|
|
1939
2405
|
type: 'stream-start';
|
|
1940
2406
|
warnings: Array<SharedV3Warning>;
|
|
1941
2407
|
} | ({
|
|
1942
2408
|
type: 'response-metadata';
|
|
1943
|
-
} &
|
|
2409
|
+
} & LanguageModelV4ResponseMetadata) | {
|
|
1944
2410
|
type: 'finish';
|
|
1945
|
-
usage:
|
|
1946
|
-
finishReason:
|
|
2411
|
+
usage: LanguageModelV4Usage;
|
|
2412
|
+
finishReason: LanguageModelV4FinishReason;
|
|
1947
2413
|
providerMetadata?: SharedV3ProviderMetadata;
|
|
1948
2414
|
} | {
|
|
1949
2415
|
type: 'raw';
|
|
@@ -1956,11 +2422,11 @@ type LanguageModelV3StreamPart = {
|
|
|
1956
2422
|
/**
|
|
1957
2423
|
* The result of a language model doStream call.
|
|
1958
2424
|
*/
|
|
1959
|
-
type
|
|
2425
|
+
type LanguageModelV4StreamResult = {
|
|
1960
2426
|
/**
|
|
1961
2427
|
* The stream.
|
|
1962
2428
|
*/
|
|
1963
|
-
stream: ReadableStream<
|
|
2429
|
+
stream: ReadableStream<LanguageModelV4StreamPart>;
|
|
1964
2430
|
/**
|
|
1965
2431
|
* Optional request information for telemetry and debugging purposes.
|
|
1966
2432
|
*/
|
|
@@ -1982,13 +2448,13 @@ type LanguageModelV3StreamResult = {
|
|
|
1982
2448
|
};
|
|
1983
2449
|
|
|
1984
2450
|
/**
|
|
1985
|
-
* Specification for a language model that implements the language model interface version
|
|
2451
|
+
* Specification for a language model that implements the language model interface version 4.
|
|
1986
2452
|
*/
|
|
1987
|
-
type
|
|
2453
|
+
type LanguageModelV4 = {
|
|
1988
2454
|
/**
|
|
1989
2455
|
* The language model must specify which language model interface version it implements.
|
|
1990
2456
|
*/
|
|
1991
|
-
readonly specificationVersion: '
|
|
2457
|
+
readonly specificationVersion: 'v4';
|
|
1992
2458
|
/**
|
|
1993
2459
|
* Provider ID.
|
|
1994
2460
|
*/
|
|
@@ -2012,11 +2478,11 @@ type LanguageModelV3 = {
|
|
|
2012
2478
|
supportedUrls: PromiseLike<Record<string, RegExp[]>> | Record<string, RegExp[]>;
|
|
2013
2479
|
/**
|
|
2014
2480
|
* Generates a language model output (non-streaming).
|
|
2015
|
-
|
|
2481
|
+
*
|
|
2016
2482
|
* Naming: "do" prefix to prevent accidental direct usage of the method
|
|
2017
2483
|
* by the user.
|
|
2018
2484
|
*/
|
|
2019
|
-
doGenerate(options:
|
|
2485
|
+
doGenerate(options: LanguageModelV4CallOptions): PromiseLike<LanguageModelV4GenerateResult>;
|
|
2020
2486
|
/**
|
|
2021
2487
|
* Generates a language model output (streaming).
|
|
2022
2488
|
*
|
|
@@ -2025,39 +2491,39 @@ type LanguageModelV3 = {
|
|
|
2025
2491
|
*
|
|
2026
2492
|
* @return A stream of higher-level language model output parts.
|
|
2027
2493
|
*/
|
|
2028
|
-
doStream(options:
|
|
2494
|
+
doStream(options: LanguageModelV4CallOptions): PromiseLike<LanguageModelV4StreamResult>;
|
|
2029
2495
|
};
|
|
2030
2496
|
|
|
2031
2497
|
/**
|
|
2032
|
-
* Experimental middleware for
|
|
2498
|
+
* Experimental middleware for LanguageModelV4.
|
|
2033
2499
|
* This type defines the structure for middleware that can be used to modify
|
|
2034
|
-
* the behavior of
|
|
2500
|
+
* the behavior of LanguageModelV4 operations.
|
|
2035
2501
|
*/
|
|
2036
|
-
type
|
|
2502
|
+
type LanguageModelV4Middleware = {
|
|
2037
2503
|
/**
|
|
2038
|
-
* Middleware specification version. Use `
|
|
2504
|
+
* Middleware specification version. Use `v4` for the current version.
|
|
2039
2505
|
*/
|
|
2040
|
-
readonly specificationVersion: '
|
|
2506
|
+
readonly specificationVersion: 'v4';
|
|
2041
2507
|
/**
|
|
2042
2508
|
* Override the provider name if desired.
|
|
2043
2509
|
* @param options.model - The language model instance.
|
|
2044
2510
|
*/
|
|
2045
2511
|
overrideProvider?: (options: {
|
|
2046
|
-
model:
|
|
2512
|
+
model: LanguageModelV4;
|
|
2047
2513
|
}) => string;
|
|
2048
2514
|
/**
|
|
2049
2515
|
* Override the model ID if desired.
|
|
2050
2516
|
* @param options.model - The language model instance.
|
|
2051
2517
|
*/
|
|
2052
2518
|
overrideModelId?: (options: {
|
|
2053
|
-
model:
|
|
2519
|
+
model: LanguageModelV4;
|
|
2054
2520
|
}) => string;
|
|
2055
2521
|
/**
|
|
2056
2522
|
* Override the supported URLs if desired.
|
|
2057
2523
|
* @param options.model - The language model instance.
|
|
2058
2524
|
*/
|
|
2059
2525
|
overrideSupportedUrls?: (options: {
|
|
2060
|
-
model:
|
|
2526
|
+
model: LanguageModelV4;
|
|
2061
2527
|
}) => PromiseLike<Record<string, RegExp[]>> | Record<string, RegExp[]>;
|
|
2062
2528
|
/**
|
|
2063
2529
|
* Transforms the parameters before they are passed to the language model.
|
|
@@ -2068,9 +2534,9 @@ type LanguageModelV3Middleware = {
|
|
|
2068
2534
|
*/
|
|
2069
2535
|
transformParams?: (options: {
|
|
2070
2536
|
type: 'generate' | 'stream';
|
|
2071
|
-
params:
|
|
2072
|
-
model:
|
|
2073
|
-
}) => PromiseLike<
|
|
2537
|
+
params: LanguageModelV4CallOptions;
|
|
2538
|
+
model: LanguageModelV4;
|
|
2539
|
+
}) => PromiseLike<LanguageModelV4CallOptions>;
|
|
2074
2540
|
/**
|
|
2075
2541
|
* Wraps the generate operation of the language model.
|
|
2076
2542
|
* @param options - Object containing the generate function, parameters, and model.
|
|
@@ -2082,11 +2548,11 @@ type LanguageModelV3Middleware = {
|
|
|
2082
2548
|
* @returns A promise that resolves to the result of the generate operation.
|
|
2083
2549
|
*/
|
|
2084
2550
|
wrapGenerate?: (options: {
|
|
2085
|
-
doGenerate: () => PromiseLike<
|
|
2086
|
-
doStream: () => PromiseLike<
|
|
2087
|
-
params:
|
|
2088
|
-
model:
|
|
2089
|
-
}) => PromiseLike<
|
|
2551
|
+
doGenerate: () => PromiseLike<LanguageModelV4GenerateResult>;
|
|
2552
|
+
doStream: () => PromiseLike<LanguageModelV4StreamResult>;
|
|
2553
|
+
params: LanguageModelV4CallOptions;
|
|
2554
|
+
model: LanguageModelV4;
|
|
2555
|
+
}) => PromiseLike<LanguageModelV4GenerateResult>;
|
|
2090
2556
|
/**
|
|
2091
2557
|
* Wraps the stream operation of the language model.
|
|
2092
2558
|
*
|
|
@@ -2099,11 +2565,11 @@ type LanguageModelV3Middleware = {
|
|
|
2099
2565
|
* @returns A promise that resolves to the result of the stream operation.
|
|
2100
2566
|
*/
|
|
2101
2567
|
wrapStream?: (options: {
|
|
2102
|
-
doGenerate: () => PromiseLike<
|
|
2103
|
-
doStream: () => PromiseLike<
|
|
2104
|
-
params:
|
|
2105
|
-
model:
|
|
2106
|
-
}) => PromiseLike<
|
|
2568
|
+
doGenerate: () => PromiseLike<LanguageModelV4GenerateResult>;
|
|
2569
|
+
doStream: () => PromiseLike<LanguageModelV4StreamResult>;
|
|
2570
|
+
params: LanguageModelV4CallOptions;
|
|
2571
|
+
model: LanguageModelV4;
|
|
2572
|
+
}) => PromiseLike<LanguageModelV4StreamResult>;
|
|
2107
2573
|
};
|
|
2108
2574
|
|
|
2109
2575
|
/**
|
|
@@ -2112,7 +2578,7 @@ type LanguageModelV3Middleware = {
|
|
|
2112
2578
|
* Note: this is **not** the user-facing tool definition. The AI SDK methods will
|
|
2113
2579
|
* map the user-facing tool definitions to this format.
|
|
2114
2580
|
*/
|
|
2115
|
-
type
|
|
2581
|
+
type LanguageModelV3FunctionTool = {
|
|
2116
2582
|
/**
|
|
2117
2583
|
* The type of the tool (always 'function').
|
|
2118
2584
|
*/
|
|
@@ -2131,16 +2597,31 @@ type LanguageModelV2FunctionTool = {
|
|
|
2131
2597
|
* understand the tool's input requirements and to provide matching suggestions.
|
|
2132
2598
|
*/
|
|
2133
2599
|
inputSchema: JSONSchema7;
|
|
2600
|
+
/**
|
|
2601
|
+
* An optional list of input examples that show the language
|
|
2602
|
+
* model what the input should look like.
|
|
2603
|
+
*/
|
|
2604
|
+
inputExamples?: Array<{
|
|
2605
|
+
input: JSONObject;
|
|
2606
|
+
}>;
|
|
2607
|
+
/**
|
|
2608
|
+
* Strict mode setting for the tool.
|
|
2609
|
+
*
|
|
2610
|
+
* Providers that support strict mode will use this setting to determine
|
|
2611
|
+
* how the input should be generated. Strict mode will always produce
|
|
2612
|
+
* valid inputs, but it might limit what input schemas are supported.
|
|
2613
|
+
*/
|
|
2614
|
+
strict?: boolean;
|
|
2134
2615
|
/**
|
|
2135
2616
|
* The provider-specific options for the tool.
|
|
2136
2617
|
*/
|
|
2137
|
-
providerOptions?:
|
|
2618
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
2138
2619
|
};
|
|
2139
2620
|
|
|
2140
2621
|
/**
|
|
2141
2622
|
* Data content. Can be a Uint8Array, base64 encoded data as a string or a URL.
|
|
2142
2623
|
*/
|
|
2143
|
-
type
|
|
2624
|
+
type LanguageModelV3DataContent = Uint8Array | string | URL;
|
|
2144
2625
|
|
|
2145
2626
|
/**
|
|
2146
2627
|
* A prompt is a list of messages.
|
|
@@ -2151,31 +2632,31 @@ type LanguageModelV2DataContent = Uint8Array | string | URL;
|
|
|
2151
2632
|
* Note: This is not a user-facing prompt. The AI SDK methods will map the
|
|
2152
2633
|
* user-facing prompt types such as chat or instruction prompts to this format.
|
|
2153
2634
|
*/
|
|
2154
|
-
type
|
|
2155
|
-
type
|
|
2635
|
+
type LanguageModelV3Prompt = Array<LanguageModelV3Message>;
|
|
2636
|
+
type LanguageModelV3Message = ({
|
|
2156
2637
|
role: 'system';
|
|
2157
2638
|
content: string;
|
|
2158
2639
|
} | {
|
|
2159
2640
|
role: 'user';
|
|
2160
|
-
content: Array<
|
|
2641
|
+
content: Array<LanguageModelV3TextPart | LanguageModelV3FilePart>;
|
|
2161
2642
|
} | {
|
|
2162
2643
|
role: 'assistant';
|
|
2163
|
-
content: Array<
|
|
2644
|
+
content: Array<LanguageModelV3TextPart | LanguageModelV3FilePart | LanguageModelV3ReasoningPart | LanguageModelV3ToolCallPart | LanguageModelV3ToolResultPart>;
|
|
2164
2645
|
} | {
|
|
2165
2646
|
role: 'tool';
|
|
2166
|
-
content: Array<
|
|
2647
|
+
content: Array<LanguageModelV3ToolResultPart | LanguageModelV3ToolApprovalResponsePart>;
|
|
2167
2648
|
}) & {
|
|
2168
2649
|
/**
|
|
2169
2650
|
* Additional provider-specific options. They are passed through
|
|
2170
2651
|
* to the provider from the AI SDK and enable provider-specific
|
|
2171
2652
|
* functionality that can be fully encapsulated in the provider.
|
|
2172
2653
|
*/
|
|
2173
|
-
providerOptions?:
|
|
2654
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
2174
2655
|
};
|
|
2175
2656
|
/**
|
|
2176
2657
|
* Text content part of a prompt. It contains a string of text.
|
|
2177
2658
|
*/
|
|
2178
|
-
interface
|
|
2659
|
+
interface LanguageModelV3TextPart {
|
|
2179
2660
|
type: 'text';
|
|
2180
2661
|
/**
|
|
2181
2662
|
* The text content.
|
|
@@ -2186,12 +2667,12 @@ interface LanguageModelV2TextPart {
|
|
|
2186
2667
|
* to the provider from the AI SDK and enable provider-specific
|
|
2187
2668
|
* functionality that can be fully encapsulated in the provider.
|
|
2188
2669
|
*/
|
|
2189
|
-
providerOptions?:
|
|
2670
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
2190
2671
|
}
|
|
2191
2672
|
/**
|
|
2192
2673
|
* Reasoning content part of a prompt. It contains a string of reasoning text.
|
|
2193
2674
|
*/
|
|
2194
|
-
interface
|
|
2675
|
+
interface LanguageModelV3ReasoningPart {
|
|
2195
2676
|
type: 'reasoning';
|
|
2196
2677
|
/**
|
|
2197
2678
|
* The reasoning text.
|
|
@@ -2202,12 +2683,12 @@ interface LanguageModelV2ReasoningPart {
|
|
|
2202
2683
|
* to the provider from the AI SDK and enable provider-specific
|
|
2203
2684
|
* functionality that can be fully encapsulated in the provider.
|
|
2204
2685
|
*/
|
|
2205
|
-
providerOptions?:
|
|
2686
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
2206
2687
|
}
|
|
2207
2688
|
/**
|
|
2208
2689
|
* File content part of a prompt. It contains a file.
|
|
2209
2690
|
*/
|
|
2210
|
-
interface
|
|
2691
|
+
interface LanguageModelV3FilePart {
|
|
2211
2692
|
type: 'file';
|
|
2212
2693
|
/**
|
|
2213
2694
|
* Optional filename of the file.
|
|
@@ -2216,7 +2697,7 @@ interface LanguageModelV2FilePart {
|
|
|
2216
2697
|
/**
|
|
2217
2698
|
* File data. Can be a Uint8Array, base64 encoded data as a string or a URL.
|
|
2218
2699
|
*/
|
|
2219
|
-
data:
|
|
2700
|
+
data: LanguageModelV3DataContent;
|
|
2220
2701
|
/**
|
|
2221
2702
|
* IANA media type of the file.
|
|
2222
2703
|
*
|
|
@@ -2230,12 +2711,12 @@ interface LanguageModelV2FilePart {
|
|
|
2230
2711
|
* to the provider from the AI SDK and enable provider-specific
|
|
2231
2712
|
* functionality that can be fully encapsulated in the provider.
|
|
2232
2713
|
*/
|
|
2233
|
-
providerOptions?:
|
|
2714
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
2234
2715
|
}
|
|
2235
2716
|
/**
|
|
2236
2717
|
* Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
|
|
2237
2718
|
*/
|
|
2238
|
-
interface
|
|
2719
|
+
interface LanguageModelV3ToolCallPart {
|
|
2239
2720
|
type: 'tool-call';
|
|
2240
2721
|
/**
|
|
2241
2722
|
* ID of the tool call. This ID is used to match the tool call with the tool result.
|
|
@@ -2259,12 +2740,12 @@ interface LanguageModelV2ToolCallPart {
|
|
|
2259
2740
|
* to the provider from the AI SDK and enable provider-specific
|
|
2260
2741
|
* functionality that can be fully encapsulated in the provider.
|
|
2261
2742
|
*/
|
|
2262
|
-
providerOptions?:
|
|
2743
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
2263
2744
|
}
|
|
2264
2745
|
/**
|
|
2265
2746
|
* Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
|
|
2266
2747
|
*/
|
|
2267
|
-
interface
|
|
2748
|
+
interface LanguageModelV3ToolResultPart {
|
|
2268
2749
|
type: 'tool-result';
|
|
2269
2750
|
/**
|
|
2270
2751
|
* ID of the tool call that this result is associated with.
|
|
@@ -2277,26 +2758,86 @@ interface LanguageModelV2ToolResultPart {
|
|
|
2277
2758
|
/**
|
|
2278
2759
|
* Result of the tool call.
|
|
2279
2760
|
*/
|
|
2280
|
-
output:
|
|
2761
|
+
output: LanguageModelV3ToolResultOutput;
|
|
2281
2762
|
/**
|
|
2282
2763
|
* Additional provider-specific options. They are passed through
|
|
2283
2764
|
* to the provider from the AI SDK and enable provider-specific
|
|
2284
2765
|
* functionality that can be fully encapsulated in the provider.
|
|
2285
2766
|
*/
|
|
2286
|
-
providerOptions?:
|
|
2767
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
2287
2768
|
}
|
|
2288
|
-
|
|
2769
|
+
/**
|
|
2770
|
+
* Tool approval response content part of a prompt. It contains the user's
|
|
2771
|
+
* decision to approve or deny a provider-executed tool call.
|
|
2772
|
+
*/
|
|
2773
|
+
interface LanguageModelV3ToolApprovalResponsePart {
|
|
2774
|
+
type: 'tool-approval-response';
|
|
2775
|
+
/**
|
|
2776
|
+
* ID of the approval request that this response refers to.
|
|
2777
|
+
*/
|
|
2778
|
+
approvalId: string;
|
|
2779
|
+
/**
|
|
2780
|
+
* Whether the approval was granted (true) or denied (false).
|
|
2781
|
+
*/
|
|
2782
|
+
approved: boolean;
|
|
2783
|
+
/**
|
|
2784
|
+
* Optional reason for approval or denial.
|
|
2785
|
+
*/
|
|
2786
|
+
reason?: string;
|
|
2787
|
+
/**
|
|
2788
|
+
* Additional provider-specific options. They are passed through
|
|
2789
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
2790
|
+
* functionality that can be fully encapsulated in the provider.
|
|
2791
|
+
*/
|
|
2792
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
2793
|
+
}
|
|
2794
|
+
/**
|
|
2795
|
+
* Result of a tool call.
|
|
2796
|
+
*/
|
|
2797
|
+
type LanguageModelV3ToolResultOutput = {
|
|
2798
|
+
/**
|
|
2799
|
+
* Text tool output that should be directly sent to the API.
|
|
2800
|
+
*/
|
|
2289
2801
|
type: 'text';
|
|
2290
2802
|
value: string;
|
|
2803
|
+
/**
|
|
2804
|
+
* Provider-specific options.
|
|
2805
|
+
*/
|
|
2806
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
2291
2807
|
} | {
|
|
2292
2808
|
type: 'json';
|
|
2293
2809
|
value: JSONValue;
|
|
2810
|
+
/**
|
|
2811
|
+
* Provider-specific options.
|
|
2812
|
+
*/
|
|
2813
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
2814
|
+
} | {
|
|
2815
|
+
/**
|
|
2816
|
+
* Type when the user has denied the execution of the tool call.
|
|
2817
|
+
*/
|
|
2818
|
+
type: 'execution-denied';
|
|
2819
|
+
/**
|
|
2820
|
+
* Optional reason for the execution denial.
|
|
2821
|
+
*/
|
|
2822
|
+
reason?: string;
|
|
2823
|
+
/**
|
|
2824
|
+
* Provider-specific options.
|
|
2825
|
+
*/
|
|
2826
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
2294
2827
|
} | {
|
|
2295
2828
|
type: 'error-text';
|
|
2296
2829
|
value: string;
|
|
2830
|
+
/**
|
|
2831
|
+
* Provider-specific options.
|
|
2832
|
+
*/
|
|
2833
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
2297
2834
|
} | {
|
|
2298
2835
|
type: 'error-json';
|
|
2299
2836
|
value: JSONValue;
|
|
2837
|
+
/**
|
|
2838
|
+
* Provider-specific options.
|
|
2839
|
+
*/
|
|
2840
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
2300
2841
|
} | {
|
|
2301
2842
|
type: 'content';
|
|
2302
2843
|
value: Array<{
|
|
@@ -2305,8 +2846,12 @@ type LanguageModelV2ToolResultOutput = {
|
|
|
2305
2846
|
* Text content.
|
|
2306
2847
|
*/
|
|
2307
2848
|
text: string;
|
|
2849
|
+
/**
|
|
2850
|
+
* Provider-specific options.
|
|
2851
|
+
*/
|
|
2852
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
2308
2853
|
} | {
|
|
2309
|
-
type: '
|
|
2854
|
+
type: 'file-data';
|
|
2310
2855
|
/**
|
|
2311
2856
|
* Base-64 encoded media data.
|
|
2312
2857
|
*/
|
|
@@ -2316,73 +2861,169 @@ type LanguageModelV2ToolResultOutput = {
|
|
|
2316
2861
|
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
2317
2862
|
*/
|
|
2318
2863
|
mediaType: string;
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2864
|
+
/**
|
|
2865
|
+
* Optional filename of the file.
|
|
2866
|
+
*/
|
|
2867
|
+
filename?: string;
|
|
2868
|
+
/**
|
|
2869
|
+
* Provider-specific options.
|
|
2870
|
+
*/
|
|
2871
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
2872
|
+
} | {
|
|
2873
|
+
type: 'file-url';
|
|
2874
|
+
/**
|
|
2875
|
+
* URL of the file.
|
|
2876
|
+
*/
|
|
2877
|
+
url: string;
|
|
2878
|
+
/**
|
|
2879
|
+
* Provider-specific options.
|
|
2880
|
+
*/
|
|
2881
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
2882
|
+
} | {
|
|
2883
|
+
type: 'file-id';
|
|
2884
|
+
/**
|
|
2885
|
+
* ID of the file.
|
|
2886
|
+
*
|
|
2887
|
+
* If you use multiple providers, you need to
|
|
2888
|
+
* specify the provider specific ids using
|
|
2889
|
+
* the Record option. The key is the provider
|
|
2890
|
+
* name, e.g. 'openai' or 'anthropic'.
|
|
2891
|
+
*/
|
|
2892
|
+
fileId: string | Record<string, string>;
|
|
2893
|
+
/**
|
|
2894
|
+
* Provider-specific options.
|
|
2895
|
+
*/
|
|
2896
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
2897
|
+
} | {
|
|
2898
|
+
/**
|
|
2899
|
+
* Images that are referenced using base64 encoded data.
|
|
2900
|
+
*/
|
|
2901
|
+
type: 'image-data';
|
|
2902
|
+
/**
|
|
2903
|
+
* Base-64 encoded image data.
|
|
2904
|
+
*/
|
|
2905
|
+
data: string;
|
|
2906
|
+
/**
|
|
2907
|
+
* IANA media type.
|
|
2908
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
2909
|
+
*/
|
|
2910
|
+
mediaType: string;
|
|
2911
|
+
/**
|
|
2912
|
+
* Provider-specific options.
|
|
2913
|
+
*/
|
|
2914
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
2915
|
+
} | {
|
|
2916
|
+
/**
|
|
2917
|
+
* Images that are referenced using a URL.
|
|
2918
|
+
*/
|
|
2919
|
+
type: 'image-url';
|
|
2920
|
+
/**
|
|
2921
|
+
* URL of the image.
|
|
2922
|
+
*/
|
|
2923
|
+
url: string;
|
|
2924
|
+
/**
|
|
2925
|
+
* Provider-specific options.
|
|
2926
|
+
*/
|
|
2927
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
2928
|
+
} | {
|
|
2929
|
+
/**
|
|
2930
|
+
* Images that are referenced using a provider file id.
|
|
2931
|
+
*/
|
|
2932
|
+
type: 'image-file-id';
|
|
2933
|
+
/**
|
|
2934
|
+
* Image that is referenced using a provider file id.
|
|
2935
|
+
*
|
|
2936
|
+
* If you use multiple providers, you need to
|
|
2937
|
+
* specify the provider specific ids using
|
|
2938
|
+
* the Record option. The key is the provider
|
|
2939
|
+
* name, e.g. 'openai' or 'anthropic'.
|
|
2940
|
+
*/
|
|
2941
|
+
fileId: string | Record<string, string>;
|
|
2942
|
+
/**
|
|
2943
|
+
* Provider-specific options.
|
|
2944
|
+
*/
|
|
2945
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
2946
|
+
} | {
|
|
2947
|
+
/**
|
|
2948
|
+
* Custom content part. This can be used to implement
|
|
2949
|
+
* provider-specific content parts.
|
|
2950
|
+
*/
|
|
2951
|
+
type: 'custom';
|
|
2952
|
+
/**
|
|
2953
|
+
* Provider-specific options.
|
|
2954
|
+
*/
|
|
2955
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
2956
|
+
}>;
|
|
2957
|
+
};
|
|
2958
|
+
|
|
2959
|
+
/**
|
|
2960
|
+
* The configuration of a provider tool.
|
|
2961
|
+
*
|
|
2962
|
+
* Provider tools are tools that are specific to a certain provider.
|
|
2963
|
+
* The input and output schemas are defined be the provider, and
|
|
2964
|
+
* some of the tools are also executed on the provider systems.
|
|
2965
|
+
*/
|
|
2966
|
+
type LanguageModelV3ProviderTool = {
|
|
2967
|
+
/**
|
|
2968
|
+
* The type of the tool (always 'provider').
|
|
2969
|
+
*/
|
|
2970
|
+
type: 'provider';
|
|
2971
|
+
/**
|
|
2972
|
+
* The ID of the tool. Should follow the format `<provider-id>.<unique-tool-name>`.
|
|
2973
|
+
*/
|
|
2974
|
+
id: `${string}.${string}`;
|
|
2975
|
+
/**
|
|
2976
|
+
* The name of the tool. Unique within this model call.
|
|
2977
|
+
*/
|
|
2978
|
+
name: string;
|
|
2979
|
+
/**
|
|
2980
|
+
* The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
|
|
2981
|
+
*/
|
|
2982
|
+
args: Record<string, unknown>;
|
|
2983
|
+
};
|
|
2984
|
+
|
|
2985
|
+
type LanguageModelV3ToolChoice = {
|
|
2986
|
+
type: 'auto';
|
|
2987
|
+
} | {
|
|
2988
|
+
type: 'none';
|
|
2989
|
+
} | {
|
|
2990
|
+
type: 'required';
|
|
2991
|
+
} | {
|
|
2992
|
+
type: 'tool';
|
|
2993
|
+
toolName: string;
|
|
2994
|
+
};
|
|
2995
|
+
|
|
2996
|
+
type LanguageModelV3CallOptions = {
|
|
2997
|
+
/**
|
|
2998
|
+
* A language mode prompt is a standardized prompt type.
|
|
2999
|
+
*
|
|
3000
|
+
* Note: This is **not** the user-facing prompt. The AI SDK methods will map the
|
|
3001
|
+
* user-facing prompt types such as chat or instruction prompts to this format.
|
|
3002
|
+
* That approach allows us to evolve the user facing prompts without breaking
|
|
3003
|
+
* the language model interface.
|
|
3004
|
+
*/
|
|
3005
|
+
prompt: LanguageModelV3Prompt;
|
|
3006
|
+
/**
|
|
3007
|
+
* Maximum number of tokens to generate.
|
|
3008
|
+
*/
|
|
3009
|
+
maxOutputTokens?: number;
|
|
3010
|
+
/**
|
|
3011
|
+
* Temperature setting. The range depends on the provider and model.
|
|
3012
|
+
*/
|
|
3013
|
+
temperature?: number;
|
|
3014
|
+
/**
|
|
3015
|
+
* Stop sequences.
|
|
3016
|
+
* If set, the model will stop generating text when one of the stop sequences is generated.
|
|
3017
|
+
* Providers may have limits on the number of stop sequences.
|
|
3018
|
+
*/
|
|
3019
|
+
stopSequences?: string[];
|
|
3020
|
+
/**
|
|
3021
|
+
* Nucleus sampling.
|
|
3022
|
+
*/
|
|
3023
|
+
topP?: number;
|
|
3024
|
+
/**
|
|
3025
|
+
* Only sample from the top K options for each subsequent token.
|
|
3026
|
+
*
|
|
2386
3027
|
* Used to remove "long tail" low probability responses.
|
|
2387
3028
|
* Recommended for advanced use cases only. You usually only need to use temperature.
|
|
2388
3029
|
*/
|
|
@@ -2427,11 +3068,11 @@ type LanguageModelV2CallOptions = {
|
|
|
2427
3068
|
/**
|
|
2428
3069
|
* The tools that are available for the model.
|
|
2429
3070
|
*/
|
|
2430
|
-
tools?: Array<
|
|
3071
|
+
tools?: Array<LanguageModelV3FunctionTool | LanguageModelV3ProviderTool>;
|
|
2431
3072
|
/**
|
|
2432
3073
|
* Specifies how the tool should be selected. Defaults to 'auto'.
|
|
2433
3074
|
*/
|
|
2434
|
-
toolChoice?:
|
|
3075
|
+
toolChoice?: LanguageModelV3ToolChoice;
|
|
2435
3076
|
/**
|
|
2436
3077
|
* Include raw chunks in the stream. Only applicable for streaming calls.
|
|
2437
3078
|
*/
|
|
@@ -2450,24 +3091,7 @@ type LanguageModelV2CallOptions = {
|
|
|
2450
3091
|
* to the provider from the AI SDK and enable provider-specific
|
|
2451
3092
|
* functionality that can be fully encapsulated in the provider.
|
|
2452
3093
|
*/
|
|
2453
|
-
providerOptions?:
|
|
2454
|
-
};
|
|
2455
|
-
|
|
2456
|
-
/**
|
|
2457
|
-
* Warning from the model provider for this call. The call will proceed, but e.g.
|
|
2458
|
-
* some settings might not be supported, which can lead to suboptimal results.
|
|
2459
|
-
*/
|
|
2460
|
-
type LanguageModelV2CallWarning = {
|
|
2461
|
-
type: 'unsupported-setting';
|
|
2462
|
-
setting: Omit<keyof LanguageModelV2CallOptions, 'prompt'>;
|
|
2463
|
-
details?: string;
|
|
2464
|
-
} | {
|
|
2465
|
-
type: 'unsupported-tool';
|
|
2466
|
-
tool: LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool;
|
|
2467
|
-
details?: string;
|
|
2468
|
-
} | {
|
|
2469
|
-
type: 'other';
|
|
2470
|
-
message: string;
|
|
3094
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
2471
3095
|
};
|
|
2472
3096
|
|
|
2473
3097
|
/**
|
|
@@ -2475,7 +3099,7 @@ type LanguageModelV2CallWarning = {
|
|
|
2475
3099
|
* Generated files as base64 encoded strings or binary data.
|
|
2476
3100
|
* The files should be returned without any unnecessary conversion.
|
|
2477
3101
|
*/
|
|
2478
|
-
type
|
|
3102
|
+
type LanguageModelV3File = {
|
|
2479
3103
|
type: 'file';
|
|
2480
3104
|
/**
|
|
2481
3105
|
* The IANA media type of the file, e.g. `image/png` or `audio/mp3`.
|
|
@@ -2492,24 +3116,28 @@ type LanguageModelV2File = {
|
|
|
2492
3116
|
* be returned as binary data.
|
|
2493
3117
|
*/
|
|
2494
3118
|
data: string | Uint8Array;
|
|
3119
|
+
/**
|
|
3120
|
+
* Optional provider-specific metadata for the file part.
|
|
3121
|
+
*/
|
|
3122
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
2495
3123
|
};
|
|
2496
3124
|
|
|
2497
3125
|
/**
|
|
2498
3126
|
* Reasoning that the model has generated.
|
|
2499
3127
|
*/
|
|
2500
|
-
type
|
|
3128
|
+
type LanguageModelV3Reasoning = {
|
|
2501
3129
|
type: 'reasoning';
|
|
2502
3130
|
text: string;
|
|
2503
3131
|
/**
|
|
2504
3132
|
* Optional provider-specific metadata for the reasoning part.
|
|
2505
3133
|
*/
|
|
2506
|
-
providerMetadata?:
|
|
3134
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
2507
3135
|
};
|
|
2508
3136
|
|
|
2509
3137
|
/**
|
|
2510
3138
|
* A source that has been used as input to generate the response.
|
|
2511
3139
|
*/
|
|
2512
|
-
type
|
|
3140
|
+
type LanguageModelV3Source = {
|
|
2513
3141
|
type: 'source';
|
|
2514
3142
|
/**
|
|
2515
3143
|
* The type of source - URL sources reference web content.
|
|
@@ -2530,7 +3158,7 @@ type LanguageModelV2Source = {
|
|
|
2530
3158
|
/**
|
|
2531
3159
|
* Additional provider metadata for the source.
|
|
2532
3160
|
*/
|
|
2533
|
-
providerMetadata?:
|
|
3161
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
2534
3162
|
} | {
|
|
2535
3163
|
type: 'source';
|
|
2536
3164
|
/**
|
|
@@ -2556,25 +3184,48 @@ type LanguageModelV2Source = {
|
|
|
2556
3184
|
/**
|
|
2557
3185
|
* Additional provider metadata for the source.
|
|
2558
3186
|
*/
|
|
2559
|
-
providerMetadata?:
|
|
3187
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
2560
3188
|
};
|
|
2561
3189
|
|
|
2562
3190
|
/**
|
|
2563
3191
|
* Text that the model has generated.
|
|
2564
3192
|
*/
|
|
2565
|
-
type
|
|
3193
|
+
type LanguageModelV3Text = {
|
|
2566
3194
|
type: 'text';
|
|
2567
3195
|
/**
|
|
2568
3196
|
* The text content.
|
|
2569
3197
|
*/
|
|
2570
3198
|
text: string;
|
|
2571
|
-
providerMetadata?:
|
|
3199
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
3200
|
+
};
|
|
3201
|
+
|
|
3202
|
+
/**
|
|
3203
|
+
* Tool approval request emitted by a provider for a provider-executed tool call.
|
|
3204
|
+
*
|
|
3205
|
+
* This is used for flows where the provider executes the tool (e.g. MCP tools)
|
|
3206
|
+
* but requires an explicit user approval before continuing.
|
|
3207
|
+
*/
|
|
3208
|
+
type LanguageModelV3ToolApprovalRequest = {
|
|
3209
|
+
type: 'tool-approval-request';
|
|
3210
|
+
/**
|
|
3211
|
+
* ID of the approval request. This ID is referenced by the subsequent
|
|
3212
|
+
* tool-approval-response (tool message) to approve or deny execution.
|
|
3213
|
+
*/
|
|
3214
|
+
approvalId: string;
|
|
3215
|
+
/**
|
|
3216
|
+
* The tool call ID that this approval request is for.
|
|
3217
|
+
*/
|
|
3218
|
+
toolCallId: string;
|
|
3219
|
+
/**
|
|
3220
|
+
* Additional provider-specific metadata for the approval request.
|
|
3221
|
+
*/
|
|
3222
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
2572
3223
|
};
|
|
2573
3224
|
|
|
2574
3225
|
/**
|
|
2575
3226
|
* Tool calls that the model has generated.
|
|
2576
3227
|
*/
|
|
2577
|
-
type
|
|
3228
|
+
type LanguageModelV3ToolCall = {
|
|
2578
3229
|
type: 'tool-call';
|
|
2579
3230
|
/**
|
|
2580
3231
|
* The identifier of the tool call. It must be unique across all tool calls.
|
|
@@ -2594,16 +3245,21 @@ type LanguageModelV2ToolCall = {
|
|
|
2594
3245
|
* If this flag is not set or is false, the tool call will be executed by the client.
|
|
2595
3246
|
*/
|
|
2596
3247
|
providerExecuted?: boolean;
|
|
3248
|
+
/**
|
|
3249
|
+
* Whether the tool is dynamic, i.e. defined at runtime.
|
|
3250
|
+
* For example, MCP (Model Context Protocol) tools that are executed by the provider.
|
|
3251
|
+
*/
|
|
3252
|
+
dynamic?: boolean;
|
|
2597
3253
|
/**
|
|
2598
3254
|
* Additional provider-specific metadata for the tool call.
|
|
2599
3255
|
*/
|
|
2600
|
-
providerMetadata?:
|
|
3256
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
2601
3257
|
};
|
|
2602
3258
|
|
|
2603
3259
|
/**
|
|
2604
3260
|
* Result of a tool call that has been executed by the provider.
|
|
2605
3261
|
*/
|
|
2606
|
-
type
|
|
3262
|
+
type LanguageModelV3ToolResult = {
|
|
2607
3263
|
type: 'tool-result';
|
|
2608
3264
|
/**
|
|
2609
3265
|
* The ID of the tool call that this result is associated with.
|
|
@@ -2616,40 +3272,62 @@ type LanguageModelV2ToolResult = {
|
|
|
2616
3272
|
/**
|
|
2617
3273
|
* Result of the tool call. This is a JSON-serializable object.
|
|
2618
3274
|
*/
|
|
2619
|
-
result:
|
|
3275
|
+
result: NonNullable<JSONValue>;
|
|
2620
3276
|
/**
|
|
2621
3277
|
* Optional flag if the result is an error or an error message.
|
|
2622
3278
|
*/
|
|
2623
3279
|
isError?: boolean;
|
|
2624
3280
|
/**
|
|
2625
|
-
* Whether the tool result
|
|
2626
|
-
*
|
|
2627
|
-
*
|
|
3281
|
+
* Whether the tool result is preliminary.
|
|
3282
|
+
*
|
|
3283
|
+
* Preliminary tool results replace each other, e.g. image previews.
|
|
3284
|
+
* There always has to be a final, non-preliminary tool result.
|
|
3285
|
+
*
|
|
3286
|
+
* If this flag is set to true, the tool result is preliminary.
|
|
3287
|
+
* If this flag is not set or is false, the tool result is not preliminary.
|
|
2628
3288
|
*/
|
|
2629
|
-
|
|
3289
|
+
preliminary?: boolean;
|
|
2630
3290
|
/**
|
|
2631
|
-
*
|
|
2632
|
-
|
|
2633
|
-
|
|
3291
|
+
* Whether the tool is dynamic, i.e. defined at runtime.
|
|
3292
|
+
* For example, MCP (Model Context Protocol) tools that are executed by the provider.
|
|
3293
|
+
*/
|
|
3294
|
+
dynamic?: boolean;
|
|
3295
|
+
/**
|
|
3296
|
+
* Additional provider-specific metadata for the tool result.
|
|
3297
|
+
*/
|
|
3298
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
2634
3299
|
};
|
|
2635
3300
|
|
|
2636
|
-
type
|
|
3301
|
+
type LanguageModelV3Content = LanguageModelV3Text | LanguageModelV3Reasoning | LanguageModelV3File | LanguageModelV3ToolApprovalRequest | LanguageModelV3Source | LanguageModelV3ToolCall | LanguageModelV3ToolResult;
|
|
2637
3302
|
|
|
2638
3303
|
/**
|
|
2639
3304
|
* Reason why a language model finished generating a response.
|
|
2640
3305
|
*
|
|
2641
|
-
*
|
|
2642
|
-
*
|
|
2643
|
-
*
|
|
2644
|
-
* - `content-filter`: content filter violation stopped the model
|
|
2645
|
-
* - `tool-calls`: model triggered tool calls
|
|
2646
|
-
* - `error`: model stopped because of an error
|
|
2647
|
-
* - `other`: model stopped for other reasons
|
|
2648
|
-
* - `unknown`: the model has not transmitted a finish reason
|
|
3306
|
+
* Contains both a unified finish reason and a raw finish reason from the provider.
|
|
3307
|
+
* The unified finish reason is used to provide a consistent finish reason across different providers.
|
|
3308
|
+
* The raw finish reason is used to provide the original finish reason from the provider.
|
|
2649
3309
|
*/
|
|
2650
|
-
type
|
|
3310
|
+
type LanguageModelV3FinishReason = {
|
|
3311
|
+
/**
|
|
3312
|
+
* Unified finish reason. This enables using the same finish reason across different providers.
|
|
3313
|
+
*
|
|
3314
|
+
* Can be one of the following:
|
|
3315
|
+
* - `stop`: model generated stop sequence
|
|
3316
|
+
* - `length`: model generated maximum number of tokens
|
|
3317
|
+
* - `content-filter`: content filter violation stopped the model
|
|
3318
|
+
* - `tool-calls`: model triggered tool calls
|
|
3319
|
+
* - `error`: model stopped because of an error
|
|
3320
|
+
* - `other`: model stopped for other reasons
|
|
3321
|
+
*/
|
|
3322
|
+
unified: 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other';
|
|
3323
|
+
/**
|
|
3324
|
+
* Raw finish reason from the provider.
|
|
3325
|
+
* This is the original finish reason from the provider.
|
|
3326
|
+
*/
|
|
3327
|
+
raw: string | undefined;
|
|
3328
|
+
};
|
|
2651
3329
|
|
|
2652
|
-
interface
|
|
3330
|
+
interface LanguageModelV3ResponseMetadata {
|
|
2653
3331
|
/**
|
|
2654
3332
|
* ID for the generated response, if the provider sends one.
|
|
2655
3333
|
*/
|
|
@@ -2666,86 +3344,158 @@ interface LanguageModelV2ResponseMetadata {
|
|
|
2666
3344
|
|
|
2667
3345
|
/**
|
|
2668
3346
|
* Usage information for a language model call.
|
|
2669
|
-
*
|
|
2670
|
-
* If your API return additional usage information, you can add it to the
|
|
2671
|
-
* provider metadata under your provider's key.
|
|
2672
3347
|
*/
|
|
2673
|
-
type
|
|
3348
|
+
type LanguageModelV3Usage = {
|
|
2674
3349
|
/**
|
|
2675
|
-
*
|
|
3350
|
+
* Information about the input tokens.
|
|
2676
3351
|
*/
|
|
2677
|
-
inputTokens:
|
|
3352
|
+
inputTokens: {
|
|
3353
|
+
/**
|
|
3354
|
+
* The total number of input (prompt) tokens used.
|
|
3355
|
+
*/
|
|
3356
|
+
total: number | undefined;
|
|
3357
|
+
/**
|
|
3358
|
+
* The number of non-cached input (prompt) tokens used.
|
|
3359
|
+
*/
|
|
3360
|
+
noCache: number | undefined;
|
|
3361
|
+
/**
|
|
3362
|
+
* The number of cached input (prompt) tokens read.
|
|
3363
|
+
*/
|
|
3364
|
+
cacheRead: number | undefined;
|
|
3365
|
+
/**
|
|
3366
|
+
* The number of cached input (prompt) tokens written.
|
|
3367
|
+
*/
|
|
3368
|
+
cacheWrite: number | undefined;
|
|
3369
|
+
};
|
|
2678
3370
|
/**
|
|
2679
|
-
*
|
|
3371
|
+
* Information about the output tokens.
|
|
2680
3372
|
*/
|
|
2681
|
-
outputTokens:
|
|
3373
|
+
outputTokens: {
|
|
3374
|
+
/**
|
|
3375
|
+
* The total number of output (completion) tokens used.
|
|
3376
|
+
*/
|
|
3377
|
+
total: number | undefined;
|
|
3378
|
+
/**
|
|
3379
|
+
* The number of text tokens used.
|
|
3380
|
+
*/
|
|
3381
|
+
text: number | undefined;
|
|
3382
|
+
/**
|
|
3383
|
+
* The number of reasoning tokens used.
|
|
3384
|
+
*/
|
|
3385
|
+
reasoning: number | undefined;
|
|
3386
|
+
};
|
|
2682
3387
|
/**
|
|
2683
|
-
*
|
|
2684
|
-
*
|
|
2685
|
-
*
|
|
3388
|
+
* Raw usage information from the provider.
|
|
3389
|
+
*
|
|
3390
|
+
* This is the usage information in the shape that the provider returns.
|
|
3391
|
+
* It can include additional information that is not part of the standard usage information.
|
|
2686
3392
|
*/
|
|
2687
|
-
|
|
3393
|
+
raw?: JSONObject;
|
|
3394
|
+
};
|
|
3395
|
+
|
|
3396
|
+
/**
|
|
3397
|
+
* The result of a language model doGenerate call.
|
|
3398
|
+
*/
|
|
3399
|
+
type LanguageModelV3GenerateResult = {
|
|
2688
3400
|
/**
|
|
2689
|
-
*
|
|
3401
|
+
* Ordered content that the model has generated.
|
|
2690
3402
|
*/
|
|
2691
|
-
|
|
3403
|
+
content: Array<LanguageModelV3Content>;
|
|
2692
3404
|
/**
|
|
2693
|
-
* The
|
|
3405
|
+
* The finish reason.
|
|
2694
3406
|
*/
|
|
2695
|
-
|
|
3407
|
+
finishReason: LanguageModelV3FinishReason;
|
|
3408
|
+
/**
|
|
3409
|
+
* The usage information.
|
|
3410
|
+
*/
|
|
3411
|
+
usage: LanguageModelV3Usage;
|
|
3412
|
+
/**
|
|
3413
|
+
* Additional provider-specific metadata. They are passed through
|
|
3414
|
+
* from the provider to the AI SDK and enable provider-specific
|
|
3415
|
+
* results that can be fully encapsulated in the provider.
|
|
3416
|
+
*/
|
|
3417
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
3418
|
+
/**
|
|
3419
|
+
* Optional request information for telemetry and debugging purposes.
|
|
3420
|
+
*/
|
|
3421
|
+
request?: {
|
|
3422
|
+
/**
|
|
3423
|
+
* Request HTTP body that was sent to the provider API.
|
|
3424
|
+
*/
|
|
3425
|
+
body?: unknown;
|
|
3426
|
+
};
|
|
3427
|
+
/**
|
|
3428
|
+
* Optional response information for telemetry and debugging purposes.
|
|
3429
|
+
*/
|
|
3430
|
+
response?: LanguageModelV3ResponseMetadata & {
|
|
3431
|
+
/**
|
|
3432
|
+
* Response headers.
|
|
3433
|
+
*/
|
|
3434
|
+
headers?: SharedV3Headers;
|
|
3435
|
+
/**
|
|
3436
|
+
* Response HTTP body.
|
|
3437
|
+
*/
|
|
3438
|
+
body?: unknown;
|
|
3439
|
+
};
|
|
3440
|
+
/**
|
|
3441
|
+
* Warnings for the call, e.g. unsupported settings.
|
|
3442
|
+
*/
|
|
3443
|
+
warnings: Array<SharedV3Warning>;
|
|
2696
3444
|
};
|
|
2697
3445
|
|
|
2698
|
-
type
|
|
3446
|
+
type LanguageModelV3StreamPart = {
|
|
2699
3447
|
type: 'text-start';
|
|
2700
|
-
providerMetadata?:
|
|
3448
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
2701
3449
|
id: string;
|
|
2702
3450
|
} | {
|
|
2703
3451
|
type: 'text-delta';
|
|
2704
3452
|
id: string;
|
|
2705
|
-
providerMetadata?:
|
|
3453
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
2706
3454
|
delta: string;
|
|
2707
3455
|
} | {
|
|
2708
3456
|
type: 'text-end';
|
|
2709
|
-
providerMetadata?:
|
|
3457
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
2710
3458
|
id: string;
|
|
2711
3459
|
} | {
|
|
2712
3460
|
type: 'reasoning-start';
|
|
2713
|
-
providerMetadata?:
|
|
3461
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
2714
3462
|
id: string;
|
|
2715
3463
|
} | {
|
|
2716
3464
|
type: 'reasoning-delta';
|
|
2717
3465
|
id: string;
|
|
2718
|
-
providerMetadata?:
|
|
3466
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
2719
3467
|
delta: string;
|
|
2720
3468
|
} | {
|
|
2721
3469
|
type: 'reasoning-end';
|
|
2722
3470
|
id: string;
|
|
2723
|
-
providerMetadata?:
|
|
3471
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
2724
3472
|
} | {
|
|
2725
3473
|
type: 'tool-input-start';
|
|
2726
3474
|
id: string;
|
|
2727
3475
|
toolName: string;
|
|
2728
|
-
providerMetadata?:
|
|
3476
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
2729
3477
|
providerExecuted?: boolean;
|
|
3478
|
+
dynamic?: boolean;
|
|
3479
|
+
title?: string;
|
|
2730
3480
|
} | {
|
|
2731
3481
|
type: 'tool-input-delta';
|
|
2732
3482
|
id: string;
|
|
2733
3483
|
delta: string;
|
|
2734
|
-
providerMetadata?:
|
|
3484
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
2735
3485
|
} | {
|
|
2736
3486
|
type: 'tool-input-end';
|
|
2737
3487
|
id: string;
|
|
2738
|
-
providerMetadata?:
|
|
2739
|
-
} |
|
|
3488
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
3489
|
+
} | LanguageModelV3ToolApprovalRequest | LanguageModelV3ToolCall | LanguageModelV3ToolResult | LanguageModelV3File | LanguageModelV3Source | {
|
|
2740
3490
|
type: 'stream-start';
|
|
2741
|
-
warnings: Array<
|
|
3491
|
+
warnings: Array<SharedV3Warning>;
|
|
2742
3492
|
} | ({
|
|
2743
3493
|
type: 'response-metadata';
|
|
2744
|
-
} &
|
|
3494
|
+
} & LanguageModelV3ResponseMetadata) | {
|
|
2745
3495
|
type: 'finish';
|
|
2746
|
-
usage:
|
|
2747
|
-
finishReason:
|
|
2748
|
-
providerMetadata?:
|
|
3496
|
+
usage: LanguageModelV3Usage;
|
|
3497
|
+
finishReason: LanguageModelV3FinishReason;
|
|
3498
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
2749
3499
|
} | {
|
|
2750
3500
|
type: 'raw';
|
|
2751
3501
|
rawValue: unknown;
|
|
@@ -2755,19 +3505,47 @@ type LanguageModelV2StreamPart = {
|
|
|
2755
3505
|
};
|
|
2756
3506
|
|
|
2757
3507
|
/**
|
|
2758
|
-
*
|
|
3508
|
+
* The result of a language model doStream call.
|
|
2759
3509
|
*/
|
|
2760
|
-
type
|
|
3510
|
+
type LanguageModelV3StreamResult = {
|
|
3511
|
+
/**
|
|
3512
|
+
* The stream.
|
|
3513
|
+
*/
|
|
3514
|
+
stream: ReadableStream<LanguageModelV3StreamPart>;
|
|
3515
|
+
/**
|
|
3516
|
+
* Optional request information for telemetry and debugging purposes.
|
|
3517
|
+
*/
|
|
3518
|
+
request?: {
|
|
3519
|
+
/**
|
|
3520
|
+
* Request HTTP body that was sent to the provider API.
|
|
3521
|
+
*/
|
|
3522
|
+
body?: unknown;
|
|
3523
|
+
};
|
|
3524
|
+
/**
|
|
3525
|
+
* Optional response data.
|
|
3526
|
+
*/
|
|
3527
|
+
response?: {
|
|
3528
|
+
/**
|
|
3529
|
+
* Response headers.
|
|
3530
|
+
*/
|
|
3531
|
+
headers?: SharedV3Headers;
|
|
3532
|
+
};
|
|
3533
|
+
};
|
|
3534
|
+
|
|
3535
|
+
/**
|
|
3536
|
+
* Specification for a language model that implements the language model interface version 3.
|
|
3537
|
+
*/
|
|
3538
|
+
type LanguageModelV3 = {
|
|
2761
3539
|
/**
|
|
2762
3540
|
* The language model must specify which language model interface version it implements.
|
|
2763
3541
|
*/
|
|
2764
|
-
readonly specificationVersion: '
|
|
3542
|
+
readonly specificationVersion: 'v3';
|
|
2765
3543
|
/**
|
|
2766
|
-
*
|
|
3544
|
+
* Provider ID.
|
|
2767
3545
|
*/
|
|
2768
3546
|
readonly provider: string;
|
|
2769
3547
|
/**
|
|
2770
|
-
* Provider-specific model ID
|
|
3548
|
+
* Provider-specific model ID.
|
|
2771
3549
|
*/
|
|
2772
3550
|
readonly modelId: string;
|
|
2773
3551
|
/**
|
|
@@ -2785,117 +3563,52 @@ type LanguageModelV2 = {
|
|
|
2785
3563
|
supportedUrls: PromiseLike<Record<string, RegExp[]>> | Record<string, RegExp[]>;
|
|
2786
3564
|
/**
|
|
2787
3565
|
* Generates a language model output (non-streaming).
|
|
3566
|
+
|
|
3567
|
+
* Naming: "do" prefix to prevent accidental direct usage of the method
|
|
3568
|
+
* by the user.
|
|
3569
|
+
*/
|
|
3570
|
+
doGenerate(options: LanguageModelV3CallOptions): PromiseLike<LanguageModelV3GenerateResult>;
|
|
3571
|
+
/**
|
|
3572
|
+
* Generates a language model output (streaming).
|
|
2788
3573
|
*
|
|
2789
3574
|
* Naming: "do" prefix to prevent accidental direct usage of the method
|
|
2790
3575
|
* by the user.
|
|
3576
|
+
*
|
|
3577
|
+
* @return A stream of higher-level language model output parts.
|
|
2791
3578
|
*/
|
|
2792
|
-
|
|
2793
|
-
/**
|
|
2794
|
-
* Ordered content that the model has generated.
|
|
2795
|
-
*/
|
|
2796
|
-
content: Array<LanguageModelV2Content>;
|
|
2797
|
-
/**
|
|
2798
|
-
* Finish reason.
|
|
2799
|
-
*/
|
|
2800
|
-
finishReason: LanguageModelV2FinishReason;
|
|
2801
|
-
/**
|
|
2802
|
-
* Usage information.
|
|
2803
|
-
*/
|
|
2804
|
-
usage: LanguageModelV2Usage;
|
|
2805
|
-
/**
|
|
2806
|
-
* Additional provider-specific metadata. They are passed through
|
|
2807
|
-
* from the provider to the AI SDK and enable provider-specific
|
|
2808
|
-
* results that can be fully encapsulated in the provider.
|
|
2809
|
-
*/
|
|
2810
|
-
providerMetadata?: SharedV2ProviderMetadata;
|
|
2811
|
-
/**
|
|
2812
|
-
* Optional request information for telemetry and debugging purposes.
|
|
2813
|
-
*/
|
|
2814
|
-
request?: {
|
|
2815
|
-
/**
|
|
2816
|
-
* Request HTTP body that was sent to the provider API.
|
|
2817
|
-
*/
|
|
2818
|
-
body?: unknown;
|
|
2819
|
-
};
|
|
2820
|
-
/**
|
|
2821
|
-
* Optional response information for telemetry and debugging purposes.
|
|
2822
|
-
*/
|
|
2823
|
-
response?: LanguageModelV2ResponseMetadata & {
|
|
2824
|
-
/**
|
|
2825
|
-
* Response headers.
|
|
2826
|
-
*/
|
|
2827
|
-
headers?: SharedV2Headers;
|
|
2828
|
-
/**
|
|
2829
|
-
* Response HTTP body.
|
|
2830
|
-
*/
|
|
2831
|
-
body?: unknown;
|
|
2832
|
-
};
|
|
2833
|
-
/**
|
|
2834
|
-
* Warnings for the call, e.g. unsupported settings.
|
|
2835
|
-
*/
|
|
2836
|
-
warnings: Array<LanguageModelV2CallWarning>;
|
|
2837
|
-
}>;
|
|
2838
|
-
/**
|
|
2839
|
-
* Generates a language model output (streaming).
|
|
2840
|
-
*
|
|
2841
|
-
* Naming: "do" prefix to prevent accidental direct usage of the method
|
|
2842
|
-
* by the user.
|
|
2843
|
-
*
|
|
2844
|
-
* @return A stream of higher-level language model output parts.
|
|
2845
|
-
*/
|
|
2846
|
-
doStream(options: LanguageModelV2CallOptions): PromiseLike<{
|
|
2847
|
-
stream: ReadableStream<LanguageModelV2StreamPart>;
|
|
2848
|
-
/**
|
|
2849
|
-
* Optional request information for telemetry and debugging purposes.
|
|
2850
|
-
*/
|
|
2851
|
-
request?: {
|
|
2852
|
-
/**
|
|
2853
|
-
* Request HTTP body that was sent to the provider API.
|
|
2854
|
-
*/
|
|
2855
|
-
body?: unknown;
|
|
2856
|
-
};
|
|
2857
|
-
/**
|
|
2858
|
-
* Optional response data.
|
|
2859
|
-
*/
|
|
2860
|
-
response?: {
|
|
2861
|
-
/**
|
|
2862
|
-
* Response headers.
|
|
2863
|
-
*/
|
|
2864
|
-
headers?: SharedV2Headers;
|
|
2865
|
-
};
|
|
2866
|
-
}>;
|
|
3579
|
+
doStream(options: LanguageModelV3CallOptions): PromiseLike<LanguageModelV3StreamResult>;
|
|
2867
3580
|
};
|
|
2868
3581
|
|
|
2869
3582
|
/**
|
|
2870
|
-
* Experimental middleware for
|
|
3583
|
+
* Experimental middleware for LanguageModelV3.
|
|
2871
3584
|
* This type defines the structure for middleware that can be used to modify
|
|
2872
|
-
* the behavior of
|
|
3585
|
+
* the behavior of LanguageModelV3 operations.
|
|
2873
3586
|
*/
|
|
2874
|
-
type
|
|
3587
|
+
type LanguageModelV3Middleware = {
|
|
2875
3588
|
/**
|
|
2876
|
-
* Middleware specification version. Use `
|
|
3589
|
+
* Middleware specification version. Use `v3` for the current version.
|
|
2877
3590
|
*/
|
|
2878
|
-
|
|
3591
|
+
readonly specificationVersion: 'v3';
|
|
2879
3592
|
/**
|
|
2880
3593
|
* Override the provider name if desired.
|
|
2881
3594
|
* @param options.model - The language model instance.
|
|
2882
3595
|
*/
|
|
2883
3596
|
overrideProvider?: (options: {
|
|
2884
|
-
model:
|
|
3597
|
+
model: LanguageModelV3;
|
|
2885
3598
|
}) => string;
|
|
2886
3599
|
/**
|
|
2887
3600
|
* Override the model ID if desired.
|
|
2888
3601
|
* @param options.model - The language model instance.
|
|
2889
3602
|
*/
|
|
2890
3603
|
overrideModelId?: (options: {
|
|
2891
|
-
model:
|
|
3604
|
+
model: LanguageModelV3;
|
|
2892
3605
|
}) => string;
|
|
2893
3606
|
/**
|
|
2894
3607
|
* Override the supported URLs if desired.
|
|
2895
3608
|
* @param options.model - The language model instance.
|
|
2896
3609
|
*/
|
|
2897
3610
|
overrideSupportedUrls?: (options: {
|
|
2898
|
-
model:
|
|
3611
|
+
model: LanguageModelV3;
|
|
2899
3612
|
}) => PromiseLike<Record<string, RegExp[]>> | Record<string, RegExp[]>;
|
|
2900
3613
|
/**
|
|
2901
3614
|
* Transforms the parameters before they are passed to the language model.
|
|
@@ -2906,9 +3619,9 @@ type LanguageModelV2Middleware = {
|
|
|
2906
3619
|
*/
|
|
2907
3620
|
transformParams?: (options: {
|
|
2908
3621
|
type: 'generate' | 'stream';
|
|
2909
|
-
params:
|
|
2910
|
-
model:
|
|
2911
|
-
}) => PromiseLike<
|
|
3622
|
+
params: LanguageModelV3CallOptions;
|
|
3623
|
+
model: LanguageModelV3;
|
|
3624
|
+
}) => PromiseLike<LanguageModelV3CallOptions>;
|
|
2912
3625
|
/**
|
|
2913
3626
|
* Wraps the generate operation of the language model.
|
|
2914
3627
|
* @param options - Object containing the generate function, parameters, and model.
|
|
@@ -2920,11 +3633,11 @@ type LanguageModelV2Middleware = {
|
|
|
2920
3633
|
* @returns A promise that resolves to the result of the generate operation.
|
|
2921
3634
|
*/
|
|
2922
3635
|
wrapGenerate?: (options: {
|
|
2923
|
-
doGenerate: () =>
|
|
2924
|
-
doStream: () =>
|
|
2925
|
-
params:
|
|
2926
|
-
model:
|
|
2927
|
-
}) =>
|
|
3636
|
+
doGenerate: () => PromiseLike<LanguageModelV3GenerateResult>;
|
|
3637
|
+
doStream: () => PromiseLike<LanguageModelV3StreamResult>;
|
|
3638
|
+
params: LanguageModelV3CallOptions;
|
|
3639
|
+
model: LanguageModelV3;
|
|
3640
|
+
}) => PromiseLike<LanguageModelV3GenerateResult>;
|
|
2928
3641
|
/**
|
|
2929
3642
|
* Wraps the stream operation of the language model.
|
|
2930
3643
|
*
|
|
@@ -2937,77 +3650,1422 @@ type LanguageModelV2Middleware = {
|
|
|
2937
3650
|
* @returns A promise that resolves to the result of the stream operation.
|
|
2938
3651
|
*/
|
|
2939
3652
|
wrapStream?: (options: {
|
|
2940
|
-
doGenerate: () =>
|
|
2941
|
-
doStream: () =>
|
|
2942
|
-
params:
|
|
2943
|
-
model:
|
|
2944
|
-
}) => PromiseLike<
|
|
3653
|
+
doGenerate: () => PromiseLike<LanguageModelV3GenerateResult>;
|
|
3654
|
+
doStream: () => PromiseLike<LanguageModelV3StreamResult>;
|
|
3655
|
+
params: LanguageModelV3CallOptions;
|
|
3656
|
+
model: LanguageModelV3;
|
|
3657
|
+
}) => PromiseLike<LanguageModelV3StreamResult>;
|
|
2945
3658
|
};
|
|
2946
3659
|
|
|
2947
3660
|
/**
|
|
2948
|
-
*
|
|
2949
|
-
*
|
|
2950
|
-
* the
|
|
3661
|
+
* A tool has a name, a description, and a set of parameters.
|
|
3662
|
+
*
|
|
3663
|
+
* Note: this is **not** the user-facing tool definition. The AI SDK methods will
|
|
3664
|
+
* map the user-facing tool definitions to this format.
|
|
2951
3665
|
*/
|
|
2952
|
-
type
|
|
3666
|
+
type LanguageModelV2FunctionTool = {
|
|
2953
3667
|
/**
|
|
2954
|
-
*
|
|
3668
|
+
* The type of the tool (always 'function').
|
|
2955
3669
|
*/
|
|
2956
|
-
|
|
3670
|
+
type: 'function';
|
|
2957
3671
|
/**
|
|
2958
|
-
*
|
|
2959
|
-
* @param options.model - The embedding model instance.
|
|
3672
|
+
* The name of the tool. Unique within this model call.
|
|
2960
3673
|
*/
|
|
2961
|
-
|
|
2962
|
-
model: EmbeddingModelV3;
|
|
2963
|
-
}) => string;
|
|
3674
|
+
name: string;
|
|
2964
3675
|
/**
|
|
2965
|
-
*
|
|
2966
|
-
*
|
|
3676
|
+
* A description of the tool. The language model uses this to understand the
|
|
3677
|
+
* tool's purpose and to provide better completion suggestions.
|
|
2967
3678
|
*/
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
3679
|
+
description?: string;
|
|
3680
|
+
/**
|
|
3681
|
+
* The parameters that the tool expects. The language model uses this to
|
|
3682
|
+
* understand the tool's input requirements and to provide matching suggestions.
|
|
3683
|
+
*/
|
|
3684
|
+
inputSchema: JSONSchema7;
|
|
3685
|
+
/**
|
|
3686
|
+
* The provider-specific options for the tool.
|
|
3687
|
+
*/
|
|
3688
|
+
providerOptions?: SharedV2ProviderOptions;
|
|
3689
|
+
};
|
|
3690
|
+
|
|
3691
|
+
/**
|
|
3692
|
+
* Data content. Can be a Uint8Array, base64 encoded data as a string or a URL.
|
|
3693
|
+
*/
|
|
3694
|
+
type LanguageModelV2DataContent = Uint8Array | string | URL;
|
|
3695
|
+
|
|
3696
|
+
/**
|
|
3697
|
+
* A prompt is a list of messages.
|
|
3698
|
+
*
|
|
3699
|
+
* Note: Not all models and prompt formats support multi-modal inputs and
|
|
3700
|
+
* tool calls. The validation happens at runtime.
|
|
3701
|
+
*
|
|
3702
|
+
* Note: This is not a user-facing prompt. The AI SDK methods will map the
|
|
3703
|
+
* user-facing prompt types such as chat or instruction prompts to this format.
|
|
3704
|
+
*/
|
|
3705
|
+
type LanguageModelV2Prompt = Array<LanguageModelV2Message>;
|
|
3706
|
+
type LanguageModelV2Message = ({
|
|
3707
|
+
role: 'system';
|
|
3708
|
+
content: string;
|
|
3709
|
+
} | {
|
|
3710
|
+
role: 'user';
|
|
3711
|
+
content: Array<LanguageModelV2TextPart | LanguageModelV2FilePart>;
|
|
3712
|
+
} | {
|
|
3713
|
+
role: 'assistant';
|
|
3714
|
+
content: Array<LanguageModelV2TextPart | LanguageModelV2FilePart | LanguageModelV2ReasoningPart | LanguageModelV2ToolCallPart | LanguageModelV2ToolResultPart>;
|
|
3715
|
+
} | {
|
|
3716
|
+
role: 'tool';
|
|
3717
|
+
content: Array<LanguageModelV2ToolResultPart>;
|
|
3718
|
+
}) & {
|
|
3719
|
+
/**
|
|
3720
|
+
* Additional provider-specific options. They are passed through
|
|
3721
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
3722
|
+
* functionality that can be fully encapsulated in the provider.
|
|
3723
|
+
*/
|
|
3724
|
+
providerOptions?: SharedV2ProviderOptions;
|
|
3725
|
+
};
|
|
3726
|
+
/**
|
|
3727
|
+
* Text content part of a prompt. It contains a string of text.
|
|
3728
|
+
*/
|
|
3729
|
+
interface LanguageModelV2TextPart {
|
|
3730
|
+
type: 'text';
|
|
3731
|
+
/**
|
|
3732
|
+
* The text content.
|
|
3733
|
+
*/
|
|
3734
|
+
text: string;
|
|
3735
|
+
/**
|
|
3736
|
+
* Additional provider-specific options. They are passed through
|
|
3737
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
3738
|
+
* functionality that can be fully encapsulated in the provider.
|
|
3739
|
+
*/
|
|
3740
|
+
providerOptions?: SharedV2ProviderOptions;
|
|
3741
|
+
}
|
|
3742
|
+
/**
|
|
3743
|
+
* Reasoning content part of a prompt. It contains a string of reasoning text.
|
|
3744
|
+
*/
|
|
3745
|
+
interface LanguageModelV2ReasoningPart {
|
|
3746
|
+
type: 'reasoning';
|
|
3747
|
+
/**
|
|
3748
|
+
* The reasoning text.
|
|
3749
|
+
*/
|
|
3750
|
+
text: string;
|
|
3751
|
+
/**
|
|
3752
|
+
* Additional provider-specific options. They are passed through
|
|
3753
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
3754
|
+
* functionality that can be fully encapsulated in the provider.
|
|
3755
|
+
*/
|
|
3756
|
+
providerOptions?: SharedV2ProviderOptions;
|
|
3757
|
+
}
|
|
3758
|
+
/**
|
|
3759
|
+
* File content part of a prompt. It contains a file.
|
|
3760
|
+
*/
|
|
3761
|
+
interface LanguageModelV2FilePart {
|
|
3762
|
+
type: 'file';
|
|
3763
|
+
/**
|
|
3764
|
+
* Optional filename of the file.
|
|
3765
|
+
*/
|
|
3766
|
+
filename?: string;
|
|
3767
|
+
/**
|
|
3768
|
+
* File data. Can be a Uint8Array, base64 encoded data as a string or a URL.
|
|
3769
|
+
*/
|
|
3770
|
+
data: LanguageModelV2DataContent;
|
|
3771
|
+
/**
|
|
3772
|
+
* IANA media type of the file.
|
|
3773
|
+
*
|
|
3774
|
+
* Can support wildcards, e.g. `image/*` (in which case the provider needs to take appropriate action).
|
|
3775
|
+
*
|
|
3776
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
3777
|
+
*/
|
|
3778
|
+
mediaType: string;
|
|
3779
|
+
/**
|
|
3780
|
+
* Additional provider-specific options. They are passed through
|
|
3781
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
3782
|
+
* functionality that can be fully encapsulated in the provider.
|
|
3783
|
+
*/
|
|
3784
|
+
providerOptions?: SharedV2ProviderOptions;
|
|
3785
|
+
}
|
|
3786
|
+
/**
|
|
3787
|
+
* Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
|
|
3788
|
+
*/
|
|
3789
|
+
interface LanguageModelV2ToolCallPart {
|
|
3790
|
+
type: 'tool-call';
|
|
3791
|
+
/**
|
|
3792
|
+
* ID of the tool call. This ID is used to match the tool call with the tool result.
|
|
3793
|
+
*/
|
|
3794
|
+
toolCallId: string;
|
|
3795
|
+
/**
|
|
3796
|
+
* Name of the tool that is being called.
|
|
3797
|
+
*/
|
|
3798
|
+
toolName: string;
|
|
3799
|
+
/**
|
|
3800
|
+
* Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
|
|
3801
|
+
*/
|
|
3802
|
+
input: unknown;
|
|
3803
|
+
/**
|
|
3804
|
+
* Whether the tool call will be executed by the provider.
|
|
3805
|
+
* If this flag is not set or is false, the tool call will be executed by the client.
|
|
3806
|
+
*/
|
|
3807
|
+
providerExecuted?: boolean;
|
|
3808
|
+
/**
|
|
3809
|
+
* Additional provider-specific options. They are passed through
|
|
3810
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
3811
|
+
* functionality that can be fully encapsulated in the provider.
|
|
3812
|
+
*/
|
|
3813
|
+
providerOptions?: SharedV2ProviderOptions;
|
|
3814
|
+
}
|
|
3815
|
+
/**
|
|
3816
|
+
* Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
|
|
3817
|
+
*/
|
|
3818
|
+
interface LanguageModelV2ToolResultPart {
|
|
3819
|
+
type: 'tool-result';
|
|
3820
|
+
/**
|
|
3821
|
+
* ID of the tool call that this result is associated with.
|
|
3822
|
+
*/
|
|
3823
|
+
toolCallId: string;
|
|
3824
|
+
/**
|
|
3825
|
+
* Name of the tool that generated this result.
|
|
3826
|
+
*/
|
|
3827
|
+
toolName: string;
|
|
3828
|
+
/**
|
|
3829
|
+
* Result of the tool call.
|
|
3830
|
+
*/
|
|
3831
|
+
output: LanguageModelV2ToolResultOutput;
|
|
3832
|
+
/**
|
|
3833
|
+
* Additional provider-specific options. They are passed through
|
|
3834
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
3835
|
+
* functionality that can be fully encapsulated in the provider.
|
|
3836
|
+
*/
|
|
3837
|
+
providerOptions?: SharedV2ProviderOptions;
|
|
3838
|
+
}
|
|
3839
|
+
type LanguageModelV2ToolResultOutput = {
|
|
3840
|
+
type: 'text';
|
|
3841
|
+
value: string;
|
|
3842
|
+
} | {
|
|
3843
|
+
type: 'json';
|
|
3844
|
+
value: JSONValue;
|
|
3845
|
+
} | {
|
|
3846
|
+
type: 'error-text';
|
|
3847
|
+
value: string;
|
|
3848
|
+
} | {
|
|
3849
|
+
type: 'error-json';
|
|
3850
|
+
value: JSONValue;
|
|
3851
|
+
} | {
|
|
3852
|
+
type: 'content';
|
|
3853
|
+
value: Array<{
|
|
3854
|
+
type: 'text';
|
|
3855
|
+
/**
|
|
3856
|
+
* Text content.
|
|
3857
|
+
*/
|
|
3858
|
+
text: string;
|
|
3859
|
+
} | {
|
|
3860
|
+
type: 'media';
|
|
3861
|
+
/**
|
|
3862
|
+
* Base-64 encoded media data.
|
|
3863
|
+
*/
|
|
3864
|
+
data: string;
|
|
3865
|
+
/**
|
|
3866
|
+
* IANA media type.
|
|
3867
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
3868
|
+
*/
|
|
3869
|
+
mediaType: string;
|
|
3870
|
+
}>;
|
|
3871
|
+
};
|
|
3872
|
+
|
|
3873
|
+
/**
|
|
3874
|
+
* The configuration of a tool that is defined by the provider.
|
|
3875
|
+
*/
|
|
3876
|
+
type LanguageModelV2ProviderDefinedTool = {
|
|
3877
|
+
/**
|
|
3878
|
+
* The type of the tool (always 'provider-defined').
|
|
3879
|
+
*/
|
|
3880
|
+
type: 'provider-defined';
|
|
3881
|
+
/**
|
|
3882
|
+
* The ID of the tool. Should follow the format `<provider-name>.<unique-tool-name>`.
|
|
3883
|
+
*/
|
|
3884
|
+
id: `${string}.${string}`;
|
|
3885
|
+
/**
|
|
3886
|
+
* The name of the tool that the user must use in the tool set.
|
|
3887
|
+
*/
|
|
3888
|
+
name: string;
|
|
3889
|
+
/**
|
|
3890
|
+
* The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
|
|
3891
|
+
*/
|
|
3892
|
+
args: Record<string, unknown>;
|
|
3893
|
+
};
|
|
3894
|
+
|
|
3895
|
+
type LanguageModelV2ToolChoice = {
|
|
3896
|
+
type: 'auto';
|
|
3897
|
+
} | {
|
|
3898
|
+
type: 'none';
|
|
3899
|
+
} | {
|
|
3900
|
+
type: 'required';
|
|
3901
|
+
} | {
|
|
3902
|
+
type: 'tool';
|
|
3903
|
+
toolName: string;
|
|
3904
|
+
};
|
|
3905
|
+
|
|
3906
|
+
type LanguageModelV2CallOptions = {
|
|
3907
|
+
/**
|
|
3908
|
+
* A language mode prompt is a standardized prompt type.
|
|
3909
|
+
*
|
|
3910
|
+
* Note: This is **not** the user-facing prompt. The AI SDK methods will map the
|
|
3911
|
+
* user-facing prompt types such as chat or instruction prompts to this format.
|
|
3912
|
+
* That approach allows us to evolve the user facing prompts without breaking
|
|
3913
|
+
* the language model interface.
|
|
3914
|
+
*/
|
|
3915
|
+
prompt: LanguageModelV2Prompt;
|
|
3916
|
+
/**
|
|
3917
|
+
* Maximum number of tokens to generate.
|
|
3918
|
+
*/
|
|
3919
|
+
maxOutputTokens?: number;
|
|
3920
|
+
/**
|
|
3921
|
+
* Temperature setting. The range depends on the provider and model.
|
|
3922
|
+
*/
|
|
3923
|
+
temperature?: number;
|
|
3924
|
+
/**
|
|
3925
|
+
* Stop sequences.
|
|
3926
|
+
* If set, the model will stop generating text when one of the stop sequences is generated.
|
|
3927
|
+
* Providers may have limits on the number of stop sequences.
|
|
3928
|
+
*/
|
|
3929
|
+
stopSequences?: string[];
|
|
3930
|
+
/**
|
|
3931
|
+
* Nucleus sampling.
|
|
3932
|
+
*/
|
|
3933
|
+
topP?: number;
|
|
3934
|
+
/**
|
|
3935
|
+
* Only sample from the top K options for each subsequent token.
|
|
3936
|
+
*
|
|
3937
|
+
* Used to remove "long tail" low probability responses.
|
|
3938
|
+
* Recommended for advanced use cases only. You usually only need to use temperature.
|
|
3939
|
+
*/
|
|
3940
|
+
topK?: number;
|
|
3941
|
+
/**
|
|
3942
|
+
* Presence penalty setting. It affects the likelihood of the model to
|
|
3943
|
+
* repeat information that is already in the prompt.
|
|
3944
|
+
*/
|
|
3945
|
+
presencePenalty?: number;
|
|
3946
|
+
/**
|
|
3947
|
+
* Frequency penalty setting. It affects the likelihood of the model
|
|
3948
|
+
* to repeatedly use the same words or phrases.
|
|
3949
|
+
*/
|
|
3950
|
+
frequencyPenalty?: number;
|
|
3951
|
+
/**
|
|
3952
|
+
* Response format. The output can either be text or JSON. Default is text.
|
|
3953
|
+
*
|
|
3954
|
+
* If JSON is selected, a schema can optionally be provided to guide the LLM.
|
|
3955
|
+
*/
|
|
3956
|
+
responseFormat?: {
|
|
3957
|
+
type: 'text';
|
|
3958
|
+
} | {
|
|
3959
|
+
type: 'json';
|
|
3960
|
+
/**
|
|
3961
|
+
* JSON schema that the generated output should conform to.
|
|
3962
|
+
*/
|
|
3963
|
+
schema?: JSONSchema7;
|
|
3964
|
+
/**
|
|
3965
|
+
* Name of output that should be generated. Used by some providers for additional LLM guidance.
|
|
3966
|
+
*/
|
|
3967
|
+
name?: string;
|
|
3968
|
+
/**
|
|
3969
|
+
* Description of the output that should be generated. Used by some providers for additional LLM guidance.
|
|
3970
|
+
*/
|
|
3971
|
+
description?: string;
|
|
3972
|
+
};
|
|
3973
|
+
/**
|
|
3974
|
+
* The seed (integer) to use for random sampling. If set and supported
|
|
3975
|
+
* by the model, calls will generate deterministic results.
|
|
3976
|
+
*/
|
|
3977
|
+
seed?: number;
|
|
3978
|
+
/**
|
|
3979
|
+
* The tools that are available for the model.
|
|
3980
|
+
*/
|
|
3981
|
+
tools?: Array<LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool>;
|
|
3982
|
+
/**
|
|
3983
|
+
* Specifies how the tool should be selected. Defaults to 'auto'.
|
|
3984
|
+
*/
|
|
3985
|
+
toolChoice?: LanguageModelV2ToolChoice;
|
|
3986
|
+
/**
|
|
3987
|
+
* Include raw chunks in the stream. Only applicable for streaming calls.
|
|
3988
|
+
*/
|
|
3989
|
+
includeRawChunks?: boolean;
|
|
3990
|
+
/**
|
|
3991
|
+
* Abort signal for cancelling the operation.
|
|
3992
|
+
*/
|
|
3993
|
+
abortSignal?: AbortSignal;
|
|
3994
|
+
/**
|
|
3995
|
+
* Additional HTTP headers to be sent with the request.
|
|
3996
|
+
* Only applicable for HTTP-based providers.
|
|
3997
|
+
*/
|
|
3998
|
+
headers?: Record<string, string | undefined>;
|
|
3999
|
+
/**
|
|
4000
|
+
* Additional provider-specific options. They are passed through
|
|
4001
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
4002
|
+
* functionality that can be fully encapsulated in the provider.
|
|
4003
|
+
*/
|
|
4004
|
+
providerOptions?: SharedV2ProviderOptions;
|
|
4005
|
+
};
|
|
4006
|
+
|
|
4007
|
+
/**
|
|
4008
|
+
* Warning from the model provider for this call. The call will proceed, but e.g.
|
|
4009
|
+
* some settings might not be supported, which can lead to suboptimal results.
|
|
4010
|
+
*/
|
|
4011
|
+
type LanguageModelV2CallWarning = {
|
|
4012
|
+
type: 'unsupported-setting';
|
|
4013
|
+
setting: Omit<keyof LanguageModelV2CallOptions, 'prompt'>;
|
|
4014
|
+
details?: string;
|
|
4015
|
+
} | {
|
|
4016
|
+
type: 'unsupported-tool';
|
|
4017
|
+
tool: LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool;
|
|
4018
|
+
details?: string;
|
|
4019
|
+
} | {
|
|
4020
|
+
type: 'other';
|
|
4021
|
+
message: string;
|
|
4022
|
+
};
|
|
4023
|
+
|
|
4024
|
+
/**
|
|
4025
|
+
* A file that has been generated by the model.
|
|
4026
|
+
* Generated files as base64 encoded strings or binary data.
|
|
4027
|
+
* The files should be returned without any unnecessary conversion.
|
|
4028
|
+
*/
|
|
4029
|
+
type LanguageModelV2File = {
|
|
4030
|
+
type: 'file';
|
|
4031
|
+
/**
|
|
4032
|
+
* The IANA media type of the file, e.g. `image/png` or `audio/mp3`.
|
|
4033
|
+
*
|
|
4034
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
4035
|
+
*/
|
|
4036
|
+
mediaType: string;
|
|
4037
|
+
/**
|
|
4038
|
+
* Generated file data as base64 encoded strings or binary data.
|
|
4039
|
+
*
|
|
4040
|
+
* The file data should be returned without any unnecessary conversion.
|
|
4041
|
+
* If the API returns base64 encoded strings, the file data should be returned
|
|
4042
|
+
* as base64 encoded strings. If the API returns binary data, the file data should
|
|
4043
|
+
* be returned as binary data.
|
|
4044
|
+
*/
|
|
4045
|
+
data: string | Uint8Array;
|
|
4046
|
+
};
|
|
4047
|
+
|
|
4048
|
+
/**
|
|
4049
|
+
* Reasoning that the model has generated.
|
|
4050
|
+
*/
|
|
4051
|
+
type LanguageModelV2Reasoning = {
|
|
4052
|
+
type: 'reasoning';
|
|
4053
|
+
text: string;
|
|
4054
|
+
/**
|
|
4055
|
+
* Optional provider-specific metadata for the reasoning part.
|
|
4056
|
+
*/
|
|
4057
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
4058
|
+
};
|
|
4059
|
+
|
|
4060
|
+
/**
|
|
4061
|
+
* A source that has been used as input to generate the response.
|
|
4062
|
+
*/
|
|
4063
|
+
type LanguageModelV2Source = {
|
|
4064
|
+
type: 'source';
|
|
4065
|
+
/**
|
|
4066
|
+
* The type of source - URL sources reference web content.
|
|
4067
|
+
*/
|
|
4068
|
+
sourceType: 'url';
|
|
4069
|
+
/**
|
|
4070
|
+
* The ID of the source.
|
|
4071
|
+
*/
|
|
4072
|
+
id: string;
|
|
4073
|
+
/**
|
|
4074
|
+
* The URL of the source.
|
|
4075
|
+
*/
|
|
4076
|
+
url: string;
|
|
4077
|
+
/**
|
|
4078
|
+
* The title of the source.
|
|
4079
|
+
*/
|
|
4080
|
+
title?: string;
|
|
4081
|
+
/**
|
|
4082
|
+
* Additional provider metadata for the source.
|
|
4083
|
+
*/
|
|
4084
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
4085
|
+
} | {
|
|
4086
|
+
type: 'source';
|
|
4087
|
+
/**
|
|
4088
|
+
* The type of source - document sources reference files/documents.
|
|
4089
|
+
*/
|
|
4090
|
+
sourceType: 'document';
|
|
4091
|
+
/**
|
|
4092
|
+
* The ID of the source.
|
|
4093
|
+
*/
|
|
4094
|
+
id: string;
|
|
4095
|
+
/**
|
|
4096
|
+
* IANA media type of the document (e.g., 'application/pdf').
|
|
4097
|
+
*/
|
|
4098
|
+
mediaType: string;
|
|
4099
|
+
/**
|
|
4100
|
+
* The title of the document.
|
|
4101
|
+
*/
|
|
4102
|
+
title: string;
|
|
4103
|
+
/**
|
|
4104
|
+
* Optional filename of the document.
|
|
4105
|
+
*/
|
|
4106
|
+
filename?: string;
|
|
4107
|
+
/**
|
|
4108
|
+
* Additional provider metadata for the source.
|
|
4109
|
+
*/
|
|
4110
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
4111
|
+
};
|
|
4112
|
+
|
|
4113
|
+
/**
|
|
4114
|
+
* Text that the model has generated.
|
|
4115
|
+
*/
|
|
4116
|
+
type LanguageModelV2Text = {
|
|
4117
|
+
type: 'text';
|
|
4118
|
+
/**
|
|
4119
|
+
* The text content.
|
|
4120
|
+
*/
|
|
4121
|
+
text: string;
|
|
4122
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
4123
|
+
};
|
|
4124
|
+
|
|
4125
|
+
/**
|
|
4126
|
+
* Tool calls that the model has generated.
|
|
4127
|
+
*/
|
|
4128
|
+
type LanguageModelV2ToolCall = {
|
|
4129
|
+
type: 'tool-call';
|
|
4130
|
+
/**
|
|
4131
|
+
* The identifier of the tool call. It must be unique across all tool calls.
|
|
4132
|
+
*/
|
|
4133
|
+
toolCallId: string;
|
|
4134
|
+
/**
|
|
4135
|
+
* The name of the tool that should be called.
|
|
4136
|
+
*/
|
|
4137
|
+
toolName: string;
|
|
4138
|
+
/**
|
|
4139
|
+
* Stringified JSON object with the tool call arguments. Must match the
|
|
4140
|
+
* parameters schema of the tool.
|
|
4141
|
+
*/
|
|
4142
|
+
input: string;
|
|
4143
|
+
/**
|
|
4144
|
+
* Whether the tool call will be executed by the provider.
|
|
4145
|
+
* If this flag is not set or is false, the tool call will be executed by the client.
|
|
4146
|
+
*/
|
|
4147
|
+
providerExecuted?: boolean;
|
|
4148
|
+
/**
|
|
4149
|
+
* Additional provider-specific metadata for the tool call.
|
|
4150
|
+
*/
|
|
4151
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
4152
|
+
};
|
|
4153
|
+
|
|
4154
|
+
/**
|
|
4155
|
+
* Result of a tool call that has been executed by the provider.
|
|
4156
|
+
*/
|
|
4157
|
+
type LanguageModelV2ToolResult = {
|
|
4158
|
+
type: 'tool-result';
|
|
4159
|
+
/**
|
|
4160
|
+
* The ID of the tool call that this result is associated with.
|
|
4161
|
+
*/
|
|
4162
|
+
toolCallId: string;
|
|
4163
|
+
/**
|
|
4164
|
+
* Name of the tool that generated this result.
|
|
4165
|
+
*/
|
|
4166
|
+
toolName: string;
|
|
4167
|
+
/**
|
|
4168
|
+
* Result of the tool call. This is a JSON-serializable object.
|
|
4169
|
+
*/
|
|
4170
|
+
result: unknown;
|
|
4171
|
+
/**
|
|
4172
|
+
* Optional flag if the result is an error or an error message.
|
|
4173
|
+
*/
|
|
4174
|
+
isError?: boolean;
|
|
4175
|
+
/**
|
|
4176
|
+
* Whether the tool result was generated by the provider.
|
|
4177
|
+
* If this flag is set to true, the tool result was generated by the provider.
|
|
4178
|
+
* If this flag is not set or is false, the tool result was generated by the client.
|
|
4179
|
+
*/
|
|
4180
|
+
providerExecuted?: boolean;
|
|
4181
|
+
/**
|
|
4182
|
+
* Additional provider-specific metadata for the tool result.
|
|
4183
|
+
*/
|
|
4184
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
4185
|
+
};
|
|
4186
|
+
|
|
4187
|
+
type LanguageModelV2Content = LanguageModelV2Text | LanguageModelV2Reasoning | LanguageModelV2File | LanguageModelV2Source | LanguageModelV2ToolCall | LanguageModelV2ToolResult;
|
|
4188
|
+
|
|
4189
|
+
/**
|
|
4190
|
+
* Reason why a language model finished generating a response.
|
|
4191
|
+
*
|
|
4192
|
+
* Can be one of the following:
|
|
4193
|
+
* - `stop`: model generated stop sequence
|
|
4194
|
+
* - `length`: model generated maximum number of tokens
|
|
4195
|
+
* - `content-filter`: content filter violation stopped the model
|
|
4196
|
+
* - `tool-calls`: model triggered tool calls
|
|
4197
|
+
* - `error`: model stopped because of an error
|
|
4198
|
+
* - `other`: model stopped for other reasons
|
|
4199
|
+
* - `unknown`: the model has not transmitted a finish reason
|
|
4200
|
+
*/
|
|
4201
|
+
type LanguageModelV2FinishReason = 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other' | 'unknown';
|
|
4202
|
+
|
|
4203
|
+
interface LanguageModelV2ResponseMetadata {
|
|
4204
|
+
/**
|
|
4205
|
+
* ID for the generated response, if the provider sends one.
|
|
4206
|
+
*/
|
|
4207
|
+
id?: string;
|
|
4208
|
+
/**
|
|
4209
|
+
* Timestamp for the start of the generated response, if the provider sends one.
|
|
4210
|
+
*/
|
|
4211
|
+
timestamp?: Date;
|
|
4212
|
+
/**
|
|
4213
|
+
* The ID of the response model that was used to generate the response, if the provider sends one.
|
|
4214
|
+
*/
|
|
4215
|
+
modelId?: string;
|
|
4216
|
+
}
|
|
4217
|
+
|
|
4218
|
+
/**
|
|
4219
|
+
* Usage information for a language model call.
|
|
4220
|
+
*
|
|
4221
|
+
* If your API return additional usage information, you can add it to the
|
|
4222
|
+
* provider metadata under your provider's key.
|
|
4223
|
+
*/
|
|
4224
|
+
type LanguageModelV2Usage = {
|
|
4225
|
+
/**
|
|
4226
|
+
* The number of input (prompt) tokens used.
|
|
4227
|
+
*/
|
|
4228
|
+
inputTokens: number | undefined;
|
|
4229
|
+
/**
|
|
4230
|
+
* The number of output (completion) tokens used.
|
|
4231
|
+
*/
|
|
4232
|
+
outputTokens: number | undefined;
|
|
4233
|
+
/**
|
|
4234
|
+
* The total number of tokens as reported by the provider.
|
|
4235
|
+
* This number might be different from the sum of `inputTokens` and `outputTokens`
|
|
4236
|
+
* and e.g. include reasoning tokens or other overhead.
|
|
4237
|
+
*/
|
|
4238
|
+
totalTokens: number | undefined;
|
|
4239
|
+
/**
|
|
4240
|
+
* The number of reasoning tokens used.
|
|
4241
|
+
*/
|
|
4242
|
+
reasoningTokens?: number | undefined;
|
|
4243
|
+
/**
|
|
4244
|
+
* The number of cached input tokens.
|
|
4245
|
+
*/
|
|
4246
|
+
cachedInputTokens?: number | undefined;
|
|
4247
|
+
};
|
|
4248
|
+
|
|
4249
|
+
type LanguageModelV2StreamPart = {
|
|
4250
|
+
type: 'text-start';
|
|
4251
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
4252
|
+
id: string;
|
|
4253
|
+
} | {
|
|
4254
|
+
type: 'text-delta';
|
|
4255
|
+
id: string;
|
|
4256
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
4257
|
+
delta: string;
|
|
4258
|
+
} | {
|
|
4259
|
+
type: 'text-end';
|
|
4260
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
4261
|
+
id: string;
|
|
4262
|
+
} | {
|
|
4263
|
+
type: 'reasoning-start';
|
|
4264
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
4265
|
+
id: string;
|
|
4266
|
+
} | {
|
|
4267
|
+
type: 'reasoning-delta';
|
|
4268
|
+
id: string;
|
|
4269
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
4270
|
+
delta: string;
|
|
4271
|
+
} | {
|
|
4272
|
+
type: 'reasoning-end';
|
|
4273
|
+
id: string;
|
|
4274
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
4275
|
+
} | {
|
|
4276
|
+
type: 'tool-input-start';
|
|
4277
|
+
id: string;
|
|
4278
|
+
toolName: string;
|
|
4279
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
4280
|
+
providerExecuted?: boolean;
|
|
4281
|
+
} | {
|
|
4282
|
+
type: 'tool-input-delta';
|
|
4283
|
+
id: string;
|
|
4284
|
+
delta: string;
|
|
4285
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
4286
|
+
} | {
|
|
4287
|
+
type: 'tool-input-end';
|
|
4288
|
+
id: string;
|
|
4289
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
4290
|
+
} | LanguageModelV2ToolCall | LanguageModelV2ToolResult | LanguageModelV2File | LanguageModelV2Source | {
|
|
4291
|
+
type: 'stream-start';
|
|
4292
|
+
warnings: Array<LanguageModelV2CallWarning>;
|
|
4293
|
+
} | ({
|
|
4294
|
+
type: 'response-metadata';
|
|
4295
|
+
} & LanguageModelV2ResponseMetadata) | {
|
|
4296
|
+
type: 'finish';
|
|
4297
|
+
usage: LanguageModelV2Usage;
|
|
4298
|
+
finishReason: LanguageModelV2FinishReason;
|
|
4299
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
4300
|
+
} | {
|
|
4301
|
+
type: 'raw';
|
|
4302
|
+
rawValue: unknown;
|
|
4303
|
+
} | {
|
|
4304
|
+
type: 'error';
|
|
4305
|
+
error: unknown;
|
|
4306
|
+
};
|
|
4307
|
+
|
|
4308
|
+
/**
|
|
4309
|
+
* Specification for a language model that implements the language model interface version 2.
|
|
4310
|
+
*/
|
|
4311
|
+
type LanguageModelV2 = {
|
|
4312
|
+
/**
|
|
4313
|
+
* The language model must specify which language model interface version it implements.
|
|
4314
|
+
*/
|
|
4315
|
+
readonly specificationVersion: 'v2';
|
|
4316
|
+
/**
|
|
4317
|
+
* Name of the provider for logging purposes.
|
|
4318
|
+
*/
|
|
4319
|
+
readonly provider: string;
|
|
4320
|
+
/**
|
|
4321
|
+
* Provider-specific model ID for logging purposes.
|
|
4322
|
+
*/
|
|
4323
|
+
readonly modelId: string;
|
|
4324
|
+
/**
|
|
4325
|
+
* Supported URL patterns by media type for the provider.
|
|
4326
|
+
*
|
|
4327
|
+
* The keys are media type patterns or full media types (e.g. `*\/*` for everything, `audio/*`, `video/*`, or `application/pdf`).
|
|
4328
|
+
* and the values are arrays of regular expressions that match the URL paths.
|
|
4329
|
+
*
|
|
4330
|
+
* The matching should be against lower-case URLs.
|
|
4331
|
+
*
|
|
4332
|
+
* Matched URLs are supported natively by the model and are not downloaded.
|
|
4333
|
+
*
|
|
4334
|
+
* @returns A map of supported URL patterns by media type (as a promise or a plain object).
|
|
4335
|
+
*/
|
|
4336
|
+
supportedUrls: PromiseLike<Record<string, RegExp[]>> | Record<string, RegExp[]>;
|
|
4337
|
+
/**
|
|
4338
|
+
* Generates a language model output (non-streaming).
|
|
4339
|
+
*
|
|
4340
|
+
* Naming: "do" prefix to prevent accidental direct usage of the method
|
|
4341
|
+
* by the user.
|
|
4342
|
+
*/
|
|
4343
|
+
doGenerate(options: LanguageModelV2CallOptions): PromiseLike<{
|
|
4344
|
+
/**
|
|
4345
|
+
* Ordered content that the model has generated.
|
|
4346
|
+
*/
|
|
4347
|
+
content: Array<LanguageModelV2Content>;
|
|
4348
|
+
/**
|
|
4349
|
+
* Finish reason.
|
|
4350
|
+
*/
|
|
4351
|
+
finishReason: LanguageModelV2FinishReason;
|
|
4352
|
+
/**
|
|
4353
|
+
* Usage information.
|
|
4354
|
+
*/
|
|
4355
|
+
usage: LanguageModelV2Usage;
|
|
4356
|
+
/**
|
|
4357
|
+
* Additional provider-specific metadata. They are passed through
|
|
4358
|
+
* from the provider to the AI SDK and enable provider-specific
|
|
4359
|
+
* results that can be fully encapsulated in the provider.
|
|
4360
|
+
*/
|
|
4361
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
4362
|
+
/**
|
|
4363
|
+
* Optional request information for telemetry and debugging purposes.
|
|
4364
|
+
*/
|
|
4365
|
+
request?: {
|
|
4366
|
+
/**
|
|
4367
|
+
* Request HTTP body that was sent to the provider API.
|
|
4368
|
+
*/
|
|
4369
|
+
body?: unknown;
|
|
4370
|
+
};
|
|
4371
|
+
/**
|
|
4372
|
+
* Optional response information for telemetry and debugging purposes.
|
|
4373
|
+
*/
|
|
4374
|
+
response?: LanguageModelV2ResponseMetadata & {
|
|
4375
|
+
/**
|
|
4376
|
+
* Response headers.
|
|
4377
|
+
*/
|
|
4378
|
+
headers?: SharedV2Headers;
|
|
4379
|
+
/**
|
|
4380
|
+
* Response HTTP body.
|
|
4381
|
+
*/
|
|
4382
|
+
body?: unknown;
|
|
4383
|
+
};
|
|
4384
|
+
/**
|
|
4385
|
+
* Warnings for the call, e.g. unsupported settings.
|
|
4386
|
+
*/
|
|
4387
|
+
warnings: Array<LanguageModelV2CallWarning>;
|
|
4388
|
+
}>;
|
|
4389
|
+
/**
|
|
4390
|
+
* Generates a language model output (streaming).
|
|
4391
|
+
*
|
|
4392
|
+
* Naming: "do" prefix to prevent accidental direct usage of the method
|
|
4393
|
+
* by the user.
|
|
4394
|
+
*
|
|
4395
|
+
* @return A stream of higher-level language model output parts.
|
|
4396
|
+
*/
|
|
4397
|
+
doStream(options: LanguageModelV2CallOptions): PromiseLike<{
|
|
4398
|
+
stream: ReadableStream<LanguageModelV2StreamPart>;
|
|
4399
|
+
/**
|
|
4400
|
+
* Optional request information for telemetry and debugging purposes.
|
|
4401
|
+
*/
|
|
4402
|
+
request?: {
|
|
4403
|
+
/**
|
|
4404
|
+
* Request HTTP body that was sent to the provider API.
|
|
4405
|
+
*/
|
|
4406
|
+
body?: unknown;
|
|
4407
|
+
};
|
|
4408
|
+
/**
|
|
4409
|
+
* Optional response data.
|
|
4410
|
+
*/
|
|
4411
|
+
response?: {
|
|
4412
|
+
/**
|
|
4413
|
+
* Response headers.
|
|
4414
|
+
*/
|
|
4415
|
+
headers?: SharedV2Headers;
|
|
4416
|
+
};
|
|
4417
|
+
}>;
|
|
4418
|
+
};
|
|
4419
|
+
|
|
4420
|
+
/**
|
|
4421
|
+
* Experimental middleware for LanguageModelV2.
|
|
4422
|
+
* This type defines the structure for middleware that can be used to modify
|
|
4423
|
+
* the behavior of LanguageModelV2 operations.
|
|
4424
|
+
*/
|
|
4425
|
+
type LanguageModelV2Middleware = {
|
|
4426
|
+
/**
|
|
4427
|
+
* Middleware specification version. Use `v2` for the current version.
|
|
4428
|
+
*/
|
|
4429
|
+
middlewareVersion?: 'v2' | undefined;
|
|
4430
|
+
/**
|
|
4431
|
+
* Override the provider name if desired.
|
|
4432
|
+
* @param options.model - The language model instance.
|
|
4433
|
+
*/
|
|
4434
|
+
overrideProvider?: (options: {
|
|
4435
|
+
model: LanguageModelV2;
|
|
4436
|
+
}) => string;
|
|
4437
|
+
/**
|
|
4438
|
+
* Override the model ID if desired.
|
|
4439
|
+
* @param options.model - The language model instance.
|
|
4440
|
+
*/
|
|
4441
|
+
overrideModelId?: (options: {
|
|
4442
|
+
model: LanguageModelV2;
|
|
4443
|
+
}) => string;
|
|
4444
|
+
/**
|
|
4445
|
+
* Override the supported URLs if desired.
|
|
4446
|
+
* @param options.model - The language model instance.
|
|
4447
|
+
*/
|
|
4448
|
+
overrideSupportedUrls?: (options: {
|
|
4449
|
+
model: LanguageModelV2;
|
|
4450
|
+
}) => PromiseLike<Record<string, RegExp[]>> | Record<string, RegExp[]>;
|
|
4451
|
+
/**
|
|
4452
|
+
* Transforms the parameters before they are passed to the language model.
|
|
4453
|
+
* @param options - Object containing the type of operation and the parameters.
|
|
4454
|
+
* @param options.type - The type of operation ('generate' or 'stream').
|
|
4455
|
+
* @param options.params - The original parameters for the language model call.
|
|
4456
|
+
* @returns A promise that resolves to the transformed parameters.
|
|
4457
|
+
*/
|
|
4458
|
+
transformParams?: (options: {
|
|
4459
|
+
type: 'generate' | 'stream';
|
|
4460
|
+
params: LanguageModelV2CallOptions;
|
|
4461
|
+
model: LanguageModelV2;
|
|
4462
|
+
}) => PromiseLike<LanguageModelV2CallOptions>;
|
|
4463
|
+
/**
|
|
4464
|
+
* Wraps the generate operation of the language model.
|
|
4465
|
+
* @param options - Object containing the generate function, parameters, and model.
|
|
4466
|
+
* @param options.doGenerate - The original generate function.
|
|
4467
|
+
* @param options.doStream - The original stream function.
|
|
4468
|
+
* @param options.params - The parameters for the generate call. If the
|
|
4469
|
+
* `transformParams` middleware is used, this will be the transformed parameters.
|
|
4470
|
+
* @param options.model - The language model instance.
|
|
4471
|
+
* @returns A promise that resolves to the result of the generate operation.
|
|
4472
|
+
*/
|
|
4473
|
+
wrapGenerate?: (options: {
|
|
4474
|
+
doGenerate: () => ReturnType<LanguageModelV2['doGenerate']>;
|
|
4475
|
+
doStream: () => ReturnType<LanguageModelV2['doStream']>;
|
|
4476
|
+
params: LanguageModelV2CallOptions;
|
|
4477
|
+
model: LanguageModelV2;
|
|
4478
|
+
}) => Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
|
|
4479
|
+
/**
|
|
4480
|
+
* Wraps the stream operation of the language model.
|
|
4481
|
+
*
|
|
4482
|
+
* @param options - Object containing the stream function, parameters, and model.
|
|
4483
|
+
* @param options.doGenerate - The original generate function.
|
|
4484
|
+
* @param options.doStream - The original stream function.
|
|
4485
|
+
* @param options.params - The parameters for the stream call. If the
|
|
4486
|
+
* `transformParams` middleware is used, this will be the transformed parameters.
|
|
4487
|
+
* @param options.model - The language model instance.
|
|
4488
|
+
* @returns A promise that resolves to the result of the stream operation.
|
|
4489
|
+
*/
|
|
4490
|
+
wrapStream?: (options: {
|
|
4491
|
+
doGenerate: () => ReturnType<LanguageModelV2['doGenerate']>;
|
|
4492
|
+
doStream: () => ReturnType<LanguageModelV2['doStream']>;
|
|
4493
|
+
params: LanguageModelV2CallOptions;
|
|
4494
|
+
model: LanguageModelV2;
|
|
4495
|
+
}) => PromiseLike<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
|
|
4496
|
+
};
|
|
4497
|
+
|
|
4498
|
+
/**
|
|
4499
|
+
* Middleware for EmbeddingModelV4.
|
|
4500
|
+
* This type defines the structure for middleware that can be used to modify
|
|
4501
|
+
* the behavior of EmbeddingModelV4 operations.
|
|
4502
|
+
*/
|
|
4503
|
+
type EmbeddingModelV4Middleware = {
|
|
4504
|
+
/**
|
|
4505
|
+
* Middleware specification version. Use `v4` for the current version.
|
|
4506
|
+
*/
|
|
4507
|
+
readonly specificationVersion: 'v4';
|
|
4508
|
+
/**
|
|
4509
|
+
* Override the provider name if desired.
|
|
4510
|
+
* @param options.model - The embedding model instance.
|
|
4511
|
+
*/
|
|
4512
|
+
overrideProvider?: (options: {
|
|
4513
|
+
model: EmbeddingModelV4;
|
|
4514
|
+
}) => string;
|
|
4515
|
+
/**
|
|
4516
|
+
* Override the model ID if desired.
|
|
4517
|
+
* @param options.model - The embedding model instance.
|
|
4518
|
+
*/
|
|
4519
|
+
overrideModelId?: (options: {
|
|
4520
|
+
model: EmbeddingModelV4;
|
|
4521
|
+
}) => string;
|
|
4522
|
+
/**
|
|
4523
|
+
* Override the limit of how many embeddings can be generated in a single API call if desired.
|
|
4524
|
+
* @param options.model - The embedding model instance.
|
|
4525
|
+
*/
|
|
4526
|
+
overrideMaxEmbeddingsPerCall?: (options: {
|
|
4527
|
+
model: EmbeddingModelV4;
|
|
4528
|
+
}) => PromiseLike<number | undefined> | number | undefined;
|
|
4529
|
+
/**
|
|
4530
|
+
* Override support for handling multiple embedding calls in parallel, if desired..
|
|
4531
|
+
* @param options.model - The embedding model instance.
|
|
4532
|
+
*/
|
|
4533
|
+
overrideSupportsParallelCalls?: (options: {
|
|
4534
|
+
model: EmbeddingModelV4;
|
|
4535
|
+
}) => PromiseLike<boolean> | boolean;
|
|
4536
|
+
/**
|
|
4537
|
+
* Transforms the parameters before they are passed to the embed model.
|
|
4538
|
+
* @param options - Object containing the type of operation and the parameters.
|
|
4539
|
+
* @param options.params - The original parameters for the embedding model call.
|
|
4540
|
+
* @returns A promise that resolves to the transformed parameters.
|
|
4541
|
+
*/
|
|
4542
|
+
transformParams?: (options: {
|
|
4543
|
+
params: EmbeddingModelV4CallOptions;
|
|
4544
|
+
model: EmbeddingModelV4;
|
|
4545
|
+
}) => PromiseLike<EmbeddingModelV4CallOptions>;
|
|
4546
|
+
/**
|
|
4547
|
+
* Wraps the embed operation of the embedding model.
|
|
4548
|
+
*
|
|
4549
|
+
* @param options - Object containing the embed function, parameters, and model.
|
|
4550
|
+
* @param options.doEmbed - The original embed function.
|
|
4551
|
+
* @param options.params - The parameters for the embed call. If the
|
|
4552
|
+
* `transformParams` middleware is used, this will be the transformed parameters.
|
|
4553
|
+
* @param options.model - The embedding model instance.
|
|
4554
|
+
* @returns A promise that resolves to the result of the generate operation.
|
|
4555
|
+
*/
|
|
4556
|
+
wrapEmbed?: (options: {
|
|
4557
|
+
doEmbed: () => ReturnType<EmbeddingModelV4['doEmbed']>;
|
|
4558
|
+
params: EmbeddingModelV4CallOptions;
|
|
4559
|
+
model: EmbeddingModelV4;
|
|
4560
|
+
}) => Promise<Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>>;
|
|
4561
|
+
};
|
|
4562
|
+
|
|
4563
|
+
/**
|
|
4564
|
+
* Middleware for EmbeddingModelV3.
|
|
4565
|
+
* This type defines the structure for middleware that can be used to modify
|
|
4566
|
+
* the behavior of EmbeddingModelV3 operations.
|
|
4567
|
+
*/
|
|
4568
|
+
type EmbeddingModelV3Middleware = {
|
|
4569
|
+
/**
|
|
4570
|
+
* Middleware specification version. Use `v3` for the current version.
|
|
4571
|
+
*/
|
|
4572
|
+
readonly specificationVersion: 'v3';
|
|
4573
|
+
/**
|
|
4574
|
+
* Override the provider name if desired.
|
|
4575
|
+
* @param options.model - The embedding model instance.
|
|
4576
|
+
*/
|
|
4577
|
+
overrideProvider?: (options: {
|
|
4578
|
+
model: EmbeddingModelV3;
|
|
4579
|
+
}) => string;
|
|
4580
|
+
/**
|
|
4581
|
+
* Override the model ID if desired.
|
|
4582
|
+
* @param options.model - The embedding model instance.
|
|
4583
|
+
*/
|
|
4584
|
+
overrideModelId?: (options: {
|
|
4585
|
+
model: EmbeddingModelV3;
|
|
4586
|
+
}) => string;
|
|
4587
|
+
/**
|
|
4588
|
+
* Override the limit of how many embeddings can be generated in a single API call if desired.
|
|
4589
|
+
* @param options.model - The embedding model instance.
|
|
4590
|
+
*/
|
|
4591
|
+
overrideMaxEmbeddingsPerCall?: (options: {
|
|
4592
|
+
model: EmbeddingModelV3;
|
|
4593
|
+
}) => PromiseLike<number | undefined> | number | undefined;
|
|
4594
|
+
/**
|
|
4595
|
+
* Override support for handling multiple embedding calls in parallel, if desired..
|
|
4596
|
+
* @param options.model - The embedding model instance.
|
|
4597
|
+
*/
|
|
4598
|
+
overrideSupportsParallelCalls?: (options: {
|
|
4599
|
+
model: EmbeddingModelV3;
|
|
4600
|
+
}) => PromiseLike<boolean> | boolean;
|
|
4601
|
+
/**
|
|
4602
|
+
* Transforms the parameters before they are passed to the embed model.
|
|
4603
|
+
* @param options - Object containing the type of operation and the parameters.
|
|
4604
|
+
* @param options.params - The original parameters for the embedding model call.
|
|
4605
|
+
* @returns A promise that resolves to the transformed parameters.
|
|
4606
|
+
*/
|
|
4607
|
+
transformParams?: (options: {
|
|
4608
|
+
params: EmbeddingModelV3CallOptions;
|
|
4609
|
+
model: EmbeddingModelV3;
|
|
4610
|
+
}) => PromiseLike<EmbeddingModelV3CallOptions>;
|
|
4611
|
+
/**
|
|
4612
|
+
* Wraps the embed operation of the embedding model.
|
|
4613
|
+
*
|
|
4614
|
+
* @param options - Object containing the embed function, parameters, and model.
|
|
4615
|
+
* @param options.doEmbed - The original embed function.
|
|
4616
|
+
* @param options.params - The parameters for the embed call. If the
|
|
4617
|
+
* `transformParams` middleware is used, this will be the transformed parameters.
|
|
4618
|
+
* @param options.model - The embedding model instance.
|
|
4619
|
+
* @returns A promise that resolves to the result of the generate operation.
|
|
4620
|
+
*/
|
|
4621
|
+
wrapEmbed?: (options: {
|
|
4622
|
+
doEmbed: () => ReturnType<EmbeddingModelV3['doEmbed']>;
|
|
4623
|
+
params: EmbeddingModelV3CallOptions;
|
|
4624
|
+
model: EmbeddingModelV3;
|
|
4625
|
+
}) => Promise<Awaited<ReturnType<EmbeddingModelV3['doEmbed']>>>;
|
|
4626
|
+
};
|
|
4627
|
+
|
|
4628
|
+
type RerankingModelV4CallOptions = {
|
|
4629
|
+
/**
|
|
4630
|
+
* Documents to rerank.
|
|
4631
|
+
* Either a list of texts or a list of JSON objects.
|
|
4632
|
+
*/
|
|
4633
|
+
documents: {
|
|
4634
|
+
type: 'text';
|
|
4635
|
+
values: string[];
|
|
4636
|
+
} | {
|
|
4637
|
+
type: 'object';
|
|
4638
|
+
values: JSONObject[];
|
|
4639
|
+
};
|
|
4640
|
+
/**
|
|
4641
|
+
* The query is a string that represents the query to rerank the documents against.
|
|
4642
|
+
*/
|
|
4643
|
+
query: string;
|
|
4644
|
+
/**
|
|
4645
|
+
* Optional limit returned documents to the top n documents.
|
|
4646
|
+
*/
|
|
4647
|
+
topN?: number;
|
|
4648
|
+
/**
|
|
4649
|
+
* Abort signal for cancelling the operation.
|
|
4650
|
+
*/
|
|
4651
|
+
abortSignal?: AbortSignal;
|
|
4652
|
+
/**
|
|
4653
|
+
* Additional provider-specific options. They are passed through
|
|
4654
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
4655
|
+
* functionality that can be fully encapsulated in the provider.
|
|
4656
|
+
*/
|
|
4657
|
+
providerOptions?: SharedV4ProviderOptions;
|
|
4658
|
+
/**
|
|
4659
|
+
* Additional HTTP headers to be sent with the request.
|
|
4660
|
+
* Only applicable for HTTP-based providers.
|
|
4661
|
+
*/
|
|
4662
|
+
headers?: SharedV4Headers;
|
|
4663
|
+
};
|
|
4664
|
+
|
|
4665
|
+
/**
|
|
4666
|
+
* Specification for a reranking model that implements the reranking model interface version 3.
|
|
4667
|
+
*/
|
|
4668
|
+
type RerankingModelV4 = {
|
|
4669
|
+
/**
|
|
4670
|
+
* The reranking model must specify which reranking model interface version it implements.
|
|
4671
|
+
*/
|
|
4672
|
+
readonly specificationVersion: 'v4';
|
|
4673
|
+
/**
|
|
4674
|
+
* Provider ID.
|
|
4675
|
+
*/
|
|
4676
|
+
readonly provider: string;
|
|
4677
|
+
/**
|
|
4678
|
+
* Provider-specific model ID.
|
|
4679
|
+
*/
|
|
4680
|
+
readonly modelId: string;
|
|
4681
|
+
/**
|
|
4682
|
+
* Reranking a list of documents using the query.
|
|
4683
|
+
*/
|
|
4684
|
+
doRerank(options: RerankingModelV4CallOptions): PromiseLike<{
|
|
4685
|
+
/**
|
|
4686
|
+
* Ordered list of reranked documents (via index before reranking).
|
|
4687
|
+
* The documents are sorted by the descending order of relevance scores.
|
|
4688
|
+
*/
|
|
4689
|
+
ranking: Array<{
|
|
4690
|
+
/**
|
|
4691
|
+
* The index of the document in the original list of documents before reranking.
|
|
4692
|
+
*/
|
|
4693
|
+
index: number;
|
|
4694
|
+
/**
|
|
4695
|
+
* The relevance score of the document after reranking.
|
|
4696
|
+
*/
|
|
4697
|
+
relevanceScore: number;
|
|
4698
|
+
}>;
|
|
4699
|
+
/**
|
|
4700
|
+
* Additional provider-specific metadata. They are passed through
|
|
4701
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
4702
|
+
* functionality that can be fully encapsulated in the provider.
|
|
4703
|
+
*/
|
|
4704
|
+
providerMetadata?: SharedV4ProviderMetadata;
|
|
4705
|
+
/**
|
|
4706
|
+
* Warnings for the call, e.g. unsupported settings.
|
|
4707
|
+
*/
|
|
4708
|
+
warnings?: Array<SharedV4Warning>;
|
|
4709
|
+
/**
|
|
4710
|
+
* Optional response information for debugging purposes.
|
|
4711
|
+
*/
|
|
4712
|
+
response?: {
|
|
4713
|
+
/**
|
|
4714
|
+
* ID for the generated response, if the provider sends one.
|
|
4715
|
+
*/
|
|
4716
|
+
id?: string;
|
|
4717
|
+
/**
|
|
4718
|
+
* Timestamp for the start of the generated response, if the provider sends one.
|
|
4719
|
+
*/
|
|
4720
|
+
timestamp?: Date;
|
|
4721
|
+
/**
|
|
4722
|
+
* The ID of the response model that was used to generate the response, if the provider sends one.
|
|
4723
|
+
*/
|
|
4724
|
+
modelId?: string;
|
|
4725
|
+
/**
|
|
4726
|
+
* Response headers.
|
|
4727
|
+
*/
|
|
4728
|
+
headers?: SharedV4Headers;
|
|
4729
|
+
/**
|
|
4730
|
+
* Response body.
|
|
4731
|
+
*/
|
|
4732
|
+
body?: unknown;
|
|
4733
|
+
};
|
|
4734
|
+
}>;
|
|
4735
|
+
};
|
|
4736
|
+
|
|
4737
|
+
type SpeechModelV4ProviderOptions = Record<string, JSONObject>;
|
|
4738
|
+
type SpeechModelV4CallOptions = {
|
|
4739
|
+
/**
|
|
4740
|
+
* Text to convert to speech.
|
|
4741
|
+
*/
|
|
4742
|
+
text: string;
|
|
4743
|
+
/**
|
|
4744
|
+
* The voice to use for speech synthesis.
|
|
4745
|
+
* This is provider-specific and may be a voice ID, name, or other identifier.
|
|
4746
|
+
*/
|
|
4747
|
+
voice?: string;
|
|
4748
|
+
/**
|
|
4749
|
+
* The desired output format for the audio e.g. "mp3", "wav", etc.
|
|
4750
|
+
*/
|
|
4751
|
+
outputFormat?: string;
|
|
4752
|
+
/**
|
|
4753
|
+
* Instructions for the speech generation e.g. "Speak in a slow and steady tone".
|
|
4754
|
+
*/
|
|
4755
|
+
instructions?: string;
|
|
4756
|
+
/**
|
|
4757
|
+
* The speed of the speech generation.
|
|
4758
|
+
*/
|
|
4759
|
+
speed?: number;
|
|
4760
|
+
/**
|
|
4761
|
+
* The language for speech generation. This should be an ISO 639-1 language code (e.g. "en", "es", "fr")
|
|
4762
|
+
* or "auto" for automatic language detection. Provider support varies.
|
|
4763
|
+
*/
|
|
4764
|
+
language?: string;
|
|
4765
|
+
/**
|
|
4766
|
+
* Additional provider-specific options that are passed through to the provider
|
|
4767
|
+
* as body parameters.
|
|
4768
|
+
*
|
|
4769
|
+
* The outer record is keyed by the provider name, and the inner
|
|
4770
|
+
* record is keyed by the provider-specific metadata key.
|
|
4771
|
+
* ```ts
|
|
4772
|
+
* {
|
|
4773
|
+
* "openai": {}
|
|
4774
|
+
* }
|
|
4775
|
+
* ```
|
|
4776
|
+
*/
|
|
4777
|
+
providerOptions?: SpeechModelV4ProviderOptions;
|
|
4778
|
+
/**
|
|
4779
|
+
* Abort signal for cancelling the operation.
|
|
4780
|
+
*/
|
|
4781
|
+
abortSignal?: AbortSignal;
|
|
4782
|
+
/**
|
|
4783
|
+
* Additional HTTP headers to be sent with the request.
|
|
4784
|
+
* Only applicable for HTTP-based providers.
|
|
4785
|
+
*/
|
|
4786
|
+
headers?: Record<string, string | undefined>;
|
|
4787
|
+
};
|
|
4788
|
+
|
|
4789
|
+
/**
|
|
4790
|
+
* Speech model specification version 3.
|
|
4791
|
+
*/
|
|
4792
|
+
type SpeechModelV4 = {
|
|
4793
|
+
/**
|
|
4794
|
+
* The speech model must specify which speech model interface
|
|
4795
|
+
* version it implements. This will allow us to evolve the speech
|
|
4796
|
+
* model interface and retain backwards compatibility. The different
|
|
4797
|
+
* implementation versions can be handled as a discriminated union
|
|
4798
|
+
* on our side.
|
|
4799
|
+
*/
|
|
4800
|
+
readonly specificationVersion: 'v4';
|
|
4801
|
+
/**
|
|
4802
|
+
* Name of the provider for logging purposes.
|
|
4803
|
+
*/
|
|
4804
|
+
readonly provider: string;
|
|
4805
|
+
/**
|
|
4806
|
+
* Provider-specific model ID for logging purposes.
|
|
4807
|
+
*/
|
|
4808
|
+
readonly modelId: string;
|
|
4809
|
+
/**
|
|
4810
|
+
* Generates speech audio from text.
|
|
4811
|
+
*/
|
|
4812
|
+
doGenerate(options: SpeechModelV4CallOptions): PromiseLike<{
|
|
4813
|
+
/**
|
|
4814
|
+
* Generated audio as an ArrayBuffer.
|
|
4815
|
+
* The audio should be returned without any unnecessary conversion.
|
|
4816
|
+
* If the API returns base64 encoded strings, the audio should be returned
|
|
4817
|
+
* as base64 encoded strings. If the API returns binary data, the audio
|
|
4818
|
+
* should be returned as binary data.
|
|
4819
|
+
*/
|
|
4820
|
+
audio: string | Uint8Array;
|
|
4821
|
+
/**
|
|
4822
|
+
* Warnings for the call, e.g. unsupported settings.
|
|
4823
|
+
*/
|
|
4824
|
+
warnings: Array<SharedV4Warning>;
|
|
4825
|
+
/**
|
|
4826
|
+
* Optional request information for telemetry and debugging purposes.
|
|
4827
|
+
*/
|
|
4828
|
+
request?: {
|
|
4829
|
+
/**
|
|
4830
|
+
* Response body (available only for providers that use HTTP requests).
|
|
4831
|
+
*/
|
|
4832
|
+
body?: unknown;
|
|
4833
|
+
};
|
|
4834
|
+
/**
|
|
4835
|
+
* Response information for telemetry and debugging purposes.
|
|
4836
|
+
*/
|
|
4837
|
+
response: {
|
|
4838
|
+
/**
|
|
4839
|
+
* Timestamp for the start of the generated response.
|
|
4840
|
+
*/
|
|
4841
|
+
timestamp: Date;
|
|
4842
|
+
/**
|
|
4843
|
+
* The ID of the response model that was used to generate the response.
|
|
4844
|
+
*/
|
|
4845
|
+
modelId: string;
|
|
4846
|
+
/**
|
|
4847
|
+
* Response headers.
|
|
4848
|
+
*/
|
|
4849
|
+
headers?: SharedV2Headers;
|
|
4850
|
+
/**
|
|
4851
|
+
* Response body.
|
|
4852
|
+
*/
|
|
4853
|
+
body?: unknown;
|
|
4854
|
+
};
|
|
4855
|
+
/**
|
|
4856
|
+
* Additional provider-specific metadata. They are passed through
|
|
4857
|
+
* from the provider to the AI SDK and enable provider-specific
|
|
4858
|
+
* results that can be fully encapsulated in the provider.
|
|
4859
|
+
*/
|
|
4860
|
+
providerMetadata?: Record<string, JSONObject>;
|
|
4861
|
+
}>;
|
|
4862
|
+
};
|
|
4863
|
+
|
|
4864
|
+
type TranscriptionModelV4ProviderOptions = Record<string, JSONObject>;
|
|
4865
|
+
type TranscriptionModelV4CallOptions = {
|
|
4866
|
+
/**
|
|
4867
|
+
* Audio data to transcribe.
|
|
4868
|
+
* Accepts a `Uint8Array` or `string`, where `string` is a base64 encoded audio file.
|
|
4869
|
+
*/
|
|
4870
|
+
audio: Uint8Array | string;
|
|
4871
|
+
/**
|
|
4872
|
+
* The IANA media type of the audio data.
|
|
4873
|
+
*
|
|
4874
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
4875
|
+
*/
|
|
4876
|
+
mediaType: string;
|
|
4877
|
+
/**
|
|
4878
|
+
* Additional provider-specific options that are passed through to the provider
|
|
4879
|
+
* as body parameters.
|
|
4880
|
+
*
|
|
4881
|
+
* The outer record is keyed by the provider name, and the inner
|
|
4882
|
+
* record is keyed by the provider-specific metadata key.
|
|
4883
|
+
* ```ts
|
|
4884
|
+
* {
|
|
4885
|
+
* "openai": {
|
|
4886
|
+
* "timestampGranularities": ["word"]
|
|
4887
|
+
* }
|
|
4888
|
+
* }
|
|
4889
|
+
* ```
|
|
4890
|
+
*/
|
|
4891
|
+
providerOptions?: TranscriptionModelV4ProviderOptions;
|
|
4892
|
+
/**
|
|
4893
|
+
* Abort signal for cancelling the operation.
|
|
4894
|
+
*/
|
|
4895
|
+
abortSignal?: AbortSignal;
|
|
4896
|
+
/**
|
|
4897
|
+
* Additional HTTP headers to be sent with the request.
|
|
4898
|
+
* Only applicable for HTTP-based providers.
|
|
4899
|
+
*/
|
|
4900
|
+
headers?: Record<string, string | undefined>;
|
|
4901
|
+
};
|
|
4902
|
+
|
|
4903
|
+
/**
|
|
4904
|
+
* Transcription model specification version 3.
|
|
4905
|
+
*/
|
|
4906
|
+
type TranscriptionModelV4 = {
|
|
4907
|
+
/**
|
|
4908
|
+
* The transcription model must specify which transcription model interface
|
|
4909
|
+
* version it implements. This will allow us to evolve the transcription
|
|
4910
|
+
* model interface and retain backwards compatibility. The different
|
|
4911
|
+
* implementation versions can be handled as a discriminated union
|
|
4912
|
+
* on our side.
|
|
4913
|
+
*/
|
|
4914
|
+
readonly specificationVersion: 'v4';
|
|
4915
|
+
/**
|
|
4916
|
+
* Name of the provider for logging purposes.
|
|
4917
|
+
*/
|
|
4918
|
+
readonly provider: string;
|
|
4919
|
+
/**
|
|
4920
|
+
* Provider-specific model ID for logging purposes.
|
|
4921
|
+
*/
|
|
4922
|
+
readonly modelId: string;
|
|
4923
|
+
/**
|
|
4924
|
+
* Generates a transcript.
|
|
4925
|
+
*/
|
|
4926
|
+
doGenerate(options: TranscriptionModelV4CallOptions): PromiseLike<{
|
|
4927
|
+
/**
|
|
4928
|
+
* The complete transcribed text from the audio.
|
|
4929
|
+
*/
|
|
4930
|
+
text: string;
|
|
4931
|
+
/**
|
|
4932
|
+
* Array of transcript segments with timing information.
|
|
4933
|
+
* Each segment represents a portion of the transcribed text with start and end times.
|
|
4934
|
+
*/
|
|
4935
|
+
segments: Array<{
|
|
4936
|
+
/**
|
|
4937
|
+
* The text content of this segment.
|
|
4938
|
+
*/
|
|
4939
|
+
text: string;
|
|
4940
|
+
/**
|
|
4941
|
+
* The start time of this segment in seconds.
|
|
4942
|
+
*/
|
|
4943
|
+
startSecond: number;
|
|
4944
|
+
/**
|
|
4945
|
+
* The end time of this segment in seconds.
|
|
4946
|
+
*/
|
|
4947
|
+
endSecond: number;
|
|
4948
|
+
}>;
|
|
4949
|
+
/**
|
|
4950
|
+
* The detected language of the audio content, as an ISO-639-1 code (e.g., 'en' for English).
|
|
4951
|
+
* May be undefined if the language couldn't be detected.
|
|
4952
|
+
*/
|
|
4953
|
+
language: string | undefined;
|
|
4954
|
+
/**
|
|
4955
|
+
* The total duration of the audio file in seconds.
|
|
4956
|
+
* May be undefined if the duration couldn't be determined.
|
|
4957
|
+
*/
|
|
4958
|
+
durationInSeconds: number | undefined;
|
|
4959
|
+
/**
|
|
4960
|
+
* Warnings for the call, e.g. unsupported settings.
|
|
4961
|
+
*/
|
|
4962
|
+
warnings: Array<SharedV4Warning>;
|
|
4963
|
+
/**
|
|
4964
|
+
* Optional request information for telemetry and debugging purposes.
|
|
4965
|
+
*/
|
|
4966
|
+
request?: {
|
|
4967
|
+
/**
|
|
4968
|
+
* Raw request HTTP body that was sent to the provider API as a string (JSON should be stringified).
|
|
4969
|
+
* Non-HTTP(s) providers should not set this.
|
|
4970
|
+
*/
|
|
4971
|
+
body?: string;
|
|
4972
|
+
};
|
|
4973
|
+
/**
|
|
4974
|
+
* Response information for telemetry and debugging purposes.
|
|
4975
|
+
*/
|
|
4976
|
+
response: {
|
|
4977
|
+
/**
|
|
4978
|
+
* Timestamp for the start of the generated response.
|
|
4979
|
+
*/
|
|
4980
|
+
timestamp: Date;
|
|
4981
|
+
/**
|
|
4982
|
+
* The ID of the response model that was used to generate the response.
|
|
4983
|
+
*/
|
|
4984
|
+
modelId: string;
|
|
4985
|
+
/**
|
|
4986
|
+
* Response headers.
|
|
4987
|
+
*/
|
|
4988
|
+
headers?: SharedV4Headers;
|
|
4989
|
+
/**
|
|
4990
|
+
* Response body.
|
|
4991
|
+
*/
|
|
4992
|
+
body?: unknown;
|
|
4993
|
+
};
|
|
4994
|
+
/**
|
|
4995
|
+
* Additional provider-specific metadata. They are passed through
|
|
4996
|
+
* from the provider to the AI SDK and enable provider-specific
|
|
4997
|
+
* results that can be fully encapsulated in the provider.
|
|
4998
|
+
*/
|
|
4999
|
+
providerMetadata?: Record<string, JSONObject>;
|
|
5000
|
+
}>;
|
|
5001
|
+
};
|
|
5002
|
+
|
|
5003
|
+
/**
|
|
5004
|
+
* Provider for language, text embedding, and image generation models.
|
|
5005
|
+
*/
|
|
5006
|
+
interface ProviderV4 {
|
|
5007
|
+
readonly specificationVersion: 'v4';
|
|
5008
|
+
/**
|
|
5009
|
+
* Returns the language model with the given id.
|
|
5010
|
+
* The model id is then passed to the provider function to get the model.
|
|
5011
|
+
*
|
|
5012
|
+
* @param {string} modelId - The id of the model to return.
|
|
5013
|
+
*
|
|
5014
|
+
* @returns {LanguageModelV4} The language model associated with the id
|
|
5015
|
+
*
|
|
5016
|
+
* @throws {NoSuchModelError} If no such model exists.
|
|
5017
|
+
*/
|
|
5018
|
+
languageModel(modelId: string): LanguageModelV4;
|
|
5019
|
+
/**
|
|
5020
|
+
* Returns the text embedding model with the given id.
|
|
5021
|
+
* The model id is then passed to the provider function to get the model.
|
|
5022
|
+
*
|
|
5023
|
+
* @param {string} modelId - The id of the model to return.
|
|
5024
|
+
*
|
|
5025
|
+
* @returns {EmbeddingModelV4} The embedding model associated with the id
|
|
5026
|
+
*
|
|
5027
|
+
* @throws {NoSuchModelError} If no such model exists.
|
|
5028
|
+
*/
|
|
5029
|
+
embeddingModel(modelId: string): EmbeddingModelV4;
|
|
2971
5030
|
/**
|
|
2972
|
-
*
|
|
2973
|
-
*
|
|
5031
|
+
* Returns the image model with the given id.
|
|
5032
|
+
* The model id is then passed to the provider function to get the model.
|
|
5033
|
+
*
|
|
5034
|
+
* @param {string} modelId - The id of the model to return.
|
|
5035
|
+
*
|
|
5036
|
+
* @returns {ImageModelV4} The image model associated with the id
|
|
2974
5037
|
*/
|
|
2975
|
-
|
|
2976
|
-
model: EmbeddingModelV3;
|
|
2977
|
-
}) => PromiseLike<number | undefined> | number | undefined;
|
|
5038
|
+
imageModel(modelId: string): ImageModelV4;
|
|
2978
5039
|
/**
|
|
2979
|
-
*
|
|
2980
|
-
*
|
|
5040
|
+
* Returns the transcription model with the given id.
|
|
5041
|
+
* The model id is then passed to the provider function to get the model.
|
|
5042
|
+
*
|
|
5043
|
+
* @param {string} modelId - The id of the model to return.
|
|
5044
|
+
*
|
|
5045
|
+
* @returns {TranscriptionModelV4} The transcription model associated with the id
|
|
2981
5046
|
*/
|
|
2982
|
-
|
|
2983
|
-
model: EmbeddingModelV3;
|
|
2984
|
-
}) => PromiseLike<boolean> | boolean;
|
|
5047
|
+
transcriptionModel?(modelId: string): TranscriptionModelV4;
|
|
2985
5048
|
/**
|
|
2986
|
-
*
|
|
2987
|
-
*
|
|
2988
|
-
*
|
|
2989
|
-
* @
|
|
5049
|
+
* Returns the speech model with the given id.
|
|
5050
|
+
* The model id is then passed to the provider function to get the model.
|
|
5051
|
+
*
|
|
5052
|
+
* @param {string} modelId - The id of the model to return.
|
|
5053
|
+
*
|
|
5054
|
+
* @returns {SpeechModelV4} The speech model associated with the id
|
|
2990
5055
|
*/
|
|
2991
|
-
|
|
2992
|
-
params: EmbeddingModelV3CallOptions;
|
|
2993
|
-
model: EmbeddingModelV3;
|
|
2994
|
-
}) => PromiseLike<EmbeddingModelV3CallOptions>;
|
|
5056
|
+
speechModel?(modelId: string): SpeechModelV4;
|
|
2995
5057
|
/**
|
|
2996
|
-
*
|
|
5058
|
+
* Returns the reranking model with the given id.
|
|
5059
|
+
* The model id is then passed to the provider function to get the model.
|
|
2997
5060
|
*
|
|
2998
|
-
* @param
|
|
2999
|
-
*
|
|
3000
|
-
* @
|
|
3001
|
-
*
|
|
3002
|
-
* @
|
|
3003
|
-
* @returns A promise that resolves to the result of the generate operation.
|
|
5061
|
+
* @param {string} modelId - The id of the model to return.
|
|
5062
|
+
*
|
|
5063
|
+
* @returns {RerankingModelV4} The reranking model associated with the id
|
|
5064
|
+
*
|
|
5065
|
+
* @throws {NoSuchModelError} If no such model exists.
|
|
3004
5066
|
*/
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
params: EmbeddingModelV3CallOptions;
|
|
3008
|
-
model: EmbeddingModelV3;
|
|
3009
|
-
}) => Promise<Awaited<ReturnType<EmbeddingModelV3['doEmbed']>>>;
|
|
3010
|
-
};
|
|
5067
|
+
rerankingModel?(modelId: string): RerankingModelV4;
|
|
5068
|
+
}
|
|
3011
5069
|
|
|
3012
5070
|
type RerankingModelV3CallOptions = {
|
|
3013
5071
|
/**
|
|
@@ -3811,6 +5869,222 @@ interface ProviderV2 {
|
|
|
3811
5869
|
speechModel?(modelId: string): SpeechModelV2;
|
|
3812
5870
|
}
|
|
3813
5871
|
|
|
5872
|
+
/**
|
|
5873
|
+
* A video or image file that can be used for video editing or image-to-video generation.
|
|
5874
|
+
* Supports both image inputs (for image-to-video) and video inputs (for editing).
|
|
5875
|
+
*/
|
|
5876
|
+
type VideoModelV4File = {
|
|
5877
|
+
type: 'file';
|
|
5878
|
+
/**
|
|
5879
|
+
* The IANA media type of the file.
|
|
5880
|
+
* Video types: 'video/mp4', 'video/webm', 'video/quicktime'
|
|
5881
|
+
* Image types: 'image/png', 'image/jpeg', 'image/webp'
|
|
5882
|
+
*/
|
|
5883
|
+
mediaType: string;
|
|
5884
|
+
/**
|
|
5885
|
+
* File data as base64 encoded string or binary data.
|
|
5886
|
+
*/
|
|
5887
|
+
data: string | Uint8Array;
|
|
5888
|
+
/**
|
|
5889
|
+
* Optional provider-specific metadata for the file part.
|
|
5890
|
+
*/
|
|
5891
|
+
providerOptions?: SharedV4ProviderMetadata;
|
|
5892
|
+
} | {
|
|
5893
|
+
type: 'url';
|
|
5894
|
+
/**
|
|
5895
|
+
* The URL of the video or image file.
|
|
5896
|
+
*/
|
|
5897
|
+
url: string;
|
|
5898
|
+
/**
|
|
5899
|
+
* Optional provider-specific metadata for the file part.
|
|
5900
|
+
*/
|
|
5901
|
+
providerOptions?: SharedV4ProviderMetadata;
|
|
5902
|
+
};
|
|
5903
|
+
|
|
5904
|
+
type VideoModelV4CallOptions = {
|
|
5905
|
+
/**
|
|
5906
|
+
* Text prompt for the video generation.
|
|
5907
|
+
*/
|
|
5908
|
+
prompt: string | undefined;
|
|
5909
|
+
/**
|
|
5910
|
+
* Number of videos to generate. Default: 1.
|
|
5911
|
+
* Most video models only support n=1 due to computational cost.
|
|
5912
|
+
*/
|
|
5913
|
+
n: number;
|
|
5914
|
+
/**
|
|
5915
|
+
* Aspect ratio of the videos to generate.
|
|
5916
|
+
* Must have the format `{width}:{height}`.
|
|
5917
|
+
* `undefined` will use the provider's default aspect ratio.
|
|
5918
|
+
* Common values: '16:9', '9:16', '1:1', '21:9', '4:3'
|
|
5919
|
+
*/
|
|
5920
|
+
aspectRatio: `${number}:${number}` | undefined;
|
|
5921
|
+
/**
|
|
5922
|
+
* Resolution of the video to generate.
|
|
5923
|
+
* Format: `{width}x{height}` (e.g., '1280x720', '1920x1080')
|
|
5924
|
+
* `undefined` will use the provider's default resolution.
|
|
5925
|
+
*/
|
|
5926
|
+
resolution: `${number}x${number}` | undefined;
|
|
5927
|
+
/**
|
|
5928
|
+
* Duration of the video in seconds.
|
|
5929
|
+
* `undefined` will use the provider's default duration.
|
|
5930
|
+
* Typically 3-10 seconds for most models.
|
|
5931
|
+
*/
|
|
5932
|
+
duration: number | undefined;
|
|
5933
|
+
/**
|
|
5934
|
+
* Frames per second (FPS) for the video.
|
|
5935
|
+
* `undefined` will use the provider's default FPS.
|
|
5936
|
+
* Common values: 24, 30, 60
|
|
5937
|
+
*/
|
|
5938
|
+
fps: number | undefined;
|
|
5939
|
+
/**
|
|
5940
|
+
* Seed for deterministic video generation.
|
|
5941
|
+
* `undefined` will use a random seed.
|
|
5942
|
+
*/
|
|
5943
|
+
seed: number | undefined;
|
|
5944
|
+
/**
|
|
5945
|
+
* Input image for image-to-video generation.
|
|
5946
|
+
* The image serves as the starting frame that the model will animate.
|
|
5947
|
+
*/
|
|
5948
|
+
image: VideoModelV4File | undefined;
|
|
5949
|
+
/**
|
|
5950
|
+
* Additional provider-specific options that are passed through to the provider
|
|
5951
|
+
* as body parameters.
|
|
5952
|
+
*
|
|
5953
|
+
* Example:
|
|
5954
|
+
* {
|
|
5955
|
+
* "fal": {
|
|
5956
|
+
* "loop": true,
|
|
5957
|
+
* "motionStrength": 0.8
|
|
5958
|
+
* }
|
|
5959
|
+
* }
|
|
5960
|
+
*/
|
|
5961
|
+
providerOptions: SharedV4ProviderOptions;
|
|
5962
|
+
/**
|
|
5963
|
+
* Abort signal for cancelling the operation.
|
|
5964
|
+
*/
|
|
5965
|
+
abortSignal?: AbortSignal;
|
|
5966
|
+
/**
|
|
5967
|
+
* Additional HTTP headers to be sent with the request.
|
|
5968
|
+
* Only applicable for HTTP-based providers.
|
|
5969
|
+
*/
|
|
5970
|
+
headers?: Record<string, string | undefined>;
|
|
5971
|
+
};
|
|
5972
|
+
|
|
5973
|
+
type GetMaxVideosPerCallFunction$1 = (options: {
|
|
5974
|
+
modelId: string;
|
|
5975
|
+
}) => PromiseLike<number | undefined> | number | undefined;
|
|
5976
|
+
/**
|
|
5977
|
+
* Generated video data. Can be a URL, base64-encoded string, or binary data.
|
|
5978
|
+
*/
|
|
5979
|
+
type VideoModelV4VideoData = {
|
|
5980
|
+
/**
|
|
5981
|
+
* Video available as a URL (most common for video providers).
|
|
5982
|
+
*/
|
|
5983
|
+
type: 'url';
|
|
5984
|
+
url: string;
|
|
5985
|
+
mediaType: string;
|
|
5986
|
+
} | {
|
|
5987
|
+
/**
|
|
5988
|
+
* Video as base64-encoded string.
|
|
5989
|
+
*/
|
|
5990
|
+
type: 'base64';
|
|
5991
|
+
data: string;
|
|
5992
|
+
mediaType: string;
|
|
5993
|
+
} | {
|
|
5994
|
+
/**
|
|
5995
|
+
* Video as binary data.
|
|
5996
|
+
*/
|
|
5997
|
+
type: 'binary';
|
|
5998
|
+
data: Uint8Array;
|
|
5999
|
+
mediaType: string;
|
|
6000
|
+
};
|
|
6001
|
+
/**
|
|
6002
|
+
* Video generation model specification version 3.
|
|
6003
|
+
*/
|
|
6004
|
+
type VideoModelV4 = {
|
|
6005
|
+
/**
|
|
6006
|
+
* The video model must specify which video model interface
|
|
6007
|
+
* version it implements. This will allow us to evolve the video
|
|
6008
|
+
* model interface and retain backwards compatibility. The different
|
|
6009
|
+
* implementation versions can be handled as a discriminated union
|
|
6010
|
+
* on our side.
|
|
6011
|
+
*/
|
|
6012
|
+
readonly specificationVersion: 'v4';
|
|
6013
|
+
/**
|
|
6014
|
+
* Name of the provider for logging purposes.
|
|
6015
|
+
*/
|
|
6016
|
+
readonly provider: string;
|
|
6017
|
+
/**
|
|
6018
|
+
* Provider-specific model ID for logging purposes.
|
|
6019
|
+
*/
|
|
6020
|
+
readonly modelId: string;
|
|
6021
|
+
/**
|
|
6022
|
+
* Limit of how many videos can be generated in a single API call.
|
|
6023
|
+
* Can be set to a number for a fixed limit, to undefined to use
|
|
6024
|
+
* the global limit, or a function that returns a number or undefined,
|
|
6025
|
+
* optionally as a promise.
|
|
6026
|
+
*
|
|
6027
|
+
* Most video models only support generating 1 video at a time due to
|
|
6028
|
+
* computational cost. Default is typically 1.
|
|
6029
|
+
*/
|
|
6030
|
+
readonly maxVideosPerCall: number | undefined | GetMaxVideosPerCallFunction$1;
|
|
6031
|
+
/**
|
|
6032
|
+
* Generates an array of videos.
|
|
6033
|
+
*/
|
|
6034
|
+
doGenerate(options: VideoModelV4CallOptions): PromiseLike<{
|
|
6035
|
+
/**
|
|
6036
|
+
* Generated videos as URLs, base64 strings, or binary data.
|
|
6037
|
+
*
|
|
6038
|
+
* Most providers return URLs to video files (MP4, WebM) due to large file sizes.
|
|
6039
|
+
* Use the discriminated union to indicate the type of video data being returned.
|
|
6040
|
+
*/
|
|
6041
|
+
videos: Array<VideoModelV4VideoData>;
|
|
6042
|
+
/**
|
|
6043
|
+
* Warnings for the call, e.g. unsupported features.
|
|
6044
|
+
*/
|
|
6045
|
+
warnings: Array<SharedV4Warning>;
|
|
6046
|
+
/**
|
|
6047
|
+
* Additional provider-specific metadata. They are passed through
|
|
6048
|
+
* from the provider to the AI SDK and enable provider-specific
|
|
6049
|
+
* results that can be fully encapsulated in the provider.
|
|
6050
|
+
*
|
|
6051
|
+
* The outer record is keyed by the provider name, and the inner
|
|
6052
|
+
* record is provider-specific metadata.
|
|
6053
|
+
*
|
|
6054
|
+
* ```ts
|
|
6055
|
+
* {
|
|
6056
|
+
* "fal": {
|
|
6057
|
+
* "videos": [{
|
|
6058
|
+
* "duration": 5.0,
|
|
6059
|
+
* "fps": 24,
|
|
6060
|
+
* "width": 1280,
|
|
6061
|
+
* "height": 720
|
|
6062
|
+
* }]
|
|
6063
|
+
* }
|
|
6064
|
+
* }
|
|
6065
|
+
* ```
|
|
6066
|
+
*/
|
|
6067
|
+
providerMetadata?: SharedV4ProviderMetadata;
|
|
6068
|
+
/**
|
|
6069
|
+
* Response information for telemetry and debugging purposes.
|
|
6070
|
+
*/
|
|
6071
|
+
response: {
|
|
6072
|
+
/**
|
|
6073
|
+
* Timestamp for the start of the generated response.
|
|
6074
|
+
*/
|
|
6075
|
+
timestamp: Date;
|
|
6076
|
+
/**
|
|
6077
|
+
* The ID of the response model that was used to generate the response.
|
|
6078
|
+
*/
|
|
6079
|
+
modelId: string;
|
|
6080
|
+
/**
|
|
6081
|
+
* Response headers.
|
|
6082
|
+
*/
|
|
6083
|
+
headers: Record<string, string> | undefined;
|
|
6084
|
+
};
|
|
6085
|
+
}>;
|
|
6086
|
+
};
|
|
6087
|
+
|
|
3814
6088
|
/**
|
|
3815
6089
|
* A video or image file that can be used for video editing or image-to-video generation.
|
|
3816
6090
|
* Supports both image inputs (for image-to-video) and video inputs (for editing).
|
|
@@ -4027,4 +6301,4 @@ type VideoModelV3 = {
|
|
|
4027
6301
|
}>;
|
|
4028
6302
|
};
|
|
4029
6303
|
|
|
4030
|
-
export { AISDKError, APICallError, type EmbeddingModelV2, type EmbeddingModelV2Embedding, type EmbeddingModelV3, type EmbeddingModelV3CallOptions, type EmbeddingModelV3Embedding, type EmbeddingModelV3Middleware, type EmbeddingModelV3Result, EmptyResponseBodyError, type VideoModelV3 as Experimental_VideoModelV3, type VideoModelV3CallOptions as Experimental_VideoModelV3CallOptions, type VideoModelV3File as Experimental_VideoModelV3File, type VideoModelV3VideoData as Experimental_VideoModelV3VideoData, type ImageModelV2, type ImageModelV2CallOptions, type ImageModelV2CallWarning, type ImageModelV2ProviderMetadata, type ImageModelV3, type ImageModelV3CallOptions, type ImageModelV3File, type ImageModelV3Middleware, type ImageModelV3ProviderMetadata, type ImageModelV3Usage, InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV2, type LanguageModelV2CallOptions, type LanguageModelV2CallWarning, type LanguageModelV2Content, type LanguageModelV2DataContent, type LanguageModelV2File, type LanguageModelV2FilePart, type LanguageModelV2FinishReason, type LanguageModelV2FunctionTool, type LanguageModelV2Message, type LanguageModelV2Middleware, type LanguageModelV2Prompt, type LanguageModelV2ProviderDefinedTool, type LanguageModelV2Reasoning, type LanguageModelV2ReasoningPart, type LanguageModelV2ResponseMetadata, type LanguageModelV2Source, type LanguageModelV2StreamPart, type LanguageModelV2Text, type LanguageModelV2TextPart, type LanguageModelV2ToolCall, type LanguageModelV2ToolCallPart, type LanguageModelV2ToolChoice, type LanguageModelV2ToolResultOutput, type LanguageModelV2ToolResultPart, type LanguageModelV2Usage, type LanguageModelV3, type LanguageModelV3CallOptions, type LanguageModelV3Content, type LanguageModelV3DataContent, type LanguageModelV3File, type LanguageModelV3FilePart, type LanguageModelV3FinishReason, type LanguageModelV3FunctionTool, type LanguageModelV3GenerateResult, type LanguageModelV3Message, type LanguageModelV3Middleware, type LanguageModelV3Prompt, type LanguageModelV3ProviderTool, type LanguageModelV3Reasoning, type LanguageModelV3ReasoningPart, type LanguageModelV3ResponseMetadata, type LanguageModelV3Source, type LanguageModelV3StreamPart, type LanguageModelV3StreamResult, type LanguageModelV3Text, type LanguageModelV3TextPart, type LanguageModelV3ToolApprovalRequest, type LanguageModelV3ToolApprovalResponsePart, type LanguageModelV3ToolCall, type LanguageModelV3ToolCallPart, type LanguageModelV3ToolChoice, type LanguageModelV3ToolResult, type LanguageModelV3ToolResultOutput, type LanguageModelV3ToolResultPart, type LanguageModelV3Usage, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV2, type ProviderV3, type RerankingModelV3, type RerankingModelV3CallOptions, type SharedV2Headers, type SharedV2ProviderMetadata, type SharedV2ProviderOptions, type SharedV3Headers, type SharedV3ProviderMetadata, type SharedV3ProviderOptions, type SharedV3Warning, type SpeechModelV2, type SpeechModelV2CallOptions, type SpeechModelV2CallWarning, type SpeechModelV3, type SpeechModelV3CallOptions, TooManyEmbeddingValuesForCallError, type TranscriptionModelV2, type TranscriptionModelV2CallOptions, type TranscriptionModelV2CallWarning, type TranscriptionModelV3, type TranscriptionModelV3CallOptions, type TypeValidationContext, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };
|
|
6304
|
+
export { AISDKError, APICallError, type EmbeddingModelV2, type EmbeddingModelV2Embedding, type EmbeddingModelV3, type EmbeddingModelV3CallOptions, type EmbeddingModelV3Embedding, type EmbeddingModelV3Middleware, type EmbeddingModelV3Result, type EmbeddingModelV4, type EmbeddingModelV4CallOptions, type EmbeddingModelV4Embedding, type EmbeddingModelV4Middleware, type EmbeddingModelV4Result, EmptyResponseBodyError, type VideoModelV3 as Experimental_VideoModelV3, type VideoModelV3CallOptions as Experimental_VideoModelV3CallOptions, type VideoModelV3File as Experimental_VideoModelV3File, type VideoModelV3VideoData as Experimental_VideoModelV3VideoData, type VideoModelV4 as Experimental_VideoModelV4, type VideoModelV4CallOptions as Experimental_VideoModelV4CallOptions, type VideoModelV4File as Experimental_VideoModelV4File, type VideoModelV4VideoData as Experimental_VideoModelV4VideoData, type ImageModelV2, type ImageModelV2CallOptions, type ImageModelV2CallWarning, type ImageModelV2ProviderMetadata, type ImageModelV3, type ImageModelV3CallOptions, type ImageModelV3File, type ImageModelV3Middleware, type ImageModelV3ProviderMetadata, type ImageModelV3Usage, type ImageModelV4, type ImageModelV4CallOptions, type ImageModelV4File, type ImageModelV4Middleware, type ImageModelV4ProviderMetadata, type ImageModelV4Usage, InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV2, type LanguageModelV2CallOptions, type LanguageModelV2CallWarning, type LanguageModelV2Content, type LanguageModelV2DataContent, type LanguageModelV2File, type LanguageModelV2FilePart, type LanguageModelV2FinishReason, type LanguageModelV2FunctionTool, type LanguageModelV2Message, type LanguageModelV2Middleware, type LanguageModelV2Prompt, type LanguageModelV2ProviderDefinedTool, type LanguageModelV2Reasoning, type LanguageModelV2ReasoningPart, type LanguageModelV2ResponseMetadata, type LanguageModelV2Source, type LanguageModelV2StreamPart, type LanguageModelV2Text, type LanguageModelV2TextPart, type LanguageModelV2ToolCall, type LanguageModelV2ToolCallPart, type LanguageModelV2ToolChoice, type LanguageModelV2ToolResultOutput, type LanguageModelV2ToolResultPart, type LanguageModelV2Usage, type LanguageModelV3, type LanguageModelV3CallOptions, type LanguageModelV3Content, type LanguageModelV3DataContent, type LanguageModelV3File, type LanguageModelV3FilePart, type LanguageModelV3FinishReason, type LanguageModelV3FunctionTool, type LanguageModelV3GenerateResult, type LanguageModelV3Message, type LanguageModelV3Middleware, type LanguageModelV3Prompt, type LanguageModelV3ProviderTool, type LanguageModelV3Reasoning, type LanguageModelV3ReasoningPart, type LanguageModelV3ResponseMetadata, type LanguageModelV3Source, type LanguageModelV3StreamPart, type LanguageModelV3StreamResult, type LanguageModelV3Text, type LanguageModelV3TextPart, type LanguageModelV3ToolApprovalRequest, type LanguageModelV3ToolApprovalResponsePart, type LanguageModelV3ToolCall, type LanguageModelV3ToolCallPart, type LanguageModelV3ToolChoice, type LanguageModelV3ToolResult, type LanguageModelV3ToolResultOutput, type LanguageModelV3ToolResultPart, type LanguageModelV3Usage, type LanguageModelV4, type LanguageModelV4CallOptions, type LanguageModelV4Content, type LanguageModelV4DataContent, type LanguageModelV4File, type LanguageModelV4FilePart, type LanguageModelV4FinishReason, type LanguageModelV4FunctionTool, type LanguageModelV4GenerateResult, type LanguageModelV4Message, type LanguageModelV4Middleware, type LanguageModelV4Prompt, type LanguageModelV4ProviderTool, type LanguageModelV4Reasoning, type LanguageModelV4ReasoningPart, type LanguageModelV4ResponseMetadata, type LanguageModelV4Source, type LanguageModelV4StreamPart, type LanguageModelV4StreamResult, type LanguageModelV4Text, type LanguageModelV4TextPart, type LanguageModelV4ToolApprovalRequest, type LanguageModelV4ToolApprovalResponsePart, type LanguageModelV4ToolCall, type LanguageModelV4ToolCallPart, type LanguageModelV4ToolChoice, type LanguageModelV4ToolResult, type LanguageModelV4ToolResultOutput, type LanguageModelV4ToolResultPart, type LanguageModelV4Usage, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV2, type ProviderV3, type ProviderV4, type RerankingModelV3, type RerankingModelV3CallOptions, type RerankingModelV4, type RerankingModelV4CallOptions, type SharedV2Headers, type SharedV2ProviderMetadata, type SharedV2ProviderOptions, type SharedV3Headers, type SharedV3ProviderMetadata, type SharedV3ProviderOptions, type SharedV3Warning, type SharedV4Headers, type SharedV4ProviderMetadata, type SharedV4ProviderOptions, type SharedV4Warning, type SpeechModelV2, type SpeechModelV2CallOptions, type SpeechModelV2CallWarning, type SpeechModelV3, type SpeechModelV3CallOptions, type SpeechModelV4, type SpeechModelV4CallOptions, TooManyEmbeddingValuesForCallError, type TranscriptionModelV2, type TranscriptionModelV2CallOptions, type TranscriptionModelV2CallWarning, type TranscriptionModelV3, type TranscriptionModelV3CallOptions, type TranscriptionModelV4, type TranscriptionModelV4CallOptions, type TypeValidationContext, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };
|