fix(azure): preserve model-to-deployment mapping for images.edit#1918
Open
serhiizghama wants to merge 2 commits into
Open
fix(azure): preserve model-to-deployment mapping for images.edit#1918serhiizghama wants to merge 2 commits into
serhiizghama wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #1917
On Azure,
images.edit()ignores the per-requestmodelparam for deployment routing. With no client-leveldeployment, the request goes to/openai/images/editsinstead of/openai/deployments/{model}/images/editsand Azure returns 404. Every other deployments-routed endpoint (chat completions, embeddings,images.generate, audio transcriptions/translations) handles this correctly.Root cause:
AzureOpenAI.buildRequestresolves the deployment via/images/editsis multipart, sooptions.bodyis already aFormDatawhenbuildRequestruns andoptions.body['model']isundefined. The multipart audio endpoints solve exactly this by passing__metadata: { model: body.model }—images.editis the only entry in_deployments_endpointswith a multipart body that doesn't.Solution
Pass
__metadata: { model: body.model }inimages.edit, mirroring the existing pattern inaudio/transcriptions.tsandaudio/translations.ts. No behavior change for non-Azure clients (__metadatais only read byAzureOpenAI.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 editto the existing "with no client-level deployment" suite intests/lib/azure.test.ts(the suite coveredimages.generatebut notimages.edit, which is how this slipped through). The test fails on master with:and passes with the fix. Full offline suite (
jest --testPathIgnorePatterns tests/api-resources): 567/567 passing; lint, prettier and./scripts/buildclean.