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