Skip to main content
400Not retryable
OpenAI 400 Bad Request
Request validation failed — a parameter is malformed, missing, unsupported by the chosen model, or over a documented limit.
Most likely causes
- 1.Parameter unsupported by the model (e.g. temperature on some reasoning models)
- 2.messages content blocks malformed or empty
- 3.max_tokens/max_completion_tokens confusion between API generations
- 4.Invalid JSON in a tool/function definition
Fix checklist
- Read error.param in the body — OpenAI points at the exact field
- Check the model page for which parameters that model accepts
- Use max_completion_tokens on reasoning models, max_tokens elsewhere
- Validate tool schemas with a JSON Schema validator before shipping
Retry guidance
Not retryable — fix the request. Identical retries return identical 400s.
// 400 is NOT retryable — surface it and fix the request/config.
const res = await fetch("https://api.openai.com/v1/chat/completions", {
method: "POST",
headers: {
"content-type": "application/json",
Authorization: `Bearer ${process.env.OPENAI_API_KEY}`,
},
body: JSON.stringify(payload),
});
if (res.status === 400) {
const body = await res.json();
// Do not retry: log the provider's message — it names the exact problem.
throw new Error(`OpenAI 400: ${JSON.stringify(body.error ?? body)}`);
}Provider status page: status.openai.com