You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The #849 default of the model's full output ceiling broke the non-streaming
`structuredOutput()` path: the Anthropic SDK refuses a non-streaming request
whose `max_tokens` could exceed its 10-minute timeout (~21,333 tokens), so
`chat({ outputSchema })` on any fallback-path model threw "Streaming is
required for operations that may take longer than 10 minutes".
`getAnthropicDefaultMaxTokens(model, { stream })` now clamps the default to
`ANTHROPIC_MAX_NONSTREAMING_TOKENS` when `stream: false`; the streaming chat
path keeps the model's full ceiling. An explicit oversized `max_tokens` still
surfaces the SDK's "use streaming" error.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/adapters/anthropic.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -140,6 +140,8 @@ const stream = chat({
140
140
141
141
Anthropic's Messages API _requires_`max_tokens` on every request, so the adapter always sends a value. When you don't set `modelOptions.max_tokens`, it defaults to the selected model's full output ceiling (`max_output_tokens` from the model metadata — e.g. 64K for Sonnet, 128K for Opus), falling back to a safe constant for unrecognized models. `max_tokens` is a ceiling, not a reservation — billing is on tokens actually generated — so this default costs nothing extra and avoids the silent mid-response truncation (`stop_reason: "max_tokens"`) that a low default would cause. Set `max_tokens` explicitly only when you want to _cap_ output below the model ceiling. If a response is truncated while using the default cap, the adapter logs a warning (visible with [debug logging](../advanced/debug-logging) enabled).
142
142
143
+
One exception: structured output (`chat({ outputSchema })`) on models that use the non-streaming finalization path clamps this default to ~21K tokens. The Anthropic SDK rejects a non-streaming request whose `max_tokens` could exceed its 10-minute timeout, so the full ceiling can't be used there. Streaming chat is unaffected. To raise the structured-output ceiling toward a model's true max, stream the response.
144
+
143
145
### Thinking (Extended Thinking)
144
146
145
147
Enable extended thinking with a token budget. This allows Claude to show its reasoning process, which is streamed as `thinking` chunks:
0 commit comments