@ai-sdk/anthropic 4.0.112 → 4.0.114

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.
@@ -596,12 +596,32 @@ When the JSON tool cannot be forced (for example with manual thinking) and the
596
596
  model answers in text without calling it, the text of its final answer is
597
597
  returned. Text before a tool call is still dropped.
598
598
 
599
+ ### Sampling
600
+
601
+ `claude-opus-4-7`, `claude-opus-4-8`, and Claude 5 models do not support
602
+ configurable `temperature`, `topP`, or `topK`. The SDK omits these settings
603
+ with a warning. A fixed temperature of `1` may be accepted with adaptive
604
+ thinking, but does not provide a configurable sampling control.
605
+
606
+ Claude 4.5 and 4.6 models accept sampling settings when thinking is disabled.
607
+ The SDK omits sampling settings when thinking is enabled.
608
+
599
609
  ### Effort
600
610
 
601
611
  Anthropic introduced an `effort` option with `claude-opus-4-5` that affects thinking, text responses, and function calls. Effort defaults to `high` and you can set it to `medium` or `low` to save tokens and to lower time-to-last-token latency (TTLT). `claude-opus-4-7`, `claude-opus-4-8`, `claude-opus-5`, `claude-opus-5-5`, `claude-fable-5`, `claude-fable-5-1`, `claude-fable-5-2`, `claude-sonnet-5`, `claude-sonnet-5-5`, and `claude-haiku-5-5` additionally support `xhigh` for maximum reasoning effort.
602
612
 
613
+ `claude-opus-4-5` accepts `low`, `medium`, and `high`. `claude-opus-4-6`
614
+ and `claude-sonnet-4-6` also accept `max`, but reject `xhigh`.
615
+ `claude-haiku-4-5` and `claude-sonnet-4-5` do not support the effort option.
616
+
603
617
  On `claude-opus-5` and `claude-haiku-5-5`, thinking can only be disabled at effort levels up to and including `high`. When you combine `thinking: { type: 'disabled' }` with `effort: 'xhigh'` or `effort: 'max'`, the AI SDK lowers the effort to `high` and emits a warning instead of sending a request that the API would reject.
604
618
 
619
+ `claude-opus-4-7`, `claude-opus-4-8`, `claude-opus-5`, and `claude-sonnet-5`
620
+ support adaptive thinking but reject
621
+ thinking token budgets. The AI SDK converts
622
+ `thinking: { type: 'enabled', budgetTokens }` to `{ type: 'adaptive' }` and
623
+ emits a warning. Use `effort` to control how much these models think.
624
+
605
625
  `claude-haiku-5-5` is the first Haiku model with effort levels and supports all
606
626
  five of them. It uses adaptive thinking and does not support thinking token
607
627
  budgets: the AI SDK converts `thinking: { type: 'enabled', budgetTokens }` to
@@ -655,7 +675,7 @@ console.log(usage); // token usage
655
675
 
656
676
  ### Fast Mode
657
677
 
658
- Anthropic supports a [`speed` option](https://code.claude.com/docs/en/fast-mode) for `claude-opus-4-6` that enables faster inference with approximately 2.5x faster output token speeds.
678
+ Anthropic supports a [`speed` option](https://code.claude.com/docs/en/fast-mode) for `claude-opus-4-6`, `claude-opus-4-8`, `claude-opus-5`, `claude-opus-5-5`, and `claude-fable-5-2` that enables faster inference.
659
679
 
660
680
  ```ts highlight="8-10"
661
681
  import { anthropic, AnthropicLanguageModelOptions } from '@ai-sdk/anthropic';
@@ -680,6 +700,9 @@ The `speed` option accepts `'fast'` or `'standard'` (default behavior).
680
700
 
681
701
  Task budgets are advisory — they do not enforce a hard token limit. The model will attempt to stay within budget, but actual usage may vary.
682
702
 
703
+ `claude-opus-4-5`, `claude-opus-4-6`, `claude-sonnet-4-6`,
704
+ `claude-haiku-4-5`, and `claude-sonnet-4-5` reject task budgets.
705
+
683
706
  ```ts highlight="8-13"
684
707
  import { anthropic, AnthropicLanguageModelOptions } from '@ai-sdk/anthropic';
685
708
  import { generateText } from 'ai';
@@ -735,6 +758,9 @@ const { text } = await generateText({
735
758
 
736
759
  The `inferenceGeo` option accepts `'us'` (US-only infrastructure) or `'global'` (default, any available geography).
737
760
 
761
+ `claude-opus-4-5`, `claude-haiku-4-5`, and `claude-sonnet-4-5` do not
762
+ support this option.
763
+
738
764
  ### Safety Classifiers and Fallbacks
739
765
 
740
766
  Claude Fable 5 has safeguards that limit its performance in certain areas like cybersecurity, biology, and chemistry, and automated safety checks are run on every request.
@@ -1150,6 +1176,11 @@ on how to integrate reasoning into your chatbot.
1150
1176
 
1151
1177
  Anthropic's Context Management feature allows you to automatically manage conversation context by clearing tool uses or thinking content when certain conditions are met. This helps optimize token usage and manage long conversations more efficiently.
1152
1178
 
1179
+ `claude-opus-4-5`, `claude-haiku-4-5`, and `claude-sonnet-4-5` accept
1180
+ tool-use clearing configuration, but reject compaction edits and the
1181
+ `compaction` provider option. The model capabilities table lists compaction
1182
+ support separately.
1183
+
1153
1184
  You can configure context management using the `contextManagement` provider option:
1154
1185
 
1155
1186
  ```ts highlight="7-20"
@@ -1556,6 +1587,8 @@ Shorter prompts cannot be cached, even if marked with `cacheControl`. Any reques
1556
1587
 
1557
1588
  For more on prompt caching with Anthropic, see [Anthropic's Cache Control documentation](https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching).
1558
1589
 
1590
+ If the number of cached tokens drops after you load the conversation history from a database, see [Prompt Cache Misses With Stored Messages](/docs/troubleshooting/prompt-cache-misses-with-stored-messages).
1591
+
1559
1592
  <Note type="warning">
1560
1593
  Because the `UIMessage` type (used by AI SDK UI hooks like `useChat`) does not
1561
1594
  support the `providerOptions` property, you can use `convertToModelMessages`
@@ -2189,6 +2222,10 @@ when it follows other messages. To keep such a message in place, for example a
2189
2222
  reminder appended to a conversation that has no initial instructions, set
2190
2223
  `providerOptions.anthropic.midConversationSystemMessages: true` on the request.
2191
2224
 
2225
+ `claude-opus-4-5`, `claude-opus-4-6`, `claude-opus-4-7`,
2226
+ `claude-sonnet-4-6`, `claude-haiku-4-5`, and `claude-sonnet-4-5` reject
2227
+ system messages inside the message history.
2228
+
2192
2229
  Use the same value on every request of a conversation. Changing it moves the
2193
2230
  message between the top-level `system` field and `messages`, so the next request
2194
2231
  misses the prompt cache, and thinking blocks from earlier turns can fail
@@ -2801,28 +2838,43 @@ and the `mediaType` should be set to `'application/pdf'`.
2801
2838
 
2802
2839
  ### Model Capabilities
2803
2840
 
2841
+ Use `anthropicModelCapabilities(modelId)` to look up a model's capabilities and
2842
+ provider options for the Messages API. Model IDs have autocomplete, and the lookup
2843
+ requires no API call. It returns `undefined` for unknown model IDs.
2844
+
2845
+ ```ts
2846
+ import { anthropicModelCapabilities } from '@ai-sdk/anthropic';
2847
+
2848
+ const model = anthropicModelCapabilities('claude-sonnet-5-5');
2849
+ console.log(model?.endpoints.messages);
2850
+ ```
2851
+
2852
+ <Note>
2853
+ `claude-opus-4-0`, `claude-opus-4-1`, and `claude-sonnet-4-0` are hidden from
2854
+ this catalog because requests returned 404s. Their historical capability
2855
+ declarations could not be revalidated and may be outdated. Their internal
2856
+ request settings are retained for compatibility.
2857
+ </Note>
2858
+
2804
2859
  {/* model-capabilities:anthropic-language:start */}
2805
2860
 
2806
- | Model | Image Input | Object Generation | Tool Usage | Computer Use | Web Search | Tool Search | Compaction |
2807
- | ------------------- | ----------- | ----------------- | ---------- | ------------ | ---------- | ----------- | ---------- |
2808
- | `claude-opus-5-5` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
2809
- | `claude-opus-5` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
2810
- | `claude-sonnet-5-5` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
2811
- | `claude-sonnet-5` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
2812
- | `claude-haiku-5-5` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
2813
- | `claude-fable-5-2` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
2814
- | `claude-fable-5-1` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
2815
- | `claude-fable-5` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
2816
- | `claude-opus-4-8` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
2817
- | `claude-opus-4-7` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
2818
- | `claude-opus-4-6` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
2819
- | `claude-sonnet-4-6` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
2820
- | `claude-opus-4-5` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Cross /> |
2821
- | `claude-haiku-4-5` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Cross /> |
2822
- | `claude-sonnet-4-5` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Cross /> |
2823
- | `claude-opus-4-1` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Cross /> | <Cross /> |
2824
- | `claude-opus-4-0` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Cross /> | <Cross /> |
2825
- | `claude-sonnet-4-0` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Cross /> | <Cross /> |
2861
+ | Model | Image Input | Object Generation | Tool Usage | Computer Use | Web Search | Tool Search | Compaction |
2862
+ | ------------------- | ----------- | ----------------- | ---------- | --------------------------------------------------------------------- | ---------- | ----------- | ---------- |
2863
+ | `claude-opus-5-5` | <Check /> | <Check /> | <Check /> | Conditional: Requires computer_toolset_20260801. | <Check /> | <Check /> | <Check /> |
2864
+ | `claude-opus-5` | <Check /> | <Check /> | <Check /> | Conditional: Requires computer_20251124 or computer_toolset_20260801. | <Check /> | <Check /> | <Check /> |
2865
+ | `claude-sonnet-5-5` | <Check /> | <Check /> | <Check /> | Conditional: Requires computer_toolset_20260801. | <Check /> | <Check /> | <Check /> |
2866
+ | `claude-sonnet-5` | <Check /> | <Check /> | <Check /> | Conditional: Requires computer_20251124 or computer_toolset_20260801. | <Check /> | <Check /> | <Check /> |
2867
+ | `claude-haiku-5-5` | <Check /> | <Check /> | <Check /> | Conditional: Requires computer_toolset_20260801. | <Check /> | <Check /> | <Check /> |
2868
+ | `claude-fable-5-2` | <Check /> | <Check /> | <Check /> | Conditional: Requires computer_toolset_20260801. | <Check /> | <Check /> | <Check /> |
2869
+ | `claude-fable-5-1` | <Check /> | <Check /> | <Check /> | Conditional: Requires computer_20251124 or computer_toolset_20260801. | <Check /> | <Check /> | <Check /> |
2870
+ | `claude-fable-5` | <Check /> | <Check /> | <Check /> | Conditional: Requires computer_20251124 or computer_toolset_20260801. | <Check /> | <Check /> | <Check /> |
2871
+ | `claude-opus-4-8` | <Check /> | <Check /> | <Check /> | Conditional: Requires computer_20251124 or computer_toolset_20260801. | <Check /> | <Check /> | <Check /> |
2872
+ | `claude-opus-4-7` | <Check /> | <Check /> | <Check /> | Conditional: Requires computer_20251124. | <Check /> | <Check /> | <Check /> |
2873
+ | `claude-opus-4-6` | <Check /> | <Check /> | <Check /> | Conditional: Requires computer_20251124. | <Check /> | <Check /> | <Check /> |
2874
+ | `claude-sonnet-4-6` | <Check /> | <Check /> | <Check /> | Conditional: Requires computer_20251124. | <Check /> | <Check /> | <Check /> |
2875
+ | `claude-opus-4-5` | <Check /> | <Check /> | <Check /> | Conditional: Requires computer_20250124 or computer_20251124. | <Check /> | <Check /> | <Cross /> |
2876
+ | `claude-haiku-4-5` | <Check /> | <Check /> | <Check /> | Conditional: Requires computer_20250124. | <Check /> | <Check /> | <Cross /> |
2877
+ | `claude-sonnet-4-5` | <Check /> | <Check /> | <Check /> | Conditional: Requires computer_20250124. | <Check /> | <Check /> | <Cross /> |
2826
2878
 
2827
2879
  {/* model-capabilities:anthropic-language:end */}
2828
2880
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/anthropic",
3
- "version": "4.0.112",
3
+ "version": "4.0.114",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -35,16 +35,17 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@ai-sdk/provider": "4.0.39",
39
- "@ai-sdk/provider-utils": "5.0.86"
38
+ "@ai-sdk/provider": "4.0.40",
39
+ "@ai-sdk/provider-utils": "5.0.88"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@ai-sdk/test-server": "2.0.4",
43
43
  "@types/node": "22.19.19",
44
+ "@typescript/native": "npm:typescript@7.0.2",
44
45
  "@vercel/ai-tsconfig": "0.0.0",
45
46
  "@vercel/ai-tsdown-config": "0.0.0",
46
47
  "tsdown": "^0.23.0",
47
- "typescript": "6.0.3",
48
+ "typescript": "npm:@typescript/typescript6@6.0.2",
48
49
  "zod": "4.6.7"
49
50
  },
50
51
  "peerDependencies": {
@@ -75,6 +76,9 @@
75
76
  "clean": "del-cli docs",
76
77
  "type-check": "tsc --noEmit",
77
78
  "test": "pnpm test:node && pnpm test:edge",
79
+ "test:node22": "node ../../tools/with-node.mjs 22 pnpm test",
80
+ "test:node24": "node ../../tools/with-node.mjs 24 pnpm test",
81
+ "test:node26": "node ../../tools/with-node.mjs 26 pnpm test",
78
82
  "test:update": "pnpm test:node -u",
79
83
  "test:watch": "vitest --config vitest.node.config.js",
80
84
  "test:edge": "vitest --config vitest.edge.config.js --run",
@@ -369,8 +369,9 @@ export const anthropicLanguageModelOptions = lazySchema(() =>
369
369
  .optional(),
370
370
 
371
371
  /**
372
- * Enable fast mode for faster inference (2.5x faster output token speeds).
373
- * Only supported with claude-opus-4-6.
372
+ * Enable fast mode for faster inference.
373
+ * Supported with claude-opus-4-6, claude-opus-4-8, claude-opus-5, claude-opus-5-5,
374
+ * and claude-fable-5-2.
374
375
  */
375
376
  speed: z.enum(['fast', 'standard']).optional(),
376
377
 
@@ -1154,7 +1154,6 @@ export class AnthropicLanguageModel implements LanguageModelV4 {
1154
1154
  type: 'other',
1155
1155
  message: `Unknown context management strategy: ${strategy}`,
1156
1156
  });
1157
- return undefined;
1158
1157
  }
1159
1158
  })
1160
1159
  .filter(edit => edit !== undefined),