Skip to content

fix(adapters): route azure-foundry through apiBase without /openai/deployments/{deployment} (#13114) - #13161

Open
santhiprakash wants to merge 3 commits into
continuedev:mainfrom
santhiprakash:fix/13114-azure-foundry-routing
Open

fix(adapters): route azure-foundry through apiBase without /openai/deployments/{deployment} (#13114)#13161
santhiprakash wants to merge 3 commits into
continuedev:mainfrom
santhiprakash:fix/13114-azure-foundry-routing

Conversation

@santhiprakash

Copy link
Copy Markdown

Description

AzureApi._getAzureBaseURL previously forced every provider: azure request through the legacy Azure OpenAI Service URL shape (/openai/deployments/{deployment}?api-version=...) regardless of env.apiType. That 404s on Azure AI Foundry (a.k.a. Microsoft Foundry) endpoints, which expose an OpenAI-compatible /openai/v1 path supplied by the user in apiBase.

The AzureConfigSchema in packages/openai-adapters/src/types.ts already declares apiType: "azure-foundry" as a valid value, but the AzureApi implementation never branched for it. This PR adds the branch:

  • When env.apiType === "azure-foundry", return the apiBase (with trailing slash trimmed, search params extracted into defaultQuery) without appending /openai/deployments/{deployment}.
  • Skip the env.deployment / env.apiVersion requirements for foundry (those are Azure OpenAI Service-only).
  • azure-openai / azure paths keep their existing behavior.

Reproduction (from the issue)

name: Main Config
version: 1.0.0
schema: v1
models:
  - name: gpt-5.3-codex
    provider: azure
    model: gpt-5.3-codex
    apiKey: YOUR_API_KEY
    apiBase: https://<your-resource>.services.ai.azure.com/openai/v1

Before: AzureApi rewrites apiBase to https://<your-resource>.services.ai.azure.com/openai/v1/openai/deployments/<deployment> and the Foundry endpoint returns 404.
After: apiBase is used as-is; the request reaches the Foundry OpenAI-compatible routing path.

Tests

Added 2 regression tests in packages/openai-adapters/src/test/main.test.ts:

  • should configure Azure AI Foundry client without appending /openai/deployments/{deployment} — verifies the baseURL is the user-supplied apiBase.
  • should not require env.deployment or env.apiVersion for Azure AI Foundry — verifies no deployment / apiVersion is required for apiType: "azure-foundry".

The fix was verified by extracting _getAzureBaseURL into a standalone Node script and running 6 cases (3 legacy azure-openai + 3 foundry) against hand-computed expected baseURLs (all pass). I could not run the vitest suite in this environment (no node_modules at the workspace root); the upstream vitest suite should be re-run by the maintainer.

Checklist

I have read the CLA Document and I hereby sign the CLA

🤖 Generated with Hermes Agent

…ate (continuedev#13104)

calculateOpenAICost() previously billed every prompt token at the standard
input rate, ignoring usage.promptTokensDetails.cached_tokens. For OpenAI
requests that hit the prompt cache (gpt-4o / gpt-4o-mini with stable system
prompts), this over-reported costs by the cache-read discount.

Add cachedInput to the pricing table for the families that document a
cache rate (gpt-4o, gpt-4o-mini), split prompt tokens into uncached and
cached portions, and bill each at its own rate. Models without a
documented cachedInput rate keep their existing behavior — cachedTokens
is ignored and the full prompt is billed at the standard input rate.

Includes regression tests covering: gpt-4o with partial cache, fully
cached input, zero cached tokens, gpt-4o-mini, gpt-4 (no rate defined),
and clamping cachedTokens when the API reports more cached than total
prompt tokens.

Verified by extracting calculateOpenAICost into a standalone Node script
and running 11 cases against hand-computed expected costs (all pass).
…nuedev#13104)

Fix the prettier-check failure on PR continuedev#13160 introduced by the previous
commit's hand-formatted long lines.
…ployments/{deployment} (continuedev#13114)

AzureApi._getAzureBaseURL previously forced every 'provider: azure' request
through the legacy Azure OpenAI Service URL shape
(/openai/deployments/{deployment}?api-version=...). That 404s on Azure AI
Foundry (a.k.a. Microsoft Foundry) endpoints, which expose an OpenAI-
compatible /openai/v1 path supplied by the user in apiBase.

Add an apiType === 'azure-foundry' branch that returns the apiBase as-is,
and skip the deployment/apiVersion guards for it. The existing
'azure-openai' / 'azure' branches keep their existing behavior, including
the deployment/apiVersion requirements.

Adds 2 regression tests in main.test.ts:
- foundry apiBase round-trips without path manipulation
- foundry construction does not throw without env.deployment / env.apiVersion

Verified by extracting _getAzureBaseURL into a standalone Node script and
running 6 cases (3 legacy azure-openai + 3 foundry) against hand-computed
expected baseURLs (all pass).
@santhiprakash
santhiprakash requested a review from a team as a code owner August 18, 2026 20:31
@santhiprakash
santhiprakash requested review from sestinj and removed request for a team August 18, 2026 20:31
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.

1 participant