Skip to content

Not clear info on how to properly setup Azure and Azure Cognitive Services Provider #14494

Closed as not planned

Description

@OpeOginni

Description

An Issue from Discord where a user could not properly get the Azure provider to work after trying to add it in using the opencode auth login command, due to missing AZURE_RESOURCE_NAME environment variable.

Plugins

None

OpenCode version

1.2.10

Steps to reproduce

  1. Login to Azure Provider using opencode auth login
  2. Put in API Key
  3. Try to use models and get hit with error.

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. github-actions commented on Feb 20, 2026

    @github-actions
    Contributor

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

    If your issue is already addressed in one of these, please consider closing this one. Otherwise, feel free to keep it open with any additional details that differentiate your case.

  2. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Feb 20, 2026
  3. absolutegravitas commented on Feb 21, 2026

    @absolutegravitas

    here's my setup if that helps for Azure Foundry / Azure Cognitive Services:

    Image

    confirmed working in opencode
    Image

  4. OpeOginni commented on Feb 21, 2026

    @OpeOginni
    ContributorAuthor

    Thanks, used that and other tests to improve the docs on cases where the used model is not an openai one

  5. absolutegravitas commented on Feb 22, 2026

    @absolutegravitas

    For posterity here's the nonFoundry Models (aka /openai/v1 standards) equivalent for anyone interested in future. Not quite sure why one needs resourceName and the other freaks out when resourceName param is used (shrug) > above my intelligence level.

    @OpeOginni your context/output limitation setting for Kimi k2.5 in another issue helped so thank you!

    Image
  6. ktzug commented on Feb 25, 2026

    @ktzug

    What about for those models that don't have OpenAI endpoints routes like Anthrophic's? They seem to not to work for whatever reason:

    Image

    As for models that have an OpenAI endpoint such as Kimi-K2.5, configuring it as an /openai/v1 model works... until it doesn't and starts exposing the Tool Calls for some reason:

    Image
      "provider": {
        "openai-compatible": {
            "options": {
                "baseURL": "https://RESOURCE_NAME.services.ai.azure.com/models",
                "apiKey": "REDACTED",
                "timeout": 300000
              },
            "models": {
                "Kimi-K2.5": {
                    "name": "Kimi-K2.5",
                    "limit": {
                      "context": 262144,
                      "output": 10000
                    },
                }
            }
        }

    I personally think that Azure is really not well integrated with OpenCode and must be worked on, or that the documentation is poor at best. My company uses Azure so it's the only thing we have available, and Claude Code (thru Azure Foundry) is costing us hundreds; even Claude has proper documentation on configuring Azure Foundry.

  7. rifusaki commented on Feb 25, 2026

    @rifusaki

    What about for those models that don't have OpenAI endpoints routes like Anthrophic's? They seem to not to work for whatever reason:

    @ktzug I just ended up setting two different custom providers: one for OpenAI-style endpoints and another one for Anthropic's. You can use the @ai-sdk/anthropic package:

      "provider": {
        "azure-anthropic": {
          "name": "Azure Foundry Anthropic",
          "npm": "@ai-sdk/anthropic",
          "api": "https://RESOURCE_NAME.services.ai.azure.com/anthropic/v1",
          "models": {
            "claude-sonnet-4-6": {
              "id": "claude-sonnet-4-6",
              "name": "Claude Sonnet 4.6",
              "tool_call": true,
              "attachment": true,
              "reasoning": true,
              "temperature": true
            }
          }
        }
      }

    However I gotta agree documentation is severely lacking.

  8. OpeOginni commented on Feb 25, 2026

    @OpeOginni
    ContributorAuthor

    The Azure system is not the cleanest, and is a bit confusing, but I have a PR to improve this flow, and maybe add a special provider for Azure Anthropic, then the Cognitive Service could be for other OpenAI Compatible models

  9. tmeckel commented on Mar 6, 2026

    @tmeckel

    Because the support for Azure was always not the best in OpenCode I created a new provider for OpenCode and other products using ai-sdk approach.

    https://github.com/ophiosdev/azure-foundry-provider

    Highlights

    • URL-first routing from copied Azure endpoint URLs (no model-name endpoint heuristics)
    • Supports both chat and responses operation paths
    • Supports Azure v1 operation paths and /openai/v1 base root with mode-driven routing
    • Chat transport uses OpenAI-compatible semantics (system role remains system, max_tokens is used)
    • Request policy control for tools (auto, off, on)
    • Built-in retries and 429 handling with exponential backoff + jitter
    • Event-driven waiter queue for maxConcurrent admission (wake-on-release, abort-aware waits)
    • Optional static quota controls (rpm, tpm, maxConcurrent, maxOutputTokensCap)
    • Adaptive throttling from Azure x-ratelimit-* headers
    • Request sanitization for chat history compatibility (removes assistant reasoning_content/reasoning fields)
    • Automatic chat->responses fallback for model/operation mismatch errors (when mode is not explicitly forced to chat)
    • Optional observability callbacks (onRetry, onAdaptiveCooldown, onSanitizedRetry, onFallback)
    • Timeout support via AbortSignal

    CC @OpeOginni @rekram1-node

  10. OpeOginni commented on Mar 6, 2026

    @OpeOginni
    ContributorAuthor

    @tmeckel this seems good, but I was thinking a better solution would be to make providers for each azure openai, azure anthrpoic and azure openai compatible, but lets see what the team thinks of

  11. removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  12. bakaburg1 commented on May 28, 2026

    @bakaburg1

    I'd really like to introduce OpenCode in my agency, but the Azure integration must be done right, otherwise it's a too big of a barrier for users.

  13. OpeOginni commented on May 28, 2026

    @OpeOginni
    ContributorAuthor

    @bakaburg1 what issue do you have, ik of folks making use of Azure models perfectly on OpenCode. Maybe let me know the issue and what models exactly you are trying to make use of.

    Here to help!

  14. github-actions commented on Jul 28, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

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