Anthropic 400: request validation and model migrations

Inspect Claude request validation, configured spend limits, thinking contracts, prefill restrictions and model-specific sampling controls.

By benchr Editorial Team · · · Changelog

Provider documentation read . Documentation review; no provider execution is established by this date.

Anthropic's invalid_request_error means the request was rejected, but HTTP 400 is not limited to malformed JSON. The current documentation also returns it for some configured spend limits. Read the structured error and message before removing fields or retrying.

Check for an account limit before rebuilding a valid request

When usage reaches an organization or workspace spend limit you set, Anthropic documents a 400 response identifying the specified API or workspace usage limit. Raising or removing that limit requires the appropriate account authority. Its monthly tier cap instead uses a 429 spend-cap response, and Claude Code workspace limits have separate behavior.

If the message identifies an invalid field, inspect the exact API host, endpoint, version header, model, and serialized value. A request can parse as JSON while using a field, type, or combination that the selected model does not accept.

Use the model's thinking contract

Anthropic's current error guide says Claude 4.7 and later models reject the old extended-thinking configuration thinking: {"type": "enabled"}. They use adaptive thinking and an appropriate output_config.effort setting. Models supporting only extended thinking, such as Claude 4.5 and earlier, reject an adaptive configuration instead. Do not apply one request builder to both generations without a capability check.

For a migration, inspect whether thinking is enabled by default and which effort controls the exact model accepts. Remove obsolete fields deliberately. A changed parameter contract does not imply that the model's reasoning is disabled or that a manual token budget still applies.

For example, the current error guide gives Claude Sonnet 5.5 a model-specific between_tools setting instead of disabled for its lowest thinking mode. It also documents effort restrictions in that mode. Do not send between_tools to another model or describe it as a universal way to turn reasoning off.

Do not rebuild signed thinking blocks

If the latest assistant turn contains thinking or redacted_thinking blocks, pass them back unchanged when the documented tool workflow requires them. Anthropic specifically warns against editing, reordering, filtering, or reconstructing these blocks, including blocks with an empty thinking field.

Inspect middleware that stores conversation history, strips unfamiliar block types, or recreates responses from displayed text. A display projection is not a complete protocol record. Preserve the original blocks in the protected application state and keep their content out of routine diagnostic logs.

The current error guide also documents prefix binding for replayed thinking on selected newer models: changing the preceding system prompt, tools, or messages can make an otherwise unchanged block invalid. The handling depends on the model, account conditions, and the documented binding configuration. Preserve protocol state and follow that model's recovery contract; passing original bytes alone does not establish that a changed conversation prefix is accepted.

Remove assistant prefill where unsupported

The current guide identifies Claude 4.6 and later, and Claude Mythos Preview, as not supporting a prefilled final assistant message. Ending with a partial assistant response can produce a 400. Use documented structured outputs on a supporting model or an instruction describing the required output. A prompt instruction is not a deterministic replacement for a sampling setting.

Sampling controls are model-specific

The error documentation explains restrictions on temperature, top_p, and top_k for current models. Remove nondefault sampling controls when the selected model rejects them; do not assume that a field accepted by another provider or an older Claude model remains valid. Consult the named model's migration and error guidance rather than assigning a new arbitrary value.

Check tool selection and tool versions

The current guide lists Claude Opus 5.5, Sonnet 5.5, Fable 5.1, and Mythos 5.1 as rejecting forced tool_choice values any and tool, including on the token-counting endpoint. It documents auto and none instead. Schema-valid tool inputs and forcing a call are different capabilities.

It also gives newer models a platform-specific computer-use toolset contract. Check the exact tool type and required headers for the model and deployment; do not copy an older computer tool entry into a newer integration or assume Amazon Bedrock has the same version acceptance.

Reduce a reproducer without losing the cause

  1. Keep the model ID, API version, and deployment scope fixed while isolating the request.
  2. Compare the required fields with the exact endpoint schema. Do not change the model and payload simultaneously.
  3. Remove optional features one at a time, retaining a redacted diff of which field changes the outcome.
  4. Restore tools, structured outputs, attachments, thinking configuration, and history separately. Preserve protocol blocks rather than copying only rendered text.
  5. Record the request ID and offending field path if provided. Escalate a minimal redacted reproducer when the documented request still fails.

No authenticated request was executed for this guide, and no “before/after” payload is presented as a captured result. The lifecycle record identifies exact retired IDs; changing one requires a separate review of the replacement's request contract.

Changelog

  • 2026-10-15 — Rebuilt validation guidance to include configured spend limits, current thinking modes, Sonnet 5.5 between_tools scope, prefix binding and prefill restrictions. Removed unsupported deterministic-prompt claims and stale model-price promotion.
  • — Updated the Opus 4 and 4.1 migration note: Opus 4.1 retired August 5, 2026, Opus 4.8 is now legacy, and benchr's pick for new code is Claude Opus 5 ($5/$25). Noted that OpenAI's GPT-6 Astra also drops custom temperature and top_p.
  • — Published. Prefill restriction, thinking-block rule, and the Opus 4.7+ sampling-parameter deprecation verified against Anthropic's API error and deprecation docs.

Sources and documentation review

Documentation review dates are recorded per source. No provider inference or independent benchmark replication was performed for this revision.

  1. Claude API errors and current model validation — read
  2. Claude configured spend limits — read