Skip to content

Fix Azure embedding Base URL handling and validation#2385

Open
tgmof wants to merge 1 commit into
logancyang:masterfrom
tgmof:fix-azure-embedding-model-proxy
Open

Fix Azure embedding Base URL handling and validation#2385
tgmof wants to merge 1 commit into
logancyang:masterfrom
tgmof:fix-azure-embedding-model-proxy

Conversation

@tgmof

@tgmof tgmof commented May 6, 2026

Copy link
Copy Markdown

Problem

  • When adding an Azure embedding model via “Embedding models → + Add Model”:
    • Setting a Base URL was ignored; code still built URLs using:
      • azureOpenAIApiInstanceName
      • azureOpenAIApiEmbeddingDeploymentName
      • azureOpenAIApiVersion
    • Runtime ended up calling:
      • POST https://[instance].openai.azure.com/openai/deployments/[deployment]/embeddings?api-version=[version]
        even when a custom Base URL was supplied.

Goals

  1. Make Azure embedding models honor the Base URL field, same as chat models.
  2. Allow users to configure Azure embeddings either via:
    • Full Base URL, or
    • Legacy instance / deployment / api-version fields, when Base URL is blank.
  3. Ensure “Test” works without requiring legacy fields when Base URL is provided.

Behavior After Changes

  1. Azure Embeddings with Base URL
    • User:
      • Selects provider: Azure.
      • Fills Base URL (full endpoint or base).
      • Sets API key.
    • UI:
      • Hides instance / deployment / version fields.
      • “Test” button no longer complains about azureOpenAIApiInstanceName.
    • Runtime:
      • Uses OpenAIEmbeddings with configuration.baseURL set to Azure endpoint.
      • Adds api-version via defaultQuery.
      • No dependency on Azure-specific constructor fields.
  2. Azure Embeddings with Legacy Fields
    • User:
      • Leaves Base URL empty.
      • Fills Instance Name, Embedding Deployment Name, API Version.
    • UI:
      • Requires these fields and shows inline errors if missing.
    • Runtime:
      • Builds https://[instance].openai.azure.com/openai/deployments/[deployment].
      • Uses OpenAIEmbeddings with the constructed URL + api-version.

@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

configuration: {
baseURL: azureUrl.baseUrl || customModel.baseUrl!.trim(),
defaultQuery: {
"api-version": azureUrl.apiVersion || apiVersion,
},
fetch: customModel.enableCors ? safeFetch : undefined,

P1 Badge Add Azure api-key header for embedding requests

This Azure branch now uses OpenAIEmbeddings, but the config never sets configuration.defaultHeaders with an api-key. In this codebase, Azure chat and curl generation both explicitly use api-key auth; without that header, embedding requests to Azure (or APIM proxies that require api-key) can fail with 401 even when the key is correct, because only the generic OpenAI auth path is configured here.


defaultQuery: {
"api-version": azureUrl.apiVersion || apiVersion,
},

P1 Badge Provide fallback Azure API version in Base URL flow

The new Base URL path allows skipping legacy Azure fields, but defaultQuery["api-version"] is set to azureUrl.apiVersion || apiVersion with no hard fallback. Since the default azureOpenAIApiVersion setting is empty, a user who pastes a deployment base URL (without query params) can send requests without a valid api-version, causing Azure embedding calls to fail in the exact path this change enables.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@logancyang

Copy link
Copy Markdown
Owner

Thanks for the fix! The Codex review flagged two real issues worth addressing before merge: the Azure path needs the api-key header set in configuration.defaultHeaders (matches what chat does), and we need a fallback api-version when the Base URL has no query params. Once those are in we can take another look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants