MoonshotAI / MoonshotAI/kimi-code
feat: add azure-foundry provider for Microsoft Foundry model access
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 53m
- Merged PRs (30d)
- 350
Description
Summary
Add a first-class azure-foundry provider type so Kimi Code can connect to Microsoft Foundry deployments without hand-wiring the generic openai provider.
Foundry hosts many model families (OpenAI GPT, DeepSeek, Meta Llama, Mistral, Cohere, and others sold directly by Azure — not just OpenAI). A dedicated provider name reflects that breadth and gives us a single place to handle Foundry-specific auth, endpoints, and model routing — rather than overloading openai.
Motivation
Today there is no Azure / Foundry provider in kimi-code:
- Provider types are limited to
anthropic,openai,kimi,google-genai,openai_responses, andvertexai(seepackages/agent-core/src/config/schema.ts). - No Foundry entry in the models.dev catalog, so
/providercannot import it. - No documentation for Foundry setup.
Users are already working around this manually. #520 reports a real session using Azure AI Foundry with:
[providers.azure]
type = "openai"
base_url = "https://[resource].openai.azure.com/openai/v1"
api_key = "[API_KEY]"
That proves demand, but it is undocumented, untested, and fragile — especially around auth (api-key header vs Bearer) and thinking-model behavior after tool calls.
Proposed design
Provider type: azure-foundry
[providers.my-foundry]
type = "azure-foundry"
base_url = "https://YOUR-RESOURCE.openai.azure.com/openai/v1"
api_key = "YOUR_KEY"
[models.foundry-gpt4o]
provider = "my-foundry"
model = "gpt-4o"
max_context_size = 128000
Credential env keys (proposed): AZURE_FOUNDRY_API_KEY, AZURE_FOUNDRY_BASE_URL.
Why not reuse openai?
| Concern | openai reuse |
azure-foundry |
|---|---|---|
| Naming | Implies OpenAI-only | Matches Foundry’s multi-model catalog |
| Auth | SDK sends Authorization: Bearer; Foundry expects api-key (or Entra Bearer) per integration docs |
Foundry-specific auth in one adapter |
| Endpoints | User must know v1 vs legacy deployment URL shapes | Provider documents and validates Foundry endpoint patterns |
| Future models | Claude / Mistral / etc. on Foundry need different wires | Natural extension point to route by model family |
Implementation can still delegate to existing kosong wires (openai, anthropic, …) internally — the new type is the Foundry-facing config surface, not a full protocol rewrite.
Integration surface (per Microsoft docs)
Foundry exposes several endpoint families. For kimi-code’s agent loop, the initial target should be the OpenAI v1-compatible route:
POST https://{resource}.openai.azure.com/openai/v1/chat/completions
Auth headers (either):
api-key: {your-key}(API key — primary v1 path)Authorization: Bearer {entra-token}(Entra ID)
Microsoft recommends this route for third-party SDKs and deprecates the old Inference API (services.ai.azure.com/models, retiring May 2026). See Integrate Microsoft Foundry with your applications.
Proposed scope (v1)
- Add
azure-foundryto provider schema, TOML parsing, andprovider-manager - Kosong adapter: Foundry auth (
api-keyheader), correct base URL handling for v1 route - Reuse OpenAI chat-completions streaming/tools/reasoning path under the hood
- Document setup in
docs/en/configuration/providers.mdand Chinese mirror - Unit tests for auth header construction and provider config resolution
- Changeset (
minor— new provider type)
Out of scope (follow-up issues)
- Foundry Agent Service / project APIs (
services.ai.azure.com/api/projects/...) - Entra ID token refresh / managed identity
- Legacy deployment URLs (
/openai/deployments/{id}/chat/completions?api-version=...) - Non-OpenAI model families on Foundry (e.g. Claude, Mistral) — architecture should allow routing to the right wire later, but not required for v1
/providercatalog import (models.dev has no Azure/Foundry entry today)- Reasoning-only completion after tool calls on Foundry (#520) — related bug, separate fix
Open questions for maintainers
azure-foundryvsazure_foundryin TOML — repo mixesgoogle-genai(kebab) andopenai_responses(snake). Preference?- v1-only for first PR, with legacy deployment URL support as a follow-up?
- Should v1 also expose an
openai_responsessub-path for Foundry models that use the Responses API?
Acceptance criteria
- User can configure an
azure-foundryprovider pointing at a Foundry v1 endpoint and run a basic chat turn with tools. api-keyauthentication works without Bearer-header hacks.- Documented example config in both locales.
- No regression to existing
openaiprovider behavior.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with packages/agent-core/src/config/schema.ts and the provider-manager entry point, then trace the existing OpenAI provider path and its configuration tests. Review docs/en/configuration/providers.md and the Chinese mirror for the documented examples. Done means a v1 Foundry provider supports api-key authentication, chat with tools, tests cover auth and config resolution, both locales are documented, and existing OpenAI behavior is unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, typescript
- Domain
- backend-api-design, cloud, documentation, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100