OpenAI API 400: image_url is only supported by certain models
BadRequestError: 400 Invalid content type. image_url is only supported by certain models.Short answer
The request carried an image part, but the model you named cannot take image input. Switch to a model from OpenAI's vision guide, such as gpt-4o or gpt-4.1. Also check the content part type: Chat Completions uses image_url, while the Responses API uses input_image.
Fix it fast
1Find out which cause you have
Print the model name and the types of the content parts that go in the request. The error is about that combination.
console.log(model); console.log(messages.map((m) => Array.isArray(m.content) ? m.content.map((p) => p.type) : typeof m.content));2Match what you see, then jump to its fix
What does the error look like?
BadRequestError: 400 Invalid content type. image_url is only supported by certain models.
Cause 1 of 2
The model does not accept images
1Check
OpenAI's image guide lists the general-purpose models that take image input, for example gpt-4o, gpt-4o-mini and gpt-4.1. A model that is not on that list, or an old text-only name still left in your config, rejects the image.
grep -rn "model:" src/ .env* 2>/dev/null2Fix
Set the model to one from the vision guide's list.
const completion = await client.chat.completions.create({
model: "gpt-4o",
messages: [
{
role: "user",
content: [
{ type: "text", text: "What is in this image?" },
{ type: "image_url", image_url: { url: "https://example.com/photo.jpg" } },
],
},
],
});3Verify
Send the same request and read the first choice.
console.log(completion.choices[0].message.content);Confirmed by developers.openai.com
Cause 2 of 2
The content part type does not match the API you call
1Check
In the Chat Completions reference a user message part of type image_url carries an image_url object with a url (a link or base64 data) and an optional detail. The vision guide's Responses API example uses an input_image item next to input_text instead.
grep -rn -e "input_image" -e "image_url" src/2Fix
Use image_url with chat.completions, or input_image with responses, and match the text part type as well.
const response = await client.responses.create({
model: "gpt-4o",
input: [
{
role: "user",
content: [
{ type: "input_text", text: "What is in this image?" },
{ type: "input_image", image_url: "https://example.com/photo.jpg", detail: "auto" },
],
},
],
});3Verify
Run the request and print the output text.
console.log(response.output_text);Confirmed by developers.openai.com
How do I stop it coming back?
- Keep the model name in one config value and check it against the vision guide when you change it.
- Write one helper that builds the image part, so the part type lives in a single place.
- Stay within the documented image formats (PNG, JPEG, WEBP, non-animated GIF) and size limits.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
AI
The model's reply breaks JSON.parse
SyntaxError: Unterminated string in JSON at position 1874
JSON.parse rejects model output for a few repeatable reasons: the JSON sits inside markdown fences or next to a sentence, the reply stopped at the token limit mid-object, a stream was parsed before it ended, or the model refused.
5 causes, each with a fixAI
The OpenAI Node client in Next.js cannot find OPENAI_API_KEY
either provide it, or instantiate the OpenAI client with an apiKey option
The OpenAI client reads process.env.OPENAI_API_KEY when you create it.
3 causes, each with a fixAI
The OpenAI API answers 429: out of credit, or just too fast?
"type": "insufficient_quota"
A 429 from the OpenAI API means one of two unrelated things.
5 causes, each with a fixAI
Azure OpenAI says the API deployment for this resource does not exist
The API deployment for this resource does not exist
Azure OpenAI does not take a model name in the model field.
2 causes, each with a fixAI
Azure OpenAI fails with an SSL certificate verification error
httpx.ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED]
The client checks the endpoint's certificate against its CA bundle, which is certifi by default.
2 causes, each with a fixAI
Gemini API says the model is not found for gemini-1.5-pro or gemini-1.5-flash
models/gemini-1.5-flash is not found for API version v1beta
Google shut down gemini-1.5-pro, gemini-1.5-flash and gemini-1.5-flash-8b on 29 September 2025, so the API no longer finds them, whatever access you have.
3 causes, each with a fix