opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Not clear how to use it with azure

Open da1z opened this issue 1 year ago • 7 comments

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.

da1z avatar Jun 24 '25 14:06 da1z

if you want to do it through config you can add an options field

provider: { azure: { options: { .... } } }

thdxr avatar Jun 24 '25 15:06 thdxr

Image

now i get this. i think it is related to striced openai schema, that does not allow optional params?

da1z avatar Jun 24 '25 22:06 da1z

I got it working by doing the following:

  1. Run the opencode auth login command and paste in your Azure API key.

  2. 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"
        }
      }
    }
  }
}
  1. Ensure Go is installed on your machine

andrii-k6a avatar Jul 02 '25 17:07 andrii-k6a

do you need the config?

thdxr avatar Jul 03 '25 04:07 thdxr

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.

andrii-k6a avatar Jul 04 '25 10:07 andrii-k6a

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

rekram1-node avatar Aug 29 '25 02:08 rekram1-node

this is good for me

sunqb avatar Jun 04 '26 01:06 sunqb