Skip to content

feat(ai): support Azure Foundry Chat Completions deployments - #9714

Open
jsanter27 wants to merge 1 commit into
earendil-works:mainfrom
jsanter27:feat/azure-chat-completions
Open

jsanter27 wants to merge 1 commit into
earendil-works:mainfrom
jsanter27:feat/azure-chat-completions

Conversation

@jsanter27

@jsanter27 jsanter27 commented Sep 17, 2026

Copy link
Copy Markdown

Summary

Implements #9645. azure-openai-responses only implemented the Responses API, so Foundry deployments that use Chat Completions (DeepSeek V4 Pro) couldn't work. Picks up @davidbrai's suggestion in #6228 to expand the Azure provider to other APIs.

Only deepseek-v4-pro is in the built-in catalog, but the endpoint resolution is model-agnostic, so other Foundry deployments now route correctly when declared in models.json under this provider with api: "openai-completions": Llama 3.3 70B, Mistral Large 3, Grok 4.6, Kimi K3, Phi-4, etc. (full list)

Decisions

  • Kept one Azure provider dispatching both APIs by model.api, as fireworks and cloudflare-ai-gateway already do, rather than a second provider: one Foundry resource, one key, one base URL.
  • Observed deployment quirks are handled in the model catalog generation, not in api code.
  • azureStreams resolves the Azure endpoint onto the model before dispatch, since openai-completions reads it off model.baseUrl and Azure models ship with an empty baseUrl.

Impact

Azure users gain Chat Completions deployments. Nothing changes for the existing Responses path: same provider id, same auth, same env vars.

Verification

  • 13 tests added to packages/ai/test/azure-openai-completions.test.ts.
  • 28 live checks against a DeepSeek V4 Pro deployment on Foundry: all seven thinking levels, every cacheRetention value plus PI_CACHE_RETENTION=long, multi-turn reasoning replay, tool calling, etc.

Follow Up

The azure-openai-responses provider name is now not entirely accurate. A next piece of work could be to support provider aliases, so this can become a general azure provider without breaking existing configs.

The Azure provider only implemented the Responses API, so Foundry
deployments that speak Chat Completions could not be used. On Chat
Completions the deepseek/deepseek-v4-pro model sends `thinking` and
`prompt_cache_key`, both of which Azure rejects with 400.

The provider now dispatches openai-completions alongside
azure-openai-responses. A stream wrapper resolves the Azure endpoint and
deployment name onto the model first, since the shared openai-completions
implementation reads both off the model.

The request-shape differences are catalog compat rather than api code:
reasoning_effort instead of DeepSeek's thinking field, no prompt cache
parameters, reasoning_content kept on assistant turns so the prefix
Foundry cached stays byte-identical, and effort clamped to the
low/medium/high the deployment accepts.

closes earendil-works#9645
@davidbrai

Copy link
Copy Markdown
Contributor

@jsanter27 I want to change the provider name to azure as part of this change.

things it will break:

  1. stored auth in auth.json will need to be fixed or do a relogin
  2. models.json any custom / overrides will need to be fixed
  3. existing sessions: pi will think it's a different model so cache will be busted and reasoning converted to text
  4. old clients will start getting 404 responses to pi.dev model catalog updates, but that just means their catalog will be frozen

I think these are the main things, and they are acceptable. adding provider aliases is lot of complexity for a narrow usecase.

wdyt? makes sense to you?

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.

2 participants