fix(azure-openai): use deployment name in AzureOpenAIResponses structured predict#21530
Open
joshuakilts wants to merge 3 commits intorun-llama:mainfrom
Open
Conversation
… predict OpenAIResponses.structured_predict and astructured_predict call responses.parse(model=self.model), where self.model is the model family name (e.g. "gpt-4o"). Azure routes API requests by deployment name, so this causes a 404 DeploymentNotFound error that is silently swallowed by the instrumentation dispatcher, returning an empty structured response. Override both methods on AzureOpenAIResponses to pass model=self.engine (the deployment name) instead. This mirrors the existing pattern in _get_model_kwargs, which already applies the same correction for other API paths. Adds two unit tests asserting the deployment name is used.
…sponses_model property Instead of duplicating structured_predict and astructured_predict in AzureOpenAIResponses, add a _responses_model hook to OpenAIResponses (returns self.model) and override it in AzureOpenAIResponses (returns self.engine). The parent methods call self._responses_model, so Azure gets the right deployment name without copying any logic. Removes stale imports added for the duplicate overrides. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
AzureOpenAIResponses.structured_predict(and the async variant) were inherited fromOpenAIResponses, which passesmodel=self.model(e.g."gpt-4o") toresponses.parse. Azure routes requests by deployment name, not model family name, so this produces a 404DeploymentNotFounderror.Changes
openai/responses.py_responses_modelproperty (returnsself.model) as a hook point for subclassesazure_openai/responses.py_responses_modelto returnself.engine(the Azure deployment name)structured_predict/astructured_predictpick up the correct value through the propertyThis follows the same pattern already used by
_get_model_kwargsinAzureOpenAIResponses.Test plan
pytest llama-index-integrations/llms/llama-index-llms-azure-openai/tests/test_azure_openai.py::test_structured_predict_uses_engine_not_modelpytest llama-index-integrations/llms/llama-index-llms-azure-openai/tests/test_azure_openai.py::test_astructured_predict_uses_engine_not_model🤖 Generated with Claude Code