Skip to content

Azure: images.edit ignores per-request model, requests go to wrong URL (404) #1917

Description

@serhiizghama

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

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    upstreamNeeds to be addressed in Stainless upstream

    Type

    No type

    Fields

    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