Skip to content

Fix Azure/OpenAI endpoints and reject Azure AI Inference URLs#5860

Merged
kevinvandijk merged 2 commits intoKilo-Org:mainfrom
Neonsy:fix/azure-gpt-codex-5-2
Feb 21, 2026
Merged

Fix Azure/OpenAI endpoints and reject Azure AI Inference URLs#5860
kevinvandijk merged 2 commits intoKilo-Org:mainfrom
Neonsy:fix/azure-gpt-codex-5-2

Conversation

@Neonsy
Copy link
Copy Markdown

@Neonsy Neonsy commented Feb 13, 2026

Context

The OpenAI Responses provider had endpoint-shape mismatches when users supplied Azure-style URLs, especially deployment/chat-completions paths. This caused fallback behavior to hit incorrect URLs and mixed auth/query behavior between OpenAI and Azure. We also needed to fail fast for unsupported Azure AI Inference endpoints (*.services.ai.azure.com) and tighten config validation for openai-responses.

Implementation

  • Added explicit endpoint classification for Azure OpenAI vs Azure AI Inference in the Responses provider.
  • Added a guard that rejects Azure AI Inference endpoints with a clear actionable error message.
  • Normalized fallback base URL construction so requests resolve cleanly to /responses without duplicating or mis-shaping /v1.
  • Updated fallback auth behavior:
    • Azure OpenAI fallback uses api-key header.
    • Non-Azure fallback uses Authorization: Bearer ....
  • Added Azure-specific api-version behavior only when needed for non-/openai/v1 paths.
  • Improved 404 guidance for Azure users, including warning against /deployments/.../chat/completions as a base URL.
  • Added openai-responses validation in webview settings (openAiBaseUrl, openAiApiKey, openAiModelId required).
  • Added targeted tests for URL normalization, Azure auth/query behavior, unsupported endpoint rejection, and validation behavior.

How to Test

  • Run provider tests:
    • cd src && pnpm test api/providers/__tests__/openai-responses.spec.ts
  • Run webview validation tests:
    • cd webview-ui && pnpm test src/utils/__tests__/validate.spec.ts
  • Manual sanity checks:
    • Configure openai-responses with Azure OpenAI base URL https://<resource>.openai.azure.com/openai/v1 and deployment model name; confirm requests target /openai/v1/responses.
    • Configure an Azure AI Inference URL (https://<resource>.services.ai.azure.com/...); confirm the provider fails immediately with the unsupported-endpoint error.
    • Use a deployment/chat-completions-style Azure URL and confirm fallback normalization still targets /openai/v1/responses correctly.

Note

The Discord user who has brought it up tested this change.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 13, 2026

🦋 Changeset detected

Latest commit: 0e10528

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
kilo-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Neonsy Neonsy force-pushed the fix/azure-gpt-codex-5-2 branch 4 times, most recently from f97b066 to edfda0a Compare February 13, 2026 16:52
@Neonsy Neonsy marked this pull request as ready for review February 14, 2026 10:58
@Neonsy Neonsy force-pushed the fix/azure-gpt-codex-5-2 branch from edfda0a to 8ec231b Compare February 14, 2026 10:59
@Anthonix24812
Copy link
Copy Markdown

Can confirm that this fix works with a Microsoft Foundry deployment of gpt-5.2-codex with Model version 2026-01-14

@Neonsy
Copy link
Copy Markdown
Author

Neonsy commented Feb 14, 2026

@kevinvandijk

…odex and reject Azure AI Inference URLs

Normalize Responses base URLs for Azure/OpenAI fallback paths.
Use Azure auth/query behavior (api-key + api-version) for fallback requests.
Add openai-responses config validation and targeted tests.
@Neonsy Neonsy force-pushed the fix/azure-gpt-codex-5-2 branch from e4a736e to baeb3f4 Compare February 18, 2026 11:59
Copy link
Copy Markdown
Contributor

@kevinvandijk kevinvandijk left a comment

Choose a reason for hiding this comment

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

Thanks! Looks good to me

@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented Feb 21, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Overview

This PR refactors Azure endpoint handling in the OpenAI Responses provider to:

  1. Reject Azure AI Inference endpoints (*.services.ai.azure.com) early with a clear error message, instead of attempting to use them with unsupported api-version query parameters.
  2. Normalize Azure OpenAI base URLs for the fallback fetch path, stripping deployment-specific paths and api-version params to produce clean /openai/v1/responses URLs.
  3. Use api-key header (instead of Authorization: Bearer) for Azure endpoints in the fallback path.
  4. Add openai-responses validation in the webview settings to require base URL, API key, and model ID.

The URL normalization logic in normalizeResponsesBaseUrl correctly handles all tested Azure URL patterns (deployment URLs, cognitiveservices, bare endpoints, /v1 paths). The shouldAppendAzureApiVersion method ensures /openai/v1 paths don't get unnecessary api-version query params.

Test coverage is thorough — new tests cover Azure AI Inference rejection, Azure OpenAI SDK path options, Azure fallback auth headers, deployment URL normalization, cognitiveservices endpoint normalization, and validation for the openai-responses provider.

Files Reviewed (5 files)
  • .changeset/azure-responses-v1-endpoints.md - Changeset
  • pnpm-lock.yaml - Lock file (skipped)
  • src/api/providers/openai-responses.ts - Core implementation changes
  • src/api/providers/__tests__/openai-responses.spec.ts - Test updates
  • webview-ui/src/utils/validate.ts - Validation for openai-responses provider
  • webview-ui/src/utils/__tests__/validate.spec.ts - Validation tests

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.

3 participants