GH-3873 Add an api-version option for Azure OpenAI #3874 
   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.    
 
As mentioned in the issue, almost all interfaces of
azure-openaisupport theapi-versionoption. 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:
Adds an
apiVersionconfiguration option toAzureOpenAiChatOptions,AzureOpenAiAudioTranscriptionOptions, andAzureOpenAiEmbeddingOptions. The parameter is then passed through to the corresponding models and ultimately provided to the Azure SDK. The transmission is achieved via the SDK'sRequestOptions, which supports appending query parameters to the request URL.I initially intended to add this option to
AzureOpenAiImageOptionsas well. However, the Azure SDK does not expose any method acceptingRequestOptionsas 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
getImageGenerationsWithResponseto public Azure/azure-sdk-for-java#46102Once that PR is accepted, I will follow up with another PR to Spring AI to add the
apiVersionoption toAzureOpenAiImageOptions.Fixes: #3873