Skip to content

fix: make azure api-version query param optional#9221

Open
DOsinga wants to merge 1 commit into
mainfrom
fix/8236-azure-api-version-optional
Open

fix: make azure api-version query param optional#9221
DOsinga wants to merge 1 commit into
mainfrom
fix/8236-azure-api-version-optional

Conversation

@DOsinga
Copy link
Copy Markdown
Collaborator

@DOsinga DOsinga commented May 14, 2026

Newer Azure OpenAI deployments using /v1 paths reject the api-version query parameter with a 400 error:

Bad request (400): api-version query parameter is not allowed when using /v1 path

This PR makes the api-version query parameter conditional — it is only included when AZURE_OPENAI_API_VERSION is explicitly set by the user.

Changes:

  • Remove AZURE_DEFAULT_API_VERSION constant and the hardcoded fallback
  • Only append api-version query param when AZURE_OPENAI_API_VERSION is configured
  • Update the ConfigKey to not be required and to have no default hint, so the desktop UI doesn't pre-fill a value that would re-introduce the problem

Backward compatibility:

  • Old-style Azure deployments: set AZURE_OPENAI_API_VERSION=2024-10-21 → works as before
  • New-style /v1 deployments: leave it unset → no query param, no 400 error

Based on the approach from #8256 by @octo-patch, with the additional fix of removing the default hint from the provider metadata so the UI doesn't suggest a default.

Fixes #8236
May also fix #8876

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8d1c246aa0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +87 to +89
if let Some(version) = api_version {
api_client = api_client.with_query(vec![("api-version".to_string(), version)]);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve api-version for legacy Azure deployment paths

from_env now omits the api-version query parameter when AZURE_OPENAI_API_VERSION is unset, but this provider still targets the legacy .../openai/deployments/{deployment}/... route shape (not /openai/v1/...). For classic Azure OpenAI endpoints, requests on that route require an API version, so a newly configured Azure provider (where this key is now optional) can fail at runtime with 4xx errors even though setup succeeds. Please keep a fallback for non-v1 endpoints (or infer based on endpoint path) so legacy deployments remain functional without manual env overrides.

Useful? React with 👍 / 👎.

Newer Azure OpenAI deployments using /v1 paths reject the api-version
query parameter with a 400 error. Now we infer from the endpoint URL:

- /v1 endpoints: omit api-version (unless explicitly set)
- Legacy endpoints: default to 2024-10-21 (preserving existing behavior)

Users can always override via AZURE_OPENAI_API_VERSION.

Also removes the default hint from the ConfigKey so the desktop UI
doesn't pre-fill a value for new-style endpoint users.

Based on the approach from #8256 by @octo-patch.

Fixes #8236

Signed-off-by: Douwe Osinga <douwe@squareup.com>
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.

New version of Azure OpenAI API does not allow api-version query parameter Configuring Azure OpenAI just results in a 400 bad request

2 participants