openai-node icon indicating copy to clipboard operation
openai-node copied to clipboard

TypeScript type error: ResponseInputImage.detail should be optional & documentation example does not match type definitions

Open princeaden1 opened this issue 3 months ago • 0 comments

Confirm this is a Node library issue and not an underlying OpenAI API issue

  • [x] This is an issue with the Node library

Describe the bug

The detail parameter was marked as required in the TypeScript interface despite the comment indicating it has a default value of 'auto'. When the detail is omitted from the code, the openai api perform as expected but IDE will always flag detail as required (typescript). From all the examples provided on openai documentation pages, detail is optional. ChatGPT example is also reflecting what is on OpenAI documentation page.

I have created two PRs on this:

  1. [The first PR solved the] (fix: make detail parameter optional in ResponseInputImage interface #1575)
  2. better documentation on this: add vision example using image URL #1571

To Reproduce

Copy and paste this in the IDE, the input will throw type error which

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);

Code snippets


OS

MacOS

Node version

Node.js v18.20.8

Library version

"openai": "^6.7.0"

princeaden1 avatar Oct 30 '25 12:10 princeaden1