Skip to content

GH-3873 Add an api-version option for Azure OpenAI #3874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sunyuhan1998
Copy link
Contributor

@sunyuhan1998 sunyuhan1998 commented Jul 22, 2025

As mentioned in the issue, almost all interfaces of azure-openai support the api-version option. This is not a parameter within the request body, but rather passed as a query parameter in the URL (refer to the official documentation: https://learn.microsoft.com/en-us/azure/ai-foundry/openai/reference-preview-latest#create-chat-completion). Currently, Spring AI does not support this option. This PR adds that support.

What this PR does:

  1. Adds an apiVersion configuration option to AzureOpenAiChatOptions, AzureOpenAiAudioTranscriptionOptions, and AzureOpenAiEmbeddingOptions. The parameter is then passed through to the corresponding models and ultimately provided to the Azure SDK. The transmission is achieved via the SDK's RequestOptions, which supports appending query parameters to the request URL.

  2. I initially intended to add this option to AzureOpenAiImageOptions as well. However, the Azure SDK does not expose any method accepting RequestOptions as public for image-related operations(com.azure.ai.openai.OpenAIClient#getImageGenerationsWithResponse(java.lang.String, com.azure.core.util.BinaryData, com.azure.core.http.rest.RequestOptions)). I believe this is a bug, as it is inconsistent with the behavior of other interfaces. I will submit a PR to the Azure SDK to address this. Once that PR is accepted, I will follow up with another PR to Spring AI to add the apiVersion option to AzureOpenAiImageOptions.

Fixes: #3873

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.

API version not supported
1 participant