I'm trying to use the OpenAI Responses API with image input (Vision). Following the official documentation example. I am getting this type error
Type '{ type: "input_text"; text: string; } | { type: "input_image"; image_url: string; }' is not assignable to type 'ResponseInputContent'.
This is the example from openAI documentation page that is returning the error.
import OpenAI from "openai";
const client = new OpenAI();
const response = await client.responses.create({
model: "gpt-5",
input: [
{
role: "user",
content: [
{
type: "input_text",
text: "What is in this image?",
},
{
type: "input_image",
image_url: "https://openai-documentation.vercel.app/images/cat_and_otter.png",
},
],
},
],
});
console.log(response.output_text);
The reason you are encountering this error is that when you have an input type of input_imageYou also need to specify detail as it is a required type of ResponseInputImage
const response = await client.responses.create({
model: "gpt-5",
input: [
{
role: "user",
content: [
{
type: "input_text",
text: "Analyze the following ingredients list",
},
{
type: "input_image",
image_url:
"https://openai-documentation.vercel.app/images/cat_and_otter.png",
detail: "auto",
},
],
},
],
});
console.log(response.output_text);