Skip to content

400 Invalid type for 'image': expected a file, but got an array instead #1492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
ashbuilds opened this issue May 3, 2025 · 0 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@ashbuilds
Copy link

ashbuilds commented May 3, 2025

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 latest version of the openai-node SDK defines the image parameter in images.edit() as accepting either a single Uploadable or an array of Uploadable files:

export interface ImageEditParams {
  image: Core.Uploadable | Array<Core.Uploadable>;
  ...
}

However, when I try to pass an array of images to the image field while using the gpt-image-1 model (as the type definition seems to allow), the API responds with:

400 Invalid type for 'image': expected a file, but got an array instead.

To Reproduce

import OpenAI from "openai";

const client = new OpenAI();

const images = await Promise.all([
  fetch(`http://localhost:3000${img.image.url_1}`),
  fetch(`http://localhost:3000${img.image.url_2}`),
]);

await client.images.edit({
  model: "gpt-image-1",
  prompt: "Combine these",
  image: images, // 👈 Passes an array as allowed by type definition
});

OS

macOs

Node version

Node v22.10.0

Library version

v4.97.0

@ashbuilds ashbuilds added the bug Something isn't working label May 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant