400 on reasoning models: the usual culprits
max_tokens: OpenAI's Chat Completions reference says it "is now deprecated in favor ofmax_completion_tokens, and is not compatible with o-series models". Usemax_completion_tokens(Chat Completions) ormax_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 notnone, removetemperature,top_p, andtop_logprobs." For Chat Completions also removelogprobs.reasoning_effort: "none"on a model that doesn't support it returns HTTP 400, per OpenAI's reasoning guide.- Old SDK: upgrade the
openaipackage; 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_tierargument": "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
- 500: retry after a brief wait; "contact us if the issue persists". Check status.openai.com.
- 503
server_is_overloaded: "The requested model is temporarily overloaded." FollowRetry-Afterif present, otherwise exponential backoff with jitter and a retry cap. - Log the request ID: the
x-request-idresponse 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.
- OpenAI API docs: Error codes: developers.openai.com/api/docs/guides/error-codes
- OpenAI API reference: Create chat completion (max_tokens, max_completion_tokens): developers.openai.com/api/reference/resources/chat/subresources/completions/methods/create
- OpenAI docs: Reasoning models: developers.openai.com/api/docs/guides/reasoning
- OpenAI docs: Using the latest model (parameter changes): developers.openai.com/api/docs/guides/latest-model/gpt-6-astra.md
- OpenAI docs: Conversation state and context window: developers.openai.com/api/docs/guides/conversation-state
- OpenAI API reference: Overview (x-request-id): developers.openai.com/api/reference/overview
- OpenAI status page: status.openai.com
- LLM API cost checker: find LLM calls with no limits or retries capped
- Exposed API key checker: find API keys committed to a repo or shipped to the browser
- reviewready CLI: one command that checks an AI app repo before it ships