[FEATURE]: Add support for Anthropic models in Azure AI Foundry
Feature hasn't been suggested before.
- [x] I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Anthropic models are now available in Azure AI Foundry. Reference: https://code.claude.com/docs/en/azure-ai-foundry
Yep we should do that, basically just means updating: https://github.com/sst/models.dev
Looking into this now - added support in sst/models.dev#405 but unable to use the claude models yet. Wondering if we should wait for ai-sdk/azure support for @anthropic-ai/foundry-sdk or just add a switch for the time being.
u can override the npm package per model if u need to:
[provider] npm = “…”
u can override the npm package per model if u need to:
[provider] npm = “…”
Thanks - fixed in sst/models.dev#409
is this available with latest opencode version 1.0.80
@krishna1s should be you just need to restart opencode a couple of times to refresh ur cache
@rekram1-node I can see now azure/claude-sonnet-4-5, is there any way to clean the cache. Also would opencode auth login with azure, going to support foundry key or we need to set env as suggested here
is there any way to clean the cache
rm ~/.cache/opencode/models.json
Uh idk I didn't set it up but i can take a look when I get a chance
I tried configuring anthropic env variable but it doesn't seems to be working
@krishna1s this works, just set the envs to your foundry creds (base url: https://{resource-name}.services.ai.azure.com/anthropic/v1)
{
"provider": {
"azure": {
"models": {
"claude-haiku-4-5": {
"id": "claude-haiku-4-5",
"provider": {
"npm": "@ai-sdk/anthropic",
"options": {
"apiKey": "{env:ANTHROPIC_FOUNDRY_API_KEY}",
"baseURL": "{env:ANTHROPIC_FOUNDRY_BASE_URL}"
}
}
}
}
}
}
}
This is very important :)
@krishna1s this works, just set the envs to your foundry creds (base url: https://{resource-name}.services.ai.azure.com/anthropic/v1)
{ "provider": { "azure": { "models": { "claude-haiku-4-5": { "id": "claude-haiku-4-5", "provider": { "npm": "@ai-sdk/anthropic", "options": { "apiKey": "{env:ANTHROPIC_FOUNDRY_API_KEY}", "baseURL": "{env:ANTHROPIC_FOUNDRY_BASE_URL}" } } } } } } }
Didnt work for me.
`
INFO 2025-11-21T14:49:36 +0ms service=session.prompt sessionID=ses_5591ba16affeJMoRrZpI0kg4cr cancel
INFO 2025-11-21T14:49:36 +1ms service=bus type=session.status publishing
INFO 2025-11-21T14:49:36 +0ms service=bus type=session.idle publishing
68 | autoload: false,
69 | async getModel(sdk: any, modelID: string, options?: Record<string, any>) {
70 | if (options?.["useCompletionUrls"]) {
71 | return sdk.chat(modelID)
72 | } else {
73 | return sdk.responses(modelID)
^
TypeError: sdk.responses is not a function. (In 'sdk.responses(modelID)', 'sdk.responses' is undefined)
at
INFO 2025-11-21T14:49:36 +0ms service=provider status=completed duration=43 providerID=azure getSDK ERROR 2025-11-21T14:49:36 +1ms service=acp-command promise={} reason=sdk.responses is not a function. (In 'sdk.responses(modelID)', 'sdk.responses' is undefined) Unhandled rejection ERROR 2025-11-21T14:49:36 +0ms service=default e=sdk.responses is not a function. (In 'sdk.responses(modelID)', 'sdk.responses' is undefined) rejection INFO 2025-11-21T14:49:36 +3ms service=default directory=/home/edisonpaul4 disposing instance INFO 2025-11-21T14:49:36 +0ms service=state key=/home/edisonpaul4 waiting for state disposal to complete INFO 2025-11-21T14:49:36 +1ms service=state key=/home/edisonpaul4 state disposal completed `
@edisonpaul4 try using the anthropic provider with the same env. Had the same issue on my system but it works fine in a fresh environment https://github.com/cau1k/anthropic-foundry-opencode
@edisonpaul4 try using the anthropic provider with the same env. Had the same issue on my system but it works fine in a fresh environment https://github.com/cau1k/anthropic-foundry-opencode
Not working
INFO 2025-11-24T12:38:57 +0ms service=provider providerID=azure-custom pkg=@ai-sdk/anthropic using preinstalled provider INFO 2025-11-24T12:38:57 +43ms service=provider status=completed duration=43 providerID=azure-custom getSDK INFO 2025-11-24T12:38:57 +0ms service=provider status=completed duration=43 providerID=azure-custom getSDK INFO 2025-11-24T12:38:57 +0ms service=provider providerID=azure-custom modelID=claude-haiku-4-5 found INFO 2025-11-24T12:38:57 +0ms service=provider providerID=azure-custom modelID=claude-haiku-4-5 found INFO 2025-11-24T12:38:57 +7ms service=bus type=message.updated publishing ERROR 2025-11-24T12:38:57 +3ms service=session.prompt error=Anthropic API key is missing. Pass it using the 'apiKey' parameter or the ANTHROPIC_API_KEY environment variable. model=claude-haiku-4-5 failed to generate title INFO 2025-11-24T12:38:57 +6ms service=bash-tool shell=/bin/bash bash tool using shell INFO 2025-11-24T12:38:57 +5ms service=session.processor process INFO 2025-11-24T12:38:57 +3ms service=bus type=session.status publishing ERROR 2025-11-24T12:38:57 +1ms service=session.prompt error={"error":{"name":"AI_LoadAPIKeyError"}} stream error ERROR 2025-11-24T12:38:57 +2ms service=session.processor error=Anthropic API key is missing. Pass it using the 'apiKey' parameter or the ANTHROPIC_API_KEY environment variable. process INFO 2025-11-24T12:38:57 +0ms service=bus type=session.error publishing INFO 2025-11-24T12:38:57 +1ms service=bus type=message.updated publishing INFO 2025-11-24T12:38:57 +0ms service=session.compaction pruning Error: Anthropic API key is missing. Pass it using the 'apiKey' parameter or the ANTHROPIC_API_KEY environment variable. INFO 2025-11-24T12:38:57 +4ms service=session.prompt sessionID=ses_54a20280cffeTuZLqvjlf6Crcw cancel INFO 2025-11-24T12:38:57 +0ms service=bus type=session.status publishing INFO 2025-11-24T12:38:57 +0ms service=bus type=session.idle publishing INFO 2025-11-24T12:38:57 +2ms service=bus type=message.updated publishing ERROR 2025-11-24T12:38:57 +1ms service=acp-command promise={} reason=Anthropic API key is missing. Pass it using the 'apiKey' parameter or the ANTHROPIC_API_KEY environment variable. Unhandled rejection ERROR 2025-11-24T12:38:57 +0ms service=default e=Anthropic API key is missing. Pass it using the 'apiKey' parameter or the ANTHROPIC_API_KEY environment variable. rejection INFO 2025-11-24T12:38:57 +0ms service=bus type=session.updated publishing INFO 2025-11-24T12:38:57 +0ms service=bus type=session.diff publishing INFO 2025-11-24T12:38:57 +0ms service=session.compaction pruned=0 total=0 found
and this is my opencode.json (took your and just kept what i needed)
{ "$schema": "https://opencode.ai/config.json", "provider": { "azure-custom": { "models": { "claude-haiku-4-5": { "id": "claude-haiku-4-5", "provider": { "npm": "@ai-sdk/anthropic", "options": { "apiKey": "{env:ANTHROPIC_FOUNDRY_API_KEY}", "baseURL": "{env:ANTHROPIC_FOUNDRY_BASE_URL}" } }, "options": { "thinking": { "type": "enabled", "budgetTokens": 16000, } }, }, "claude-sonnet-4-5": { "id": "claude-sonnet-4-5", "provider": { "npm": "@ai-sdk/anthropic", "options": { "apiKey": "{env:ANTHROPIC_FOUNDRY_API_KEY}", "baseURL": "{env:ANTHROPIC_FOUNDRY_BASE_URL}" } }, "options": { "thinking": { "type": "enabled", "budgetTokens": 16000, } }, }, } }, } }
Hello, this configuration works according to my tests
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"azure-anthropic": {
"name": "Azure AI Foundry (Anthropic)",
"npm": "@ai-sdk/anthropic",
"api": "{env:ANTHROPIC_FOUNDRY_BASE_URL}",
"env": ["ANTHROPIC_FOUNDRY_API_KEY"],
"models": {
"claude-sonnet-4-5": {
"id": "claude-sonnet-4-5",
"name": "Claude Sonnet 4.5",
"tool_call": true,
"attachment": true,
"reasoning": true,
"temperature": true,
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 16000
}
}
},
"claude-haiku-4-5": {
"id": "claude-haiku-4-5",
"name": "Claude Haiku 4.5",
"tool_call": true,
"attachment": true,
"reasoning": true,
"temperature": true,
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 16000
}
}
}
}
}
}
}
Hello, this configuration works according to my tests [...]
I can confirm. Worked for me.
Does it work irrespective of foundry deployment name ?
Yes, it works regardless of the Foundry deployment name.
The resource URL is configured through an environment variable like ANTHROPIC_FOUNDRY_BASE_URL, where you set the full URL of your resource:
https://[RESOURCE_NAME].services.ai.azure.com/anthropic/v1
So the deployment name itself doesn't matter what matters is that the base URL points to your specific Azure AI Foundry resource.
do we need to update models.dev was it incorrect?
The resource name can also be provided in opencode.json. The API-Key can be set in auth.json as well. That's my current setup. Thanks to the comment before.
"provider": {
"azure-anthropic": {
"name": "Azure AI Foundry (Anthropic)",
"npm": "@ai-sdk/anthropic",
"api": "https://<RSN>.ai.azure.com/anthropic/v1",
"models": {
"claude-opus-4-5": {
"id": "claude-opus-4-5",
"name": "Claude Opus 4.5",
"tool_call": true,
"attachment": true,
"reasoning": true,
"temperature": true
},
"claude-sonnet-4-5": {
"id": "claude-sonnet-4-5",
"name": "Claude Sonnet 4.5",
"tool_call": true,
"attachment": true,
"reasoning": true,
"temperature": true
}
}
auth.json:
{
"azure-anthropic": {
"type": "api",
"key": "xyz"
}
}
The resource name can also be provided in
opencode.json. The API-Key can be set inauth.jsonas well. That's my current setup. Thanks to the comment before."provider": { "azure-anthropic": { "name": "Azure AI Foundry (Anthropic)", "npm": "@ai-sdk/anthropic", "api": "https://<RSN>.ai.azure.com/anthropic/v1", "models": { "claude-opus-4-5": { "id": "claude-opus-4-5", "name": "Claude Opus 4.5", "tool_call": true, "attachment": true, "reasoning": true, "temperature": true }, "claude-sonnet-4-5": { "id": "claude-sonnet-4-5", "name": "Claude Sonnet 4.5", "tool_call": true, "attachment": true, "reasoning": true, "temperature": true } }
auth.json:{ "azure-anthropic": { "type": "api", "key": "xyz" } }
This works great in the Terminal but not on the Web UI for some reason. Has anybody found a workaround for that?
I'm having the issue with OpenCode 1.1.16 , is that opencode need to dump version of dependency, or this need to be configured manually?