Skip to content

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

Closed

Description

@BenjaminOmar

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

Activity

  1. changed the title [-]Settign up opencode with azure ai foundry (openai) project[/-] [+]Setting up opencode with azure ai foundry (openai) project issue[/+] on Nov 9, 2025
  2. rekram1-node commented on Nov 9, 2025

    @rekram1-node
    Collaborator

    @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

  3. rekram1-node commented on Nov 9, 2025

    @rekram1-node
    Collaborator

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

  4. BenjaminOmar commented on Nov 9, 2025

    @BenjaminOmar
    Author

    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!

  5. Delta-11 commented on Nov 11, 2025

    @Delta-11

    @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

  6. rekram1-node commented on Nov 11, 2025

    @rekram1-node
    Collaborator

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

  7. Delta-11 commented on Nov 12, 2025

    @Delta-11

    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.

  8. Delta-11 commented on Nov 12, 2025

    @Delta-11

    @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.

  9. rekram1-node commented on Nov 12, 2025

    @rekram1-node
    Collaborator

    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

  10. Delta-11 commented on Nov 13, 2025

    @Delta-11

    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.

  11. rekram1-node commented on Nov 13, 2025

    @rekram1-node
    Collaborator

    We are going to make share self hostable soon

  12. Delta-11 commented on Nov 14, 2025

    @Delta-11

    Thanks for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions