Confirm this is a Node library issue and not an underlying OpenAI API issue
Describe the bug
When using AzureOpenAI without a client-level deployment and passing the deployment via the per-request model param (the documented pattern, which works for chat completions, embeddings, audio transcriptions/translations and images.generate), images.edit() does not get its path rewritten to /deployments/{model}/images/edits. The request is sent to https://{endpoint}/openai/images/edits, which returns 404 on Azure.
Root cause: AzureOpenAI.buildRequest resolves the deployment with
const model = this.deploymentName || options.body['model'] || options.__metadata?.['model'];
/images/edits is a multipart endpoint, so by the time buildRequest runs, options.body is already a FormData instance — options.body['model'] is undefined. The other multipart endpoints handle this by passing the model through request metadata (see audio/transcriptions.ts and audio/translations.ts, which both set __metadata: { model: body.model }), but the images.edit method does not, so the fallback is also undefined and the path rewrite is skipped.
Note images.generate is unaffected because its body stays a plain JSON object. images.edit is the only deployments-routed endpoint (_deployments_endpoints includes /images/edits) with this gap, which is probably why it went unnoticed — the Azure test suite covers model→deployment mapping for generate/transcriptions/translations but has no images.edit case.
To Reproduce
import { AzureOpenAI } from 'openai';
const client = new AzureOpenAI({
endpoint: 'https://my-resource.openai.azure.com',
apiKey: '...',
apiVersion: '2025-04-01-preview',
// no client-level `deployment`
});
await client.images.edit({
model: 'my-gpt-image-deployment', // per-request deployment
image: fs.createReadStream('input.png'),
prompt: 'add a hat',
});
// → POST https://my-resource.openai.azure.com/openai/images/edits?api-version=...
// → 404 (missing /deployments/my-gpt-image-deployment/)
Expected: POST https://my-resource.openai.azure.com/openai/deployments/my-gpt-image-deployment/images/edits?api-version=...
Workaround: instantiate the client with a client-level deployment — but that forces a separate client instance per deployment.
OS
macOS / Linux
Node version
Node v26.0.0
Library version
openai v6.42.0 (current master)
Confirm this is a Node library issue and not an underlying OpenAI API issue
Describe the bug
When using
AzureOpenAIwithout a client-leveldeploymentand passing the deployment via the per-requestmodelparam (the documented pattern, which works for chat completions, embeddings, audio transcriptions/translations andimages.generate),images.edit()does not get its path rewritten to/deployments/{model}/images/edits. The request is sent tohttps://{endpoint}/openai/images/edits, which returns 404 on Azure.Root cause:
AzureOpenAI.buildRequestresolves the deployment with/images/editsis a multipart endpoint, so by the timebuildRequestruns,options.bodyis already aFormDatainstance —options.body['model']isundefined. The other multipart endpoints handle this by passing the model through request metadata (seeaudio/transcriptions.tsandaudio/translations.ts, which both set__metadata: { model: body.model }), but theimages.editmethod does not, so the fallback is alsoundefinedand the path rewrite is skipped.Note
images.generateis unaffected because its body stays a plain JSON object.images.editis the only deployments-routed endpoint (_deployments_endpointsincludes/images/edits) with this gap, which is probably why it went unnoticed — the Azure test suite covers model→deployment mapping for generate/transcriptions/translations but has noimages.editcase.To Reproduce
Expected:
POST https://my-resource.openai.azure.com/openai/deployments/my-gpt-image-deployment/images/edits?api-version=...Workaround: instantiate the client with a client-level
deployment— but that forces a separate client instance per deployment.OS
macOS / Linux
Node version
Node v26.0.0
Library version
openai v6.42.0 (current master)