API 400 error when submitting image-only message (empty text content block)
Resolved 💬 7 comments Opened Apr 17, 2026 by willardjansen Closed May 30, 2026
Summary
When submitting a message containing only an image (no text), Claude Code sends an API request with an empty text content block, causing the Anthropic API to reject the request with a 400 error.
Error
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages: text content blocks must be non-empty"},"request_id":"req_011Ca9cUr9rBmqKijmBWEqps"}
Retries produce the same error with different request IDs — the bad payload is sent every time.
Reproduction
- Start a Claude Code session
- Paste or attach an image into the prompt without typing any text
- Submit
Expected: The image is accepted as the user turn (either alone, or with the empty text block stripped).
Actual: API Error: 400 — text content blocks must be non-empty.
Environment
- Claude Code CLI
- Model: Opus 4.7 (1M context)
- Platform: macOS (Darwin 25.4.0)
Likely Fix
Strip empty text content blocks before sending, or omit the text block entirely when the user turn only contains an image.
Screenshot
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗