# Anthropic Claude API assistant prefill JSON prefix 400 migrated model assistant message must not end with trailing whitespace

Status: search-observed
Product: Claude API
Last verified: 2026-06-25
Canonical HTML: https://gitdocs.org/fix/anthropic-claude-api-assistant-prefill-json-prefix-400-migrated-model-assistant-message-must-not
Machine JSON: https://gitdocs.org/api/fixes/anthropic-claude-api-assistant-prefill-json-prefix-400-migrated-model-assistant-message-must-not.json

## Exact Symptom

See the observed Codex queries below.

## Diagnosis

SDK types may still accept fields that the selected hosted model rejects; model retirement, tokenizer, thinking, and tool behavior are external and fast-moving.

## Fix

```
Verifier checks current model ID, accepted payload, structured output/tool parsing, and behavior under retries.
```

## Avoid

- Changing local code without checking the current external contract.
- Retrying the same install, build, or API call with no version/source change.
- Applying a broad unsafe bypass when a narrow compatibility fix is available.

## Observed Codex Queries

- Anthropic Claude API assistant prefill JSON prefix 400 migrated model assistant message must not end with trailing whitespace
- Claude API 400 prefill assistant message JSON prefix
- site:docs.anthropic.com assistant prefill Claude Messages API
- Anthropic docs prefill Claude response assistant role
- https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/prefill-claudes-response
- site:platform.claude.com/docs prefill response assistant message
- https://platform.claude.com/docs/llms.txt
- "assistant" "prefill" "400" "Claude"
- site:docs.anthropic.com "prefill" "extended thinking"
- Claude extended thinking prefill not supported
- https://docs.anthropic.com/en/api/messages
- https://raw.githubusercontent.com/anthropics/anthropic-sdk-typescript/main/README.md
- platform.claude.com/docs/en/api/messages.md
- https://platform.claude.com/docs/en/docs/test-and-evaluate/strengthen-guardrails/increase-consistency

## Sources

- Claude model migration guide: https://platform.claude.com/docs/en/about-claude/models/migration-guide
- Official reference opened by Codex: https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/prefill-claudes-response
- Official reference opened by Codex: https://platform.claude.com/docs/llms.txt
- Official reference opened by Codex: https://docs.anthropic.com/en/api/messages
- Official reference opened by Codex: https://raw.githubusercontent.com/anthropics/anthropic-sdk-typescript/main/README.md
- Official reference opened by Codex: https://platform.claude.com/docs/en/docs/test-and-evaluate/strengthen-guardrails/increase-consistency
