Skip to content

images.edit endpoint rejects GPT Image models #1844

@melihmucuk

Description

@melihmucuk

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

  • This is an issue with the Node library

Describe the bug

The images.edit endpoint currently appears to be in a broken state for all models:

  1. GPT Image models are rejected with a model validation error.
  2. dall-e-2 is reported as non-existent when explicitly provided.

This makes the images.edit endpoint completely unusable via the Node.js SDK (and presumably the raw API as well).

Environment

  • SDK: openai npm package v6.34.0 (latest)
  • Runtime: Node.js v22.14.0
  • API Key: Valid, confirmed working for images.generate

Expected Behavior

Per the Image Generation guide, gpt-image-2 should support image editing:

"Creates an edited or extended image given one or more source images and a prompt. This endpoint supports GPT Image models (gpt-image-1.5, gpt-image-1, gpt-image-1-mini, and chatgpt-image-latest) and dall-e-2."

The following request should succeed:

const { OpenAI, toFile } = require("openai");
const fs = require("fs");
const client = new OpenAI();

const image = await toFile(fs.createReadStream("photo.png"));

const response = await client.images.edit({
  model: "gpt-image-2",
  image,
  prompt: "make the apple green",
});

Actual Behavior

1. GPT Image models are rejected

Request:

await client.images.edit({
  model: "gpt-image-2",
  image,
  prompt: "make the apple green",
});

Response:

400 Invalid value: 'gpt-image-2'. Value must be 'dall-e-2'.

The same error occurs for gpt-image-1, gpt-image-1.5, gpt-image-1-mini, and chatgpt-image-latest.

2. dall-e-2 is reported as non-existent

Request:

await client.images.edit({
  model: "dall-e-2",
  image,
  prompt: "make the apple green",
});

Response:

400 The model 'dall-e-2' does not exist.

To Reproduce

The issue is reproducible with raw HTTP as well:

curl -X POST "https://api.openai.com/v1/images/edits" \
  -H "Authorization: Bearer \$OPENAI_API_KEY" \
  -F "model=gpt-image-2" \
  -F "image=@photo.png" \
  -F "prompt=make the apple green"

Response:

{
  "error": {
    "message": "Invalid value: 'gpt-image-2'. Value must be 'dall-e-2'.",
    "type": "invalid_request_error",
    "param": "model",
    "code": null
  }
}
curl -X POST "https://api.openai.com/v1/images/edits" \
  -H "Authorization: Bearer \$OPENAI_API_KEY" \
  -F "model=dall-e-2" \
  -F "image=@photo.png" \
  -F "prompt=make the apple green"

Response:

{
  "error": {
    "message": "The model 'dall-e-2' does not exist.",
    "type": "invalid_request_error",
    "param": "model",
    "code": "model_not_found"
  }
}

Additional Context

  • images.generate works correctly with gpt-image-2 and all other GPT Image models.
  • The issue is specific to images.edit.
  • The images.edit SDK method correctly routes to /images/edits and uses multipart/form-data, so this is an API-side validation issue, not an SDK bug.

Code snippets

async function edit(args) {
  const prompt = args._.slice(1).join(' ');
  if (!prompt) {
    console.error('Error: prompt is required');
    process.exit(1);
  }
  if (!args.image) {
    console.error('Error: --image is required');
    process.exit(1);
  }

  const body = {
    prompt,
    image: await toFile(fs.createReadStream(args.image)),
    model: args.model || DEFAULT_MODEL,
  };
  if (args.mask) body.mask = await toFile(fs.createReadStream(args.mask));
  if (args.n) body.n = parseInt(args.n, 10);
  if (args.size) body.size = args.size;
  if (args.background) body.background = args.background;
  if (args.user) body.user = args.user;

  const res = await client.images.edit(body);
  const data = res.data || [];
  const prefix = 'png';
  const paths = [];
  for (let i = 0; i < data.length; i++) {
    paths.push(saveImage(data[i].b64_json, prefix, i));
  }
  for (const p of paths) console.log(p);
}

OS

macOS

Node version

Node v22.14.0

Library version

openai v6.34.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions