Skip to content

fix(azure): preserve model-to-deployment mapping for images.edit#1918

Open
serhiizghama wants to merge 2 commits into
openai:mainfrom
serhiizghama:fix/azure-images-edit-deployment-routing
Open

fix(azure): preserve model-to-deployment mapping for images.edit#1918
serhiizghama wants to merge 2 commits into
openai:mainfrom
serhiizghama:fix/azure-images-edit-deployment-routing

Conversation

@serhiizghama

Copy link
Copy Markdown

Problem

Fixes #1917

On Azure, images.edit() ignores the per-request model param for deployment routing. With no client-level deployment, the request goes to /openai/images/edits instead of /openai/deployments/{model}/images/edits and Azure returns 404. Every other deployments-routed endpoint (chat completions, embeddings, images.generate, audio transcriptions/translations) handles this correctly.

Root cause: AzureOpenAI.buildRequest resolves the deployment via

const model = this.deploymentName || options.body['model'] || options.__metadata?.['model'];

/images/edits is multipart, so options.body is already a FormData when buildRequest runs and options.body['model'] is undefined. The multipart audio endpoints solve exactly this by passing __metadata: { model: body.model }images.edit is the only entry in _deployments_endpoints with a multipart body that doesn't.

Solution

Pass __metadata: { model: body.model } in images.edit, mirroring the existing pattern in audio/transcriptions.ts and audio/translations.ts. No behavior change for non-Azure clients (__metadata is only read by AzureOpenAI.buildRequest).

Since this file is generated, the underlying fix may need to land in the Stainless config — the change here reproduces exactly what the generator already emits for the audio multipart endpoints, so it should be a straightforward config mirror.

Testing

Added handles image edit to the existing "with no client-level deployment" suite in tests/lib/azure.test.ts (the suite covered images.generate but not images.edit, which is how this slipped through). The test fails on master with:

- "url": "https://example.com/openai/deployments/deployment/images/edits?api-version=..."
+ "url": "https://example.com/openai/images/edits?api-version=..."

and passes with the fix. Full offline suite (jest --testPathIgnorePatterns tests/api-resources): 567/567 passing; lint, prettier and ./scripts/build clean.

@serhiizghama serhiizghama requested a review from a team as a code owner June 4, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant