Shipping an AI app or agent? Security review in 1 working day: $149 / ₹13,900. Request a review →
AI Review Ready
Home / Error fixes / OpenAI API 400 / 500
Fix · OpenAI API

OpenAI API error 400, 500 and 503

400: the request is malformed or uses something the model doesn't support; OpenAI says "The error message should advise you on the specific error made." 500: "Issue on our servers": retry after a short wait. 503 server_is_overloaded: wait for the Retry-After header, then retry.

400 on reasoning models: the usual culprits

  • max_tokens: OpenAI's Chat Completions reference says it "is now deprecated in favor of max_completion_tokens, and is not compatible with o-series models". Use max_completion_tokens (Chat Completions) or max_output_tokens (Responses API). It includes reasoning tokens, so don't set it too low.
  • temperature, top_p, top_logprobs: OpenAI's current model guide: "When reasoning effort is not none, remove temperature, top_p, and top_logprobs." For Chat Completions also remove logprobs.
  • reasoning_effort: "none" on a model that doesn't support it returns HTTP 400, per OpenAI's reasoning guide.
  • Old SDK: upgrade the openai package; older versions may send parameters newer models reject.

Developers report messages like Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead. That wording isn't in OpenAI's docs, but the fix is the one above.

400 because the input is too long

OpenAI: "The context window is the maximum number of tokens that can be used in a single request", counting input, output and reasoning tokens. Count tokens before sending (OpenAI's tokenizer or tiktoken), trim old turns, or in the Responses API set truncation: "auto" so the earliest conversation items are dropped. OpenAI's reasoning guide recommends "reserving at least 25,000 tokens for reasoning and outputs".

Other 400s

  • "Invalid service_tier argument": "The requested or resolved service tier is not allowed for the project."
  • Anything else: read error.message, check the parameter in the API reference, and check the request's JSON, encoding and size.

500 and 503

  1. 500: retry after a brief wait; "contact us if the issue persists". Check status.openai.com.
  2. 503 server_is_overloaded: "The requested model is temporarily overloaded." Follow Retry-After if present, otherwise exponential backoff with jitter and a retry cap.
  3. Log the request ID: the x-request-id response header; OpenAI recommends logging it in production and asks for it in support requests.

A 429 is different: OpenAI API error 429. Billing and quota 429s won't clear with retries.

Running Claude Code, Codex or Cursor on real repos, or shipping an AI agent? A Quick Review ($149 / ₹13,900, 1 working day) checks one repo, config or setup for leaked keys, risky agent permissions and MCP servers. Request a Quick Review

FAQ

What does OpenAI API error 400 mean?

The request was malformed or used a parameter the model doesn't accept. The error message names the problem. On reasoning models it is often max_tokens (use max_completion_tokens) or temperature/top_p.

Should I use max_tokens or max_completion_tokens?

OpenAI says max_tokens is deprecated in favor of max_completion_tokens and isn't compatible with o-series models. In the Responses API use max_output_tokens.

What should I do about OpenAI error 500?

It's a server-side issue. Retry after a short wait with backoff, check status.openai.com, and contact OpenAI with the x-request-id if it persists.

What is server_is_overloaded?

The 503 error when the requested model is temporarily overloaded. Wait for the Retry-After header, then retry.

Related errors

Sources

Read 2 Dec 2026. These tools change often: if a step no longer matches, the linked page wins.

Related free tools