Skip to main content
HTTP 400 Bad Request
The server cannot process the request due to a client error — malformed JSON, invalid parameters, or schema violations.
4xx · Client error✗ not retryable — fix the request instead
In AI APIs specifically
The most common AI-API 400s: max_tokens exceeding the model limit, invalid model IDs, malformed tool schemas, and context-window overflow (Anthropic returns 400 with an invalid_request_error when the prompt is too long).
Fix checklist
- Read the error body — providers return a specific message and param pointer.
- Validate JSON and tool schemas before sending.
- Check token counts against the model's context window.
- Pin SDK versions — request shapes change across API versions.
Spec: RFC reference
Related status codes
401 Unauthorized
Authentication is missing or invalid for this request..
402 Payment RequiredThe request requires payment — billing is not set up or a balance is exhausted..
403 ForbiddenThe server understood the request but refuses to authorize it — valid credentials, insufficient permission..
404 Not FoundThe requested resource does not exist at this URL..