Setting up opencode with azure ai foundry (openai) project issue #2736

Closed
opened 2026-02-16 17:37:01 -05:00 by yindo · 12 comments
Owner

Originally created by @BenjaminOmar on GitHub (Nov 9, 2025).

Question

i am trying to set up opencode to use a deployment from my azure ai foundry (openai) project. i have therefore set up this opencode.jsonc file:

{
  "$schema": "https://opencode.ai/config.json",
  "model": "azure/GPT-4.1",
  "theme": "opencode",
  "autoupdate": true,
  "provider": {
    "azure": {
      "options": {
        "apiKey": "api-key",
        "baseURL": "url-to-ai-foundry-project",
        "resourceName": "opencode-test"
      },
      "models": {
        "azure/GPT-4.1": {
          "name": "GPT-4.1"
        }
      }
    }
  }
}

I have then used the powershell command [System.Environment]::SetEnvironmentVariable('AZURE_RESOURCE_NAME', 'opencode-test', 'User') to set the resuce name.

Lastly i used the opencode auth login and pasted the same api key that is set within the opencode.jsonc.

When i then try to use opencode, i then get:

Image

anyone know what i might be doing wrong? is there a way to run it in "verbose mode", so it is easier to debug?

This is the model info:

Image
Originally created by @BenjaminOmar on GitHub (Nov 9, 2025). ### Question i am trying to set up opencode to use a deployment from my azure ai foundry (openai) project. i have therefore set up this `opencode.jsonc` file: ``` { "$schema": "https://opencode.ai/config.json", "model": "azure/GPT-4.1", "theme": "opencode", "autoupdate": true, "provider": { "azure": { "options": { "apiKey": "api-key", "baseURL": "url-to-ai-foundry-project", "resourceName": "opencode-test" }, "models": { "azure/GPT-4.1": { "name": "GPT-4.1" } } } } } ``` I have then used the powershell command `[System.Environment]::SetEnvironmentVariable('AZURE_RESOURCE_NAME', 'opencode-test', 'User')` to set the resuce name. Lastly i used the `opencode auth login` and pasted the same api key that is set within the `opencode.jsonc`. When i then try to use opencode, i then get: <img width="1329" height="559" alt="Image" src="https://github.com/user-attachments/assets/299b450e-313c-49c2-ad7a-686f1e2c3a27" /> anyone know what i might be doing wrong? is there a way to run it in "verbose mode", so it is easier to debug? This is the model info: <img width="357" height="155" alt="Image" src="https://github.com/user-attachments/assets/cb4329a9-8a1b-4206-914b-45ec471c0d6d" />
yindo closed this issue 2026-02-16 17:37:01 -05:00
Author
Owner

@rekram1-node commented on GitHub (Nov 9, 2025):

@BenjaminOmar the model key shouldn't need a provider prefix: "azure/"

Also note: "The deployment name must match the model name for opencode to work properly."

I see you made a deployment called GPT-4.1 but that doesn't match the model name gpt-4.1

@rekram1-node commented on GitHub (Nov 9, 2025): @BenjaminOmar the model key shouldn't need a provider prefix: "azure/" Also note: "The deployment name must match the model name for opencode to work properly." I see you made a deployment called `GPT-4.1` but that doesn't match the model name `gpt-4.1`
Author
Owner

@rekram1-node commented on GitHub (Nov 9, 2025):

u prolly saw this but we have docs for azure: https://opencode.ai/docs/providers/#azure-openai

@rekram1-node commented on GitHub (Nov 9, 2025): u prolly saw this but we have docs for azure: https://opencode.ai/docs/providers/#azure-openai
Author
Owner

@BenjaminOmar commented on GitHub (Nov 9, 2025):

figured it out @rekram1-node. it should be like this:

{
  "$schema": "https://opencode.ai/config.json",
  "model": "gpt-4.1-mini",
  "theme": "opencode",
  "autoupdate": true,
  "provider": {
    "azure": {
      "options": {
        "apiKey": "api-key",
        "baseURL": "base-url",
        "resourceName": "resource-name"
      },
      "models": {
        "gpt-4.1-mini": {
          "name": "gpt-4.1-mini"
        }
      }
    }
  }
}

thanks for the help!

@BenjaminOmar commented on GitHub (Nov 9, 2025): figured it out @rekram1-node. it should be like this: ``` { "$schema": "https://opencode.ai/config.json", "model": "gpt-4.1-mini", "theme": "opencode", "autoupdate": true, "provider": { "azure": { "options": { "apiKey": "api-key", "baseURL": "base-url", "resourceName": "resource-name" }, "models": { "gpt-4.1-mini": { "name": "gpt-4.1-mini" } } } } } ``` thanks for the help!
Author
Owner

@Delta-11 commented on GitHub (Nov 11, 2025):

@rekram1-node I have connected Opencode to Github App, and I have a workflow file. I am not able to configure the resources properly using Azure OpenAI.
name: opencode

on:
issue_comment:
types: [created]

jobs:
opencode:
# Run only if the comment body contains /oc or /opencode
if: |
contains(github.event.comment.body, '/oc') ||
contains(github.event.comment.body, '/opencode')
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

  - name: Run opencode
    uses: sst/opencode/github@latest
    env:
      AZURE_API_KEY: ${{ secrets.AZURE_API_KEY }}
      AZURE_RESOURCE_NAME: ${{ secrets.AZURE_RESOURCE_NAME }}
    with:
      model: azure/gpt-4.1-mini

I am getting following error.
modelID: "gpt-4.1-mini",
providerID: "azure",
time: {
created: 1762877974726,
completed: 1762877974757,
},
sessionID: "ses_58c48dd8effesRo8Q0Ps8f0sIO",
error: {
name: "UnknownError",
data: {
message: "Error: Unable to connect. Is the computer able to access the url?",
},
},
}

I have kept the model name and deployment name, but still there is an issue in connecting to Azure OpenAI model.
AZURE_RESOURCE_NAME = https://{resource_name}.openai.azure.com/openai/deployments/{model_name}/chat/completions?api-version=2025-01-01-preview

@Delta-11 commented on GitHub (Nov 11, 2025): @rekram1-node I have connected Opencode to Github App, and I have a workflow file. I am not able to configure the resources properly using Azure OpenAI. name: opencode on: issue_comment: types: [created] jobs: opencode: # Run only if the comment body contains /oc or /opencode if: | contains(github.event.comment.body, '/oc') || contains(github.event.comment.body, '/opencode') runs-on: ubuntu-latest permissions: id-token: write steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 1 - name: Run opencode uses: sst/opencode/github@latest env: AZURE_API_KEY: ${{ secrets.AZURE_API_KEY }} AZURE_RESOURCE_NAME: ${{ secrets.AZURE_RESOURCE_NAME }} with: model: azure/gpt-4.1-mini I am getting following error. modelID: "gpt-4.1-mini", providerID: "azure", time: { created: 1762877974726, completed: 1762877974757, }, sessionID: "ses_58c48dd8effesRo8Q0Ps8f0sIO", error: { name: "UnknownError", data: { message: "Error: Unable to connect. Is the computer able to access the url?", }, }, } I have kept the model name and deployment name, but still there is an issue in connecting to Azure OpenAI model. AZURE_RESOURCE_NAME = https://{resource_name}.openai.azure.com/openai/deployments/{model_name}/chat/completions?api-version=2025-01-01-preview
Author
Owner

@rekram1-node commented on GitHub (Nov 11, 2025):

does the resource have any security restrictions? Wondering why the action cant access it

@rekram1-node commented on GitHub (Nov 11, 2025): does the resource have any security restrictions? Wondering why the action cant access it
Author
Owner

@Delta-11 commented on GitHub (Nov 12, 2025):

No, there is no such restriction. I can access it using python sdk or in Azure Playground as well. Do you have some boiler plate code or some reference I can refer to. It will be helpful.

@Delta-11 commented on GitHub (Nov 12, 2025): No, there is no such restriction. I can access it using python sdk or in Azure Playground as well. Do you have some boiler plate code or some reference I can refer to. It will be helpful.
Author
Owner

@rekram1-node commented on GitHub (Nov 12, 2025):

@Delta-11 there isn't much to our azure stuff it is just this:

and the ai sdk package: https://ai-sdk.dev/providers/ai-sdk-providers/azure

@rekram1-node commented on GitHub (Nov 12, 2025): @Delta-11 there isn't much to our azure stuff it is just this: - https://github.com/sst/opencode/blob/a0f469095c590110ce51d371be3edfe7a671f330/packages/opencode/src/provider/provider.ts#L67-L79 and the ai sdk package: https://ai-sdk.dev/providers/ai-sdk-providers/azure
Author
Owner

@Delta-11 commented on GitHub (Nov 12, 2025):

@rekram1-node Thanks, I was able to fix the code and it is working as expected. However, I have one doubt, I can see the current session is being stored at opencode side. I have hosted my own opencode server. Can you point me to the reference if there is a way I configure in github action workflow that will connect to my server instead of opencode server.

@Delta-11 commented on GitHub (Nov 12, 2025): @rekram1-node Thanks, I was able to fix the code and it is working as expected. However, I have one doubt, I can see the current session is being stored at opencode side. I have hosted my own opencode server. Can you point me to the reference if there is a way I configure in github action workflow that will connect to my server instead of opencode server.
Author
Owner

@rekram1-node commented on GitHub (Nov 12, 2025):

hmm that's interesting... I don't think we have a great way of doing that rn.... Frank added a command that allows u to import a session from a github action locally, but u have to run it yourself each time it doesn't auto sync.

I suppose u could also do SSH + a file mount and write a custom action if u want everything to auto sync

Here is an example of a custom action for reference: https://github.com/sst/opencode/blob/dev/.github/workflows/duplicate-issues.yml

@rekram1-node commented on GitHub (Nov 12, 2025): hmm that's interesting... I don't think we have a great way of doing that rn.... Frank added a command that allows u to import a session from a github action locally, but u have to run it yourself each time it doesn't auto sync. I suppose u could also do SSH + a file mount and write a custom action if u want everything to auto sync Here is an example of a custom action for reference: https://github.com/sst/opencode/blob/dev/.github/workflows/duplicate-issues.yml
Author
Owner

@Delta-11 commented on GitHub (Nov 13, 2025):

I did try, but still issue persist the share link that is created for session is still stored on opencode.ai server and not on my own server.
Then only option I could see now is, I can do opencode serve and then try connecting using SDK or send a direct API request.
I am doubtful whether using this approach I would be able to create a new branch, update the code automatically and then raise a PR. I don't see a direct functionality available in SDK.

@Delta-11 commented on GitHub (Nov 13, 2025): I did try, but still issue persist the share link that is created for session is still stored on opencode.ai server and not on my own server. Then only option I could see now is, I can do opencode serve and then try connecting using SDK or send a direct API request. I am doubtful whether using this approach I would be able to create a new branch, update the code automatically and then raise a PR. I don't see a direct functionality available in SDK.
Author
Owner

@rekram1-node commented on GitHub (Nov 13, 2025):

We are going to make share self hostable soon

@rekram1-node commented on GitHub (Nov 13, 2025): We are going to make share self hostable soon
Author
Owner

@Delta-11 commented on GitHub (Nov 14, 2025):

Thanks for that.

@Delta-11 commented on GitHub (Nov 14, 2025): Thanks for that.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2736