Not clear how to use it with azure
Sorry I really what to try opencode but it is not clear from docs how to make it work with azure. how do i pass resource name, api version and api key? I assume i can do it through env vars that vercel ai sdk respect but i want to do it through config.
if you want to do it through config you can add an options field
provider: { azure: { options: { .... } } }
now i get this. i think it is related to striced openai schema, that does not allow optional params?
I got it working by doing the following:
-
Run the
opencode auth logincommand and paste in your Azure API key. -
Add the following configuration to
~/.config/opencode/config.json:
{
"$schema": "https://opencode.ai/config.json",
"model": "azure/gpt-4o",
"provider": {
"azure": {
"options": {
"resourceName": "your-azure-resource-name"
},
"models": {
"azure/gpt-4o": {
"name": "GPT-4o"
}
}
}
}
}
- Ensure Go is installed on your machine
do you need the config?
I mainly use it to specify the resourceName option - otherwise, I'd need to export the AZURE_RESOURCE_NAME environment variable, which I'd prefer not to do.
What I’m still unclear on is how to specify which deployment to use. I may have multiple deployments of the same model within a single resource, so I’m not sure how the tool determines which one to use by default, or how to override that if needed.
we have better docs for azure now: https://opencode.ai/docs/providers/#azure-openai
if you get schema issues you likely have an mcp server that your model of choice doesnt like the format of the tools < we may wanna sanitize params for you tho
this is good for me