@ai-sdk/provider 0.0.22 → 0.0.23

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,144 @@
1
+ # @ai-sdk/provider
2
+
3
+ ## 0.0.23
4
+
5
+ ### Patch Changes
6
+
7
+ - 03313cd: feat (ai): expose response id, response model, response timestamp in telemetry and api
8
+ - 3be7c1c: fix (provider/anthropic): support prompt caching on assistant messages
9
+
10
+ ## 0.0.22
11
+
12
+ ### Patch Changes
13
+
14
+ - 26515cb: feat (ai/provider): introduce ProviderV1 specification
15
+
16
+ ## 0.0.21
17
+
18
+ ### Patch Changes
19
+
20
+ - f2c025e: feat (ai/core): prompt validation
21
+
22
+ ## 0.0.20
23
+
24
+ ### Patch Changes
25
+
26
+ - 6ac355e: feat (provider/anthropic): add cache control support
27
+
28
+ ## 0.0.19
29
+
30
+ ### Patch Changes
31
+
32
+ - dd4a0f5: fix (ai/provider): remove invalid check in isJSONParseError
33
+
34
+ ## 0.0.18
35
+
36
+ ### Patch Changes
37
+
38
+ - 4bd27a9: chore (ai/provider): refactor type validation
39
+
40
+ ## 0.0.17
41
+
42
+ ### Patch Changes
43
+
44
+ - 029af4c: feat (ai/core): support schema name & description in generateObject & streamObject
45
+
46
+ ## 0.0.16
47
+
48
+ ### Patch Changes
49
+
50
+ - d58517b: feat (ai/openai): structured outputs
51
+
52
+ ## 0.0.15
53
+
54
+ ### Patch Changes
55
+
56
+ - 96aed25: fix (ai/provider): release new version
57
+
58
+ ## 0.0.14
59
+
60
+ ### Patch Changes
61
+
62
+ - a8d1c9e9: feat (ai/core): parallel image download
63
+
64
+ ## 0.0.13
65
+
66
+ ### Patch Changes
67
+
68
+ - 2b9da0f0: feat (core): support stopSequences setting.
69
+ - a5b58845: feat (core): support topK setting
70
+ - 4aa8deb3: feat (provider): support responseFormat setting in provider api
71
+ - 13b27ec6: chore (ai/core): remove grammar mode
72
+
73
+ ## 0.0.12
74
+
75
+ ### Patch Changes
76
+
77
+ - b7290943: feat (ai/core): add token usage to embed and embedMany
78
+
79
+ ## 0.0.11
80
+
81
+ ### Patch Changes
82
+
83
+ - 5edc6110: feat (provider): add headers support to language and embedding model spec
84
+
85
+ ## 0.0.10
86
+
87
+ ### Patch Changes
88
+
89
+ - 102ca22f: fix (@ai-sdk/provider): fix TypeValidationError.isTypeValidationError
90
+
91
+ ## 0.0.9
92
+
93
+ ### Patch Changes
94
+
95
+ - 09295e2e: feat (@ai-sdk/provider): add DownloadError
96
+
97
+ ## 0.0.8
98
+
99
+ ### Patch Changes
100
+
101
+ - f39c0dd2: feat (provider): add toolChoice to language model specification
102
+
103
+ ## 0.0.7
104
+
105
+ ### Patch Changes
106
+
107
+ - 8e780288: feat (ai/provider): add "unknown" finish reason (for models that don't provide a finish reason)
108
+
109
+ ## 0.0.6
110
+
111
+ ### Patch Changes
112
+
113
+ - 6a50ac4: feat (provider): add additional error types
114
+
115
+ ## 0.0.5
116
+
117
+ ### Patch Changes
118
+
119
+ - 0f6bc4e: feat (ai/core): add embed function
120
+
121
+ ## 0.0.4
122
+
123
+ ### Patch Changes
124
+
125
+ - 325ca55: feat (ai/core): improve image content part error message
126
+
127
+ ## 0.0.3
128
+
129
+ ### Patch Changes
130
+
131
+ - 41d5736: ai/core: re-expose language model types.
132
+
133
+ ## 0.0.2
134
+
135
+ ### Patch Changes
136
+
137
+ - d6431ae: ai/core: add logprobs support (thanks @SamStenner for the contribution)
138
+ - 25f3350: ai/core: add support for getting raw response headers.
139
+
140
+ ## 0.0.1
141
+
142
+ ### Patch Changes
143
+
144
+ - 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/dist/index.d.mts CHANGED
@@ -659,6 +659,12 @@ interface LanguageModelV1ToolCallPart {
659
659
  Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
660
660
  */
661
661
  args: unknown;
662
+ /**
663
+ * Additional provider-specific metadata. They are passed through
664
+ * to the provider from the AI SDK and enable provider-specific
665
+ * functionality that can be fully encapsulated in the provider.
666
+ */
667
+ providerMetadata?: LanguageModelV1ProviderMetadata;
662
668
  }
663
669
  /**
664
670
  Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
@@ -757,6 +763,12 @@ Specifies how the tool should be selected. Defaults to 'auto'.
757
763
  the language model interface.
758
764
  */
759
765
  prompt: LanguageModelV1Prompt;
766
+ /**
767
+ * Additional provider-specific metadata. They are passed through
768
+ * to the provider from the AI SDK and enable provider-specific
769
+ * functionality that can be fully encapsulated in the provider.
770
+ */
771
+ providerMetadata?: LanguageModelV1ProviderMetadata;
760
772
  };
761
773
 
762
774
  /**
@@ -860,8 +872,6 @@ type LanguageModelV1 = {
860
872
  use further optimizations if this flag is set to `true`.
861
873
 
862
874
  Defaults to `false`.
863
-
864
- TODO rename to supportsGrammarGuidedGeneration in v2
865
875
  */
866
876
  readonly supportsStructuredOutputs?: boolean;
867
877
  /**
@@ -908,7 +918,7 @@ type LanguageModelV1 = {
908
918
  rawSettings: Record<string, unknown>;
909
919
  };
910
920
  /**
911
- Optional raw response information for debugging purposes.
921
+ Optional response information for telemetry and debugging purposes.
912
922
  */
913
923
  rawResponse?: {
914
924
  /**
@@ -916,6 +926,20 @@ type LanguageModelV1 = {
916
926
  */
917
927
  headers?: Record<string, string>;
918
928
  };
929
+ response?: {
930
+ /**
931
+ ID for the generated response, if the provider sends one.
932
+ */
933
+ id?: string;
934
+ /**
935
+ Timestamp for the start of the generated response, if the provider sends one.
936
+ */
937
+ timestamp?: Date;
938
+ /**
939
+ The ID of the response model that was used to generate the response, if the provider sends one.
940
+ */
941
+ modelId?: string;
942
+ };
919
943
  warnings?: LanguageModelV1CallWarning[];
920
944
  /**
921
945
  Additional provider-specific metadata. They are passed through
@@ -924,8 +948,10 @@ type LanguageModelV1 = {
924
948
  */
925
949
  providerMetadata?: LanguageModelV1ProviderMetadata;
926
950
  /**
927
- Logprobs for the completion.
928
- `undefined` if the mode does not support logprobs or if was not enabled
951
+ Logprobs for the completion.
952
+ `undefined` if the mode does not support logprobs or if was not enabled
953
+
954
+ @deprecated will be changed into a provider-specific extension in v2
929
955
  */
930
956
  logprobs?: LanguageModelV1LogProbs;
931
957
  }>;
@@ -977,20 +1003,24 @@ type LanguageModelV1StreamPart = {
977
1003
  toolCallId: string;
978
1004
  toolName: string;
979
1005
  argsTextDelta: string;
1006
+ } | {
1007
+ type: 'response-metadata';
1008
+ id?: string;
1009
+ timestamp?: Date;
1010
+ modelId?: string;
980
1011
  } | {
981
1012
  type: 'finish';
982
1013
  finishReason: LanguageModelV1FinishReason;
983
- logprobs?: LanguageModelV1LogProbs;
984
1014
  providerMetadata?: LanguageModelV1ProviderMetadata;
985
1015
  usage: {
986
1016
  promptTokens: number;
987
1017
  completionTokens: number;
988
1018
  };
1019
+ logprobs?: LanguageModelV1LogProbs;
989
1020
  } | {
990
1021
  type: 'error';
991
1022
  error: unknown;
992
1023
  };
993
- type LanguageModelV1ResponseMetadata = {};
994
1024
 
995
1025
  /**
996
1026
  * Provider for language and text embedding models.
@@ -1020,4 +1050,4 @@ interface ProviderV1 {
1020
1050
  textEmbeddingModel(modelId: string): EmbeddingModelV1<string>;
1021
1051
  }
1022
1052
 
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 };
1053
+ 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 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
@@ -659,6 +659,12 @@ interface LanguageModelV1ToolCallPart {
659
659
  Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
660
660
  */
661
661
  args: unknown;
662
+ /**
663
+ * Additional provider-specific metadata. They are passed through
664
+ * to the provider from the AI SDK and enable provider-specific
665
+ * functionality that can be fully encapsulated in the provider.
666
+ */
667
+ providerMetadata?: LanguageModelV1ProviderMetadata;
662
668
  }
663
669
  /**
664
670
  Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
@@ -757,6 +763,12 @@ Specifies how the tool should be selected. Defaults to 'auto'.
757
763
  the language model interface.
758
764
  */
759
765
  prompt: LanguageModelV1Prompt;
766
+ /**
767
+ * Additional provider-specific metadata. They are passed through
768
+ * to the provider from the AI SDK and enable provider-specific
769
+ * functionality that can be fully encapsulated in the provider.
770
+ */
771
+ providerMetadata?: LanguageModelV1ProviderMetadata;
760
772
  };
761
773
 
762
774
  /**
@@ -860,8 +872,6 @@ type LanguageModelV1 = {
860
872
  use further optimizations if this flag is set to `true`.
861
873
 
862
874
  Defaults to `false`.
863
-
864
- TODO rename to supportsGrammarGuidedGeneration in v2
865
875
  */
866
876
  readonly supportsStructuredOutputs?: boolean;
867
877
  /**
@@ -908,7 +918,7 @@ type LanguageModelV1 = {
908
918
  rawSettings: Record<string, unknown>;
909
919
  };
910
920
  /**
911
- Optional raw response information for debugging purposes.
921
+ Optional response information for telemetry and debugging purposes.
912
922
  */
913
923
  rawResponse?: {
914
924
  /**
@@ -916,6 +926,20 @@ type LanguageModelV1 = {
916
926
  */
917
927
  headers?: Record<string, string>;
918
928
  };
929
+ response?: {
930
+ /**
931
+ ID for the generated response, if the provider sends one.
932
+ */
933
+ id?: string;
934
+ /**
935
+ Timestamp for the start of the generated response, if the provider sends one.
936
+ */
937
+ timestamp?: Date;
938
+ /**
939
+ The ID of the response model that was used to generate the response, if the provider sends one.
940
+ */
941
+ modelId?: string;
942
+ };
919
943
  warnings?: LanguageModelV1CallWarning[];
920
944
  /**
921
945
  Additional provider-specific metadata. They are passed through
@@ -924,8 +948,10 @@ type LanguageModelV1 = {
924
948
  */
925
949
  providerMetadata?: LanguageModelV1ProviderMetadata;
926
950
  /**
927
- Logprobs for the completion.
928
- `undefined` if the mode does not support logprobs or if was not enabled
951
+ Logprobs for the completion.
952
+ `undefined` if the mode does not support logprobs or if was not enabled
953
+
954
+ @deprecated will be changed into a provider-specific extension in v2
929
955
  */
930
956
  logprobs?: LanguageModelV1LogProbs;
931
957
  }>;
@@ -977,20 +1003,24 @@ type LanguageModelV1StreamPart = {
977
1003
  toolCallId: string;
978
1004
  toolName: string;
979
1005
  argsTextDelta: string;
1006
+ } | {
1007
+ type: 'response-metadata';
1008
+ id?: string;
1009
+ timestamp?: Date;
1010
+ modelId?: string;
980
1011
  } | {
981
1012
  type: 'finish';
982
1013
  finishReason: LanguageModelV1FinishReason;
983
- logprobs?: LanguageModelV1LogProbs;
984
1014
  providerMetadata?: LanguageModelV1ProviderMetadata;
985
1015
  usage: {
986
1016
  promptTokens: number;
987
1017
  completionTokens: number;
988
1018
  };
1019
+ logprobs?: LanguageModelV1LogProbs;
989
1020
  } | {
990
1021
  type: 'error';
991
1022
  error: unknown;
992
1023
  };
993
- type LanguageModelV1ResponseMetadata = {};
994
1024
 
995
1025
  /**
996
1026
  * Provider for language and text embedding models.
@@ -1020,4 +1050,4 @@ interface ProviderV1 {
1020
1050
  textEmbeddingModel(modelId: string): EmbeddingModelV1<string>;
1021
1051
  }
1022
1052
 
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 };
1053
+ 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 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.23",
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",