@ai-sdk/anthropic 4.0.90 → 4.0.92

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/anthropic",
3
- "version": "4.0.90",
3
+ "version": "4.0.92",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@ai-sdk/provider": "4.0.34",
39
- "@ai-sdk/provider-utils": "5.0.70"
39
+ "@ai-sdk/provider-utils": "5.0.71"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@ai-sdk/test-server": "2.0.4",
@@ -3667,6 +3667,13 @@ function resolveAnthropicReasoningConfig({
3667
3667
  // `between_tools` is the lowest thinking setting on models that support
3668
3668
  // it: no upfront thinking, only short progress notes between tool calls.
3669
3669
  if (supportsBetweenToolsThinking) {
3670
+ warnings.push({
3671
+ type: 'compatibility',
3672
+ feature: 'reasoning',
3673
+ details:
3674
+ `reasoning 'none' is not supported by ${modelId}; thinking cannot be disabled. ` +
3675
+ `Using 'between_tools' thinking, the lowest thinking setting, instead.`,
3676
+ });
3670
3677
  return { thinking: { type: 'between_tools' } };
3671
3678
  }
3672
3679
 
@@ -3691,11 +3698,10 @@ function resolveAnthropicReasoningConfig({
3691
3698
  const effort = mapReasoningToProviderEffort({
3692
3699
  reasoning,
3693
3700
  effortMap: {
3694
- minimal: 'low' as const,
3695
3701
  low: 'low' as const,
3696
3702
  medium: 'medium' as const,
3697
3703
  high: 'high' as const,
3698
- xhigh: supportsXhighEffort ? ('xhigh' as const) : ('max' as const),
3704
+ ...(supportsXhighEffort && { xhigh: 'xhigh' as const }),
3699
3705
  max: 'max' as const,
3700
3706
  },
3701
3707
  warnings,
@@ -3712,9 +3718,6 @@ function resolveAnthropicReasoningConfig({
3712
3718
  maxReasoningBudget: maxOutputTokensForModel,
3713
3719
  warnings,
3714
3720
  });
3715
- if (budgetTokens == null) {
3716
- return undefined;
3717
- }
3718
3721
  return { thinking: { type: 'enabled', budgetTokens } };
3719
3722
  }
3720
3723
 
@@ -160,18 +160,8 @@ export function createAnthropic(
160
160
  });
161
161
  }
162
162
 
163
- const getHeaders = async () => {
164
- const authHeaders: Record<string, string> = options.authToken
165
- ? { Authorization: `Bearer ${await resolve(options.authToken)}` }
166
- : {
167
- 'x-api-key': loadApiKey({
168
- apiKey: options.apiKey,
169
- environmentVariableName: 'ANTHROPIC_API_KEY',
170
- description: 'Anthropic',
171
- }),
172
- };
173
-
174
- return withUserAgentSuffix(
163
+ const createHeaders = (authHeaders: Record<string, string>) =>
164
+ withUserAgentSuffix(
175
165
  {
176
166
  'anthropic-version': '2023-06-01',
177
167
  ...authHeaders,
@@ -179,6 +169,28 @@ export function createAnthropic(
179
169
  },
180
170
  `ai-sdk-anthropic/${VERSION}`,
181
171
  );
172
+
173
+ const getHeaders = () => {
174
+ const authToken = options.authToken;
175
+
176
+ if (authToken) {
177
+ const token = typeof authToken === 'function' ? authToken() : authToken;
178
+ const createBearerHeaders = (token: string) =>
179
+ createHeaders({ Authorization: `Bearer ${token}` });
180
+
181
+ // Keep synchronous credentials serializable across workflow boundaries.
182
+ return typeof token === 'string'
183
+ ? createBearerHeaders(token)
184
+ : resolve(token).then(createBearerHeaders);
185
+ }
186
+
187
+ return createHeaders({
188
+ 'x-api-key': loadApiKey({
189
+ apiKey: options.apiKey,
190
+ environmentVariableName: 'ANTHROPIC_API_KEY',
191
+ description: 'Anthropic',
192
+ }),
193
+ });
182
194
  };
183
195
 
184
196
  const languageModelConfig = {