Skip to content

How to set up an Azure Foundry (Cognitive Services) model on windows #11792

Closed

Description

@ilrenzo

Question

Hi,
I've deployed a gpt5.1-codex model on Azure Foundry.
I have the following info from Azure Foundry:

  • Target URI: "my-service.cognitiveservices.azure.com"
  • Model: "gpt-5.1-codex"
  • API KEY
  • Deployment name: "my-service"

When I try to add this model from Azure in opencode it only asks me for the API KEY. I select the the gpt 5.1 Codex model in the chat from Azure Cognitive Services and it says:

"AI_LoadSettingError: Azure OpenAI resource name setting is missing. Pass it using the 'resourceName' parameter or the AZURE_RESOURCE_NAME environment variable."

Image

I've tried to set this AZURE_RESOURCE_NAME in various places:

  • As an environment var. I verified the environment variable was set correctly as "my-service".
  • I created an opencode.json file in the project's folder trying different json structures

Nothing worked. Still getting the same message.

Also, in windows I can't find any file with my settings and the API key that I can modify.

Any help on how to proceed?

Activity

  1. github-actions commented on Feb 2, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  2. ilrenzo commented on Feb 5, 2026

    @ilrenzo
    Author

    Hi,
    I've finally figured out. In windows it doesn't create any opencode.json file but if you create one and put this in your project root, it works:
    {
    "$schema": "https://opencode.ai/config.json",
    "model": "gpt-5.1-codex",
    "theme": "opencode",
    "autoupdate": true,
    "provider": {
    "azure-cognitive-services": {
    "options": {
    "apiKey": "-redacted-",
    "resourceName": "my-service"
    },
    "models": {
    "gpt-5.1-codex": {
    "name": "gpt-5.1-codex"
    }
    }
    }
    }
    }

    Where resource name is the first part of your Target URI in Foundry: https://my-service.cognitiveservices.azure.com.
    Do not put any base url as it will build it itself using the resourceName.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions