Skip to content

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 have submitted a PR to Azure to attempt to fix it:
    GH-46101 Changed the visibility of the interface getImageGenerationsWithResponse to public Azure/azure-sdk-for-java#46102
    Once that PR is accepted, I will follow up with another PR to Spring AI to add the apiVersion option to AzureOpenAiImageOptions.

Fixes: #3873

Signed-off-by: Sun Yuhan <sunyuhan1998@users.noreply.github.com>
…& Embedding Signed-off-by: Sun Yuhan <sunyuhan1998@users.noreply.github.com>
Signed-off-by: Sun Yuhan <sunyuhan1998@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2 participants