@ai-sdk/provider 0.0.22 → 0.0.24

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 ADDED
@@ -0,0 +1,150 @@
1
+ # @ai-sdk/provider
2
+
3
+ ## 0.0.24
4
+
5
+ ### Patch Changes
6
+
7
+ - d595d0d: feat (ai/core): file content parts
8
+
9
+ ## 0.0.23
10
+
11
+ ### Patch Changes
12
+
13
+ - 03313cd: feat (ai): expose response id, response model, response timestamp in telemetry and api
14
+ - 3be7c1c: fix (provider/anthropic): support prompt caching on assistant messages
15
+
16
+ ## 0.0.22
17
+
18
+ ### Patch Changes
19
+
20
+ - 26515cb: feat (ai/provider): introduce ProviderV1 specification
21
+
22
+ ## 0.0.21
23
+
24
+ ### Patch Changes
25
+
26
+ - f2c025e: feat (ai/core): prompt validation
27
+
28
+ ## 0.0.20
29
+
30
+ ### Patch Changes
31
+
32
+ - 6ac355e: feat (provider/anthropic): add cache control support
33
+
34
+ ## 0.0.19
35
+
36
+ ### Patch Changes
37
+
38
+ - dd4a0f5: fix (ai/provider): remove invalid check in isJSONParseError
39
+
40
+ ## 0.0.18
41
+
42
+ ### Patch Changes
43
+
44
+ - 4bd27a9: chore (ai/provider): refactor type validation
45
+
46
+ ## 0.0.17
47
+
48
+ ### Patch Changes
49
+
50
+ - 029af4c: feat (ai/core): support schema name & description in generateObject & streamObject
51
+
52
+ ## 0.0.16
53
+
54
+ ### Patch Changes
55
+
56
+ - d58517b: feat (ai/openai): structured outputs
57
+
58
+ ## 0.0.15
59
+
60
+ ### Patch Changes
61
+
62
+ - 96aed25: fix (ai/provider): release new version
63
+
64
+ ## 0.0.14
65
+
66
+ ### Patch Changes
67
+
68
+ - a8d1c9e9: feat (ai/core): parallel image download
69
+
70
+ ## 0.0.13
71
+
72
+ ### Patch Changes
73
+
74
+ - 2b9da0f0: feat (core): support stopSequences setting.
75
+ - a5b58845: feat (core): support topK setting
76
+ - 4aa8deb3: feat (provider): support responseFormat setting in provider api
77
+ - 13b27ec6: chore (ai/core): remove grammar mode
78
+
79
+ ## 0.0.12
80
+
81
+ ### Patch Changes
82
+
83
+ - b7290943: feat (ai/core): add token usage to embed and embedMany
84
+
85
+ ## 0.0.11
86
+
87
+ ### Patch Changes
88
+
89
+ - 5edc6110: feat (provider): add headers support to language and embedding model spec
90
+
91
+ ## 0.0.10
92
+
93
+ ### Patch Changes
94
+
95
+ - 102ca22f: fix (@ai-sdk/provider): fix TypeValidationError.isTypeValidationError
96
+
97
+ ## 0.0.9
98
+
99
+ ### Patch Changes
100
+
101
+ - 09295e2e: feat (@ai-sdk/provider): add DownloadError
102
+
103
+ ## 0.0.8
104
+
105
+ ### Patch Changes
106
+
107
+ - f39c0dd2: feat (provider): add toolChoice to language model specification
108
+
109
+ ## 0.0.7
110
+
111
+ ### Patch Changes
112
+
113
+ - 8e780288: feat (ai/provider): add "unknown" finish reason (for models that don't provide a finish reason)
114
+
115
+ ## 0.0.6
116
+
117
+ ### Patch Changes
118
+
119
+ - 6a50ac4: feat (provider): add additional error types
120
+
121
+ ## 0.0.5
122
+
123
+ ### Patch Changes
124
+
125
+ - 0f6bc4e: feat (ai/core): add embed function
126
+
127
+ ## 0.0.4
128
+
129
+ ### Patch Changes
130
+
131
+ - 325ca55: feat (ai/core): improve image content part error message
132
+
133
+ ## 0.0.3
134
+
135
+ ### Patch Changes
136
+
137
+ - 41d5736: ai/core: re-expose language model types.
138
+
139
+ ## 0.0.2
140
+
141
+ ### Patch Changes
142
+
143
+ - d6431ae: ai/core: add logprobs support (thanks @SamStenner for the contribution)
144
+ - 25f3350: ai/core: add support for getting raw response headers.
145
+
146
+ ## 0.0.1
147
+
148
+ ### Patch Changes
149
+
150
+ - eb150a6: ai/core: remove scaling of setting values (breaking change). If you were using the temperature, frequency penalty, or presence penalty settings, you need to update the providers and adjust the setting values.
package/README.md CHANGED
@@ -1 +1 @@
1
- # Vercel AI SDK - Provider Language Model Specification
1
+ # AI SDK - Provider Language Model Specification
package/dist/index.d.mts CHANGED
@@ -591,7 +591,7 @@ type LanguageModelV1Message = ({
591
591
  content: string;
592
592
  } | {
593
593
  role: 'user';
594
- content: Array<LanguageModelV1TextPart | LanguageModelV1ImagePart>;
594
+ content: Array<LanguageModelV1TextPart | LanguageModelV1ImagePart | LanguageModelV1FilePart>;
595
595
  } | {
596
596
  role: 'assistant';
597
597
  content: Array<LanguageModelV1TextPart | LanguageModelV1ToolCallPart>;
@@ -643,6 +643,26 @@ interface LanguageModelV1ImagePart {
643
643
  providerMetadata?: LanguageModelV1ProviderMetadata;
644
644
  }
645
645
  /**
646
+ File content part of a prompt. It contains a file.
647
+ */
648
+ interface LanguageModelV1FilePart {
649
+ type: 'file';
650
+ /**
651
+ File data as base64 encoded string or as a URL.
652
+ */
653
+ data: string | URL;
654
+ /**
655
+ Mime type of the file.
656
+ */
657
+ mimeType: string;
658
+ /**
659
+ * Additional provider-specific metadata. They are passed through
660
+ * to the provider from the AI SDK and enable provider-specific
661
+ * functionality that can be fully encapsulated in the provider.
662
+ */
663
+ providerMetadata?: LanguageModelV1ProviderMetadata;
664
+ }
665
+ /**
646
666
  Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
647
667
  */
648
668
  interface LanguageModelV1ToolCallPart {
@@ -659,6 +679,12 @@ interface LanguageModelV1ToolCallPart {
659
679
  Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
660
680
  */
661
681
  args: unknown;
682
+ /**
683
+ * Additional provider-specific metadata. They are passed through
684
+ * to the provider from the AI SDK and enable provider-specific
685
+ * functionality that can be fully encapsulated in the provider.
686
+ */
687
+ providerMetadata?: LanguageModelV1ProviderMetadata;
662
688
  }
663
689
  /**
664
690
  Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
@@ -757,6 +783,12 @@ Specifies how the tool should be selected. Defaults to 'auto'.
757
783
  the language model interface.
758
784
  */
759
785
  prompt: LanguageModelV1Prompt;
786
+ /**
787
+ Additional provider-specific metadata.
788
+ The metadata is passed through to the provider from the AI SDK and enables
789
+ provider-specific functionality that can be fully encapsulated in the provider.
790
+ */
791
+ providerMetadata?: LanguageModelV1ProviderMetadata;
760
792
  };
761
793
 
762
794
  /**
@@ -860,8 +892,6 @@ type LanguageModelV1 = {
860
892
  use further optimizations if this flag is set to `true`.
861
893
 
862
894
  Defaults to `false`.
863
-
864
- TODO rename to supportsGrammarGuidedGeneration in v2
865
895
  */
866
896
  readonly supportsStructuredOutputs?: boolean;
867
897
  /**
@@ -908,7 +938,7 @@ type LanguageModelV1 = {
908
938
  rawSettings: Record<string, unknown>;
909
939
  };
910
940
  /**
911
- Optional raw response information for debugging purposes.
941
+ Optional response information for telemetry and debugging purposes.
912
942
  */
913
943
  rawResponse?: {
914
944
  /**
@@ -916,6 +946,20 @@ type LanguageModelV1 = {
916
946
  */
917
947
  headers?: Record<string, string>;
918
948
  };
949
+ response?: {
950
+ /**
951
+ ID for the generated response, if the provider sends one.
952
+ */
953
+ id?: string;
954
+ /**
955
+ Timestamp for the start of the generated response, if the provider sends one.
956
+ */
957
+ timestamp?: Date;
958
+ /**
959
+ The ID of the response model that was used to generate the response, if the provider sends one.
960
+ */
961
+ modelId?: string;
962
+ };
919
963
  warnings?: LanguageModelV1CallWarning[];
920
964
  /**
921
965
  Additional provider-specific metadata. They are passed through
@@ -924,8 +968,10 @@ type LanguageModelV1 = {
924
968
  */
925
969
  providerMetadata?: LanguageModelV1ProviderMetadata;
926
970
  /**
927
- Logprobs for the completion.
928
- `undefined` if the mode does not support logprobs or if was not enabled
971
+ Logprobs for the completion.
972
+ `undefined` if the mode does not support logprobs or if was not enabled
973
+
974
+ @deprecated will be changed into a provider-specific extension in v2
929
975
  */
930
976
  logprobs?: LanguageModelV1LogProbs;
931
977
  }>;
@@ -977,20 +1023,24 @@ type LanguageModelV1StreamPart = {
977
1023
  toolCallId: string;
978
1024
  toolName: string;
979
1025
  argsTextDelta: string;
1026
+ } | {
1027
+ type: 'response-metadata';
1028
+ id?: string;
1029
+ timestamp?: Date;
1030
+ modelId?: string;
980
1031
  } | {
981
1032
  type: 'finish';
982
1033
  finishReason: LanguageModelV1FinishReason;
983
- logprobs?: LanguageModelV1LogProbs;
984
1034
  providerMetadata?: LanguageModelV1ProviderMetadata;
985
1035
  usage: {
986
1036
  promptTokens: number;
987
1037
  completionTokens: number;
988
1038
  };
1039
+ logprobs?: LanguageModelV1LogProbs;
989
1040
  } | {
990
1041
  type: 'error';
991
1042
  error: unknown;
992
1043
  };
993
- type LanguageModelV1ResponseMetadata = {};
994
1044
 
995
1045
  /**
996
1046
  * Provider for language and text embedding models.
@@ -1000,7 +1050,7 @@ interface ProviderV1 {
1000
1050
  Returns the language model with the given id.
1001
1051
  The model id is then passed to the provider function to get the model.
1002
1052
 
1003
- @param {string} id - The id of the model to return.
1053
+ @param {string} modelId - The id of the model to return.
1004
1054
 
1005
1055
  @returns {LanguageModel} The language model associated with the id
1006
1056
 
@@ -1011,7 +1061,7 @@ interface ProviderV1 {
1011
1061
  Returns the text embedding model with the given id.
1012
1062
  The model id is then passed to the provider function to get the model.
1013
1063
 
1014
- @param {string} id - The id of the model to return.
1064
+ @param {string} modelId - The id of the model to return.
1015
1065
 
1016
1066
  @returns {LanguageModel} The language model associated with the id
1017
1067
 
@@ -1020,4 +1070,4 @@ interface ProviderV1 {
1020
1070
  textEmbeddingModel(modelId: string): EmbeddingModelV1<string>;
1021
1071
  }
1022
1072
 
1023
- export { AISDKError, APICallError, type EmbeddingModelV1, type EmbeddingModelV1Embedding, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV1, type LanguageModelV1CallOptions, type LanguageModelV1CallWarning, type LanguageModelV1FinishReason, type LanguageModelV1FunctionTool, type LanguageModelV1FunctionToolCall, type LanguageModelV1ImagePart, type LanguageModelV1LogProbs, type LanguageModelV1Message, type LanguageModelV1Prompt, type LanguageModelV1ProviderMetadata, type LanguageModelV1ResponseMetadata, type LanguageModelV1StreamPart, type LanguageModelV1TextPart, type LanguageModelV1ToolCallPart, type LanguageModelV1ToolChoice, type LanguageModelV1ToolResultPart, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV1, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };
1073
+ export { AISDKError, APICallError, type EmbeddingModelV1, type EmbeddingModelV1Embedding, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV1, type LanguageModelV1CallOptions, type LanguageModelV1CallWarning, type LanguageModelV1FilePart, type LanguageModelV1FinishReason, type LanguageModelV1FunctionTool, type LanguageModelV1FunctionToolCall, type LanguageModelV1ImagePart, type LanguageModelV1LogProbs, type LanguageModelV1Message, type LanguageModelV1Prompt, type LanguageModelV1ProviderMetadata, type LanguageModelV1StreamPart, type LanguageModelV1TextPart, type LanguageModelV1ToolCallPart, type LanguageModelV1ToolChoice, type LanguageModelV1ToolResultPart, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV1, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };
package/dist/index.d.ts CHANGED
@@ -591,7 +591,7 @@ type LanguageModelV1Message = ({
591
591
  content: string;
592
592
  } | {
593
593
  role: 'user';
594
- content: Array<LanguageModelV1TextPart | LanguageModelV1ImagePart>;
594
+ content: Array<LanguageModelV1TextPart | LanguageModelV1ImagePart | LanguageModelV1FilePart>;
595
595
  } | {
596
596
  role: 'assistant';
597
597
  content: Array<LanguageModelV1TextPart | LanguageModelV1ToolCallPart>;
@@ -643,6 +643,26 @@ interface LanguageModelV1ImagePart {
643
643
  providerMetadata?: LanguageModelV1ProviderMetadata;
644
644
  }
645
645
  /**
646
+ File content part of a prompt. It contains a file.
647
+ */
648
+ interface LanguageModelV1FilePart {
649
+ type: 'file';
650
+ /**
651
+ File data as base64 encoded string or as a URL.
652
+ */
653
+ data: string | URL;
654
+ /**
655
+ Mime type of the file.
656
+ */
657
+ mimeType: string;
658
+ /**
659
+ * Additional provider-specific metadata. They are passed through
660
+ * to the provider from the AI SDK and enable provider-specific
661
+ * functionality that can be fully encapsulated in the provider.
662
+ */
663
+ providerMetadata?: LanguageModelV1ProviderMetadata;
664
+ }
665
+ /**
646
666
  Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
647
667
  */
648
668
  interface LanguageModelV1ToolCallPart {
@@ -659,6 +679,12 @@ interface LanguageModelV1ToolCallPart {
659
679
  Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
660
680
  */
661
681
  args: unknown;
682
+ /**
683
+ * Additional provider-specific metadata. They are passed through
684
+ * to the provider from the AI SDK and enable provider-specific
685
+ * functionality that can be fully encapsulated in the provider.
686
+ */
687
+ providerMetadata?: LanguageModelV1ProviderMetadata;
662
688
  }
663
689
  /**
664
690
  Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
@@ -757,6 +783,12 @@ Specifies how the tool should be selected. Defaults to 'auto'.
757
783
  the language model interface.
758
784
  */
759
785
  prompt: LanguageModelV1Prompt;
786
+ /**
787
+ Additional provider-specific metadata.
788
+ The metadata is passed through to the provider from the AI SDK and enables
789
+ provider-specific functionality that can be fully encapsulated in the provider.
790
+ */
791
+ providerMetadata?: LanguageModelV1ProviderMetadata;
760
792
  };
761
793
 
762
794
  /**
@@ -860,8 +892,6 @@ type LanguageModelV1 = {
860
892
  use further optimizations if this flag is set to `true`.
861
893
 
862
894
  Defaults to `false`.
863
-
864
- TODO rename to supportsGrammarGuidedGeneration in v2
865
895
  */
866
896
  readonly supportsStructuredOutputs?: boolean;
867
897
  /**
@@ -908,7 +938,7 @@ type LanguageModelV1 = {
908
938
  rawSettings: Record<string, unknown>;
909
939
  };
910
940
  /**
911
- Optional raw response information for debugging purposes.
941
+ Optional response information for telemetry and debugging purposes.
912
942
  */
913
943
  rawResponse?: {
914
944
  /**
@@ -916,6 +946,20 @@ type LanguageModelV1 = {
916
946
  */
917
947
  headers?: Record<string, string>;
918
948
  };
949
+ response?: {
950
+ /**
951
+ ID for the generated response, if the provider sends one.
952
+ */
953
+ id?: string;
954
+ /**
955
+ Timestamp for the start of the generated response, if the provider sends one.
956
+ */
957
+ timestamp?: Date;
958
+ /**
959
+ The ID of the response model that was used to generate the response, if the provider sends one.
960
+ */
961
+ modelId?: string;
962
+ };
919
963
  warnings?: LanguageModelV1CallWarning[];
920
964
  /**
921
965
  Additional provider-specific metadata. They are passed through
@@ -924,8 +968,10 @@ type LanguageModelV1 = {
924
968
  */
925
969
  providerMetadata?: LanguageModelV1ProviderMetadata;
926
970
  /**
927
- Logprobs for the completion.
928
- `undefined` if the mode does not support logprobs or if was not enabled
971
+ Logprobs for the completion.
972
+ `undefined` if the mode does not support logprobs or if was not enabled
973
+
974
+ @deprecated will be changed into a provider-specific extension in v2
929
975
  */
930
976
  logprobs?: LanguageModelV1LogProbs;
931
977
  }>;
@@ -977,20 +1023,24 @@ type LanguageModelV1StreamPart = {
977
1023
  toolCallId: string;
978
1024
  toolName: string;
979
1025
  argsTextDelta: string;
1026
+ } | {
1027
+ type: 'response-metadata';
1028
+ id?: string;
1029
+ timestamp?: Date;
1030
+ modelId?: string;
980
1031
  } | {
981
1032
  type: 'finish';
982
1033
  finishReason: LanguageModelV1FinishReason;
983
- logprobs?: LanguageModelV1LogProbs;
984
1034
  providerMetadata?: LanguageModelV1ProviderMetadata;
985
1035
  usage: {
986
1036
  promptTokens: number;
987
1037
  completionTokens: number;
988
1038
  };
1039
+ logprobs?: LanguageModelV1LogProbs;
989
1040
  } | {
990
1041
  type: 'error';
991
1042
  error: unknown;
992
1043
  };
993
- type LanguageModelV1ResponseMetadata = {};
994
1044
 
995
1045
  /**
996
1046
  * Provider for language and text embedding models.
@@ -1000,7 +1050,7 @@ interface ProviderV1 {
1000
1050
  Returns the language model with the given id.
1001
1051
  The model id is then passed to the provider function to get the model.
1002
1052
 
1003
- @param {string} id - The id of the model to return.
1053
+ @param {string} modelId - The id of the model to return.
1004
1054
 
1005
1055
  @returns {LanguageModel} The language model associated with the id
1006
1056
 
@@ -1011,7 +1061,7 @@ interface ProviderV1 {
1011
1061
  Returns the text embedding model with the given id.
1012
1062
  The model id is then passed to the provider function to get the model.
1013
1063
 
1014
- @param {string} id - The id of the model to return.
1064
+ @param {string} modelId - The id of the model to return.
1015
1065
 
1016
1066
  @returns {LanguageModel} The language model associated with the id
1017
1067
 
@@ -1020,4 +1070,4 @@ interface ProviderV1 {
1020
1070
  textEmbeddingModel(modelId: string): EmbeddingModelV1<string>;
1021
1071
  }
1022
1072
 
1023
- export { AISDKError, APICallError, type EmbeddingModelV1, type EmbeddingModelV1Embedding, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV1, type LanguageModelV1CallOptions, type LanguageModelV1CallWarning, type LanguageModelV1FinishReason, type LanguageModelV1FunctionTool, type LanguageModelV1FunctionToolCall, type LanguageModelV1ImagePart, type LanguageModelV1LogProbs, type LanguageModelV1Message, type LanguageModelV1Prompt, type LanguageModelV1ProviderMetadata, type LanguageModelV1ResponseMetadata, type LanguageModelV1StreamPart, type LanguageModelV1TextPart, type LanguageModelV1ToolCallPart, type LanguageModelV1ToolChoice, type LanguageModelV1ToolResultPart, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV1, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };
1073
+ export { AISDKError, APICallError, type EmbeddingModelV1, type EmbeddingModelV1Embedding, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV1, type LanguageModelV1CallOptions, type LanguageModelV1CallWarning, type LanguageModelV1FilePart, type LanguageModelV1FinishReason, type LanguageModelV1FunctionTool, type LanguageModelV1FunctionToolCall, type LanguageModelV1ImagePart, type LanguageModelV1LogProbs, type LanguageModelV1Message, type LanguageModelV1Prompt, type LanguageModelV1ProviderMetadata, type LanguageModelV1StreamPart, type LanguageModelV1TextPart, type LanguageModelV1ToolCallPart, type LanguageModelV1ToolChoice, type LanguageModelV1ToolResultPart, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV1, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@ai-sdk/provider",
3
- "version": "0.0.22",
3
+ "version": "0.0.24",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",
8
8
  "types": "./dist/index.d.ts",
9
9
  "files": [
10
- "dist/**/*"
10
+ "dist/**/*",
11
+ "CHANGELOG.md"
11
12
  ],
12
13
  "exports": {
13
14
  "./package.json": "./package.json",