Skip to content

@ai-sdk/azure provider does not work with /chat/completions since v1.3.4 #20287

Closed

Description

@chunglam2525

Description

@ai-sdk/azure provider does not work since v1.3.4

here is my opencode.json config

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "foundary": {
      "npm": "@ai-sdk/azure",
      "options": {
        "baseURL": "https://custom-domain/openai",
        "apiKey": "xxxxxxxx",
        "apiVersion": "2025-04-01-preview",
        "useDeploymentBasedUrls": true,
        "useCompletionUrls": true
      },
      "models": {
        "gpt-5.4": {
          "name": "GPT-5.4"
        }
      }
    }
  },
  "autoupdate": false
}

I have looked up a lot of similar issue regarding azure openai api, seems like everyone is confuse about azure multiple supporting API format.

Expect:
POST: https://custom-domain/openai/deployments/{deployment-id}/chat/completions?api-version={api-version}

{
  "model": "gpt-5.4",
  "messages": [
    ...
  ],
  ...
}

Actual:
POST: https://custom-domain/openai/deployments/{deployment-id}/responses?api-version={api-version}

{
  "model": "gpt-5.4",
  "input": [
    ...
  ],
  ...
}

This line of code sdk.chat(modelID) should direct me to the chat completion method with useCompletionUrls options based on the logic

changing @ai-sdk/azure version to 3.0.49 in opencode v1.3.4 might cause this issue to appear

Plugins

No response

OpenCode version

v1.3.4

Steps to reproduce

  1. prepare a azure api that have (only) this API format available - https://custom-domain/openai/deployments/{deployment-id}/chat/completions?api-version={api-version}
  2. use opencode version v1.3.3 with this config - it works
  3. use opencode version v1.3.4 with same config - it does not works

Screenshot and/or share link

No response

Operating System

macOS

Terminal

WezTerm

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 31, 2026
  2. changed the title [-]@ai-sdk/azure provider does not work since v1.3.4[/-] [+]@ai-sdk/azure provider does not work with /chat/completions since v1.3.4[/+] on Mar 31, 2026
  3. rekram1-node commented on Mar 31, 2026

    @rekram1-node
    Collaborator

    are u getting a 404 not found? I managed to hit azure completions just fine

  4. chunglam2525 commented on Mar 31, 2026

    @chunglam2525
    Author

    are u getting a 404 not found? I managed to hit azure completions just fine

    I did get Resource Not Found error in response.

    I try running debug log and saw it was hitting /response endpoint, which indicates it was using response method from @ai-sdk/azure provider.

    I also try forcing the api path with similar to this method, but later found out that the request body json is in different formats with the different error message I received.

    One thing that I am uncertain is that in previous opencode versions, I did not even input useCompletionUrls option at all and the api still works fine, hitting the completion endpoint correctly. But based on the code logic, it should default to using response instead.

  5. rekram1-node commented on Mar 31, 2026

    @rekram1-node
    Collaborator

    Oh I think I found it

  6. rekram1-node commented on Mar 31, 2026

    @rekram1-node
    Collaborator

    Wait why is ur provider called "foundary"

    If it was called "azure" I think it'd work but it's not?

  7. rekram1-node commented on Mar 31, 2026

    @rekram1-node
    Collaborator

    "useCompletionUrls" is something we have it's only tied to that oen provider name

  8. added a commit that references this issue on Mar 31, 2026
    eac82dc
  9. chunglam2525 commented on Apr 1, 2026

    @chunglam2525
    Author

    Wait why is ur provider called "foundary"

    If it was called "azure" I think it'd work but it's not?

    It does work after I change the namespace from foundary to azure (tested on opencode v1.3.13)

      "provider": {
        "azure": {
          "npm": "@ai-sdk/azure",
          "options": {
            "baseURL": "https://custom-domain/openai",
            "apiKey": "xxxxxxxx",
            "apiVersion": "2025-04-01-preview",
            "useDeploymentBasedUrls": true,
            "useCompletionUrls": true
          },
          "models": {
            "gpt-5.4": {
              "name": "GPT-5.4"
            }
          }
        }
      }
    

    I thought this is just a display name tag in TUI model select, separating custom provider with default provider, didn't know it have actual mapping functionality

    Does this mean provider[key] and provider[key].npm always need to pair up correctly?

  10. rekram1-node commented on Apr 1, 2026

    @rekram1-node
    Collaborator

    No, it's just that deployment / completion urls thing is kinda an old artifact, im not even sure if it is documented there has got to be a cleaner solution.

    But it has been hard coded specifically for that provider this whole time

  11. rekram1-node commented on Apr 1, 2026

    @rekram1-node
    Collaborator

    We have azure support but it's not like great in terms of UX and accounting for all the different setups so if u have any ideas we are all ears

  12. peri4n commented on Apr 23, 2026

    @peri4n

    @chunglam2525 @rekram1-node I am sorry but is this broken again? I can't get it to work in 1.4.11 with azure as provider name and useCompletionUrls set to true.

  13. chunglam2525 commented on May 6, 2026

    @chunglam2525
    Author

    @peri4n are you experiencing this error?

    Function tools with reasoning_effort are not supported for gpt-5.5 in /v1/chat/completions. Please use /v1/responses instead.
    

    In opencode v1.3.16, this pr fixes provider options for azure sdk. But it breaks the /v1/chat/completions method.


    Removing reasoning_effort from fetch body does solve this problem, but I am not sure this will be a good solution, since this is too much of custom logic for this specific provider. @rekram1-node

    packages/opencode/src/provider/provider.ts

    // Strip openai itemId metadata following what codex does
    if (
      (model.api.npm === "@ai-sdk/openai" || model.api.npm === "@ai-sdk/azure") &&
      opts.body &&
      opts.method === "POST"
    ) {
      const body = JSON.parse(opts.body as string)
      const keepIds = body.store === true
      let bodyChanged = false
      if (!keepIds && Array.isArray(body.input)) {
        for (const item of body.input) {
          if ("id" in item) {
            delete item.id
            bodyChanged = true
          }
        }
      }
      // Remove reasoning_effort for /v1/chat/completions
      if (options["useCompletionUrls"]) {
        delete body["reasoning_effort"]
        bodyChanged = true
      }
      if (bodyChanged) {
        opts.body = JSON.stringify(body)
      }
    }
    

    For now, I would recommend sticking to a fix version of opencode if you are using azure with /chat/completion endpoint, since it is already mention in above reply that this azure deployment/completion endpoint being an old artifact with discontinue updates

  14. peri4n commented on May 7, 2026

    @peri4n

    Hi @chunglam2525,
    thank you for the response.

    I get a 404 Ressource not Found because I can't opencode to actually use a chat/completions endpoint even with useCompletionUrls set to true.

  15. chunglam2525 commented on May 11, 2026

    @chunglam2525
    Author

    Hi @chunglam2525, thank you for the response.

    I get a 404 Ressource not Found because I can't opencode to actually use a chat/completions endpoint even with useCompletionUrls set to true.

    Can you share your provider config? it seems like it is reaching an incorrect endpoint.
    Or what you could do is using DEBUG log opencode --log-level DEBUG to investigate the API call from opencode.

  16. rekram1-node commented on May 11, 2026

    @rekram1-node
    Collaborator

    maybe share opencode debug config

  17. peri4n commented on May 11, 2026

    @peri4n

    I hope this helps:

    {
      "$schema": "https://opencode.ai/config.json",
      "mcp": {
        "git": {
          "command": [
            "/nix/store/n6704zw3zhjmzf4xh37lvq40p914rzk6-mcp-server-git-2026.1.26/bin/mcp-server-git"
          ],
          "enabled": true,
          "type": "local"
        },
        "nixos": {
          "command": [
            "/nix/store/29zsf22sip45hm3nkmkw0myp40kc27hb-mcp-nixos-2.4.3/bin/mcp-nixos"
          ],
          "enabled": true,
          "type": "local"
        },
        "sequential-thinking": {
          "command": [
            "/nix/store/6b0rp1chaakhv2si1z7mik890n0w50aw-mcp-server-sequential-thinking-2026.1.26/bin/mcp-server-sequential-thinking"
          ],
          "enabled": true,
          "type": "local"
        }
      },
      "model": "enbw_anthropic/Latest",
      "provider": {
        "azure": {
          "models": {
            "gpt-5": {
              "name": "GPT-5"
            },
            "gpt-5-mini": {
              "name": "GPT-5 Mini"
            }
          },
          "name": "ENBW OpenAI",
          "npm": "@ai-sdk/azure",
          "options": {
            "apiKey": "API_KEY",
            "apiVersion": "2025-02-01-preview",
            "baseURL": "https://example.com/openai",
            "useCompletionUrls": true,
            "useDeploymentBasedUrls": true
          }
        },
        "enbw_anthropic": {
          "models": {
            "eu.anthropic.claude-sonnet-4-20250514-v1:0": {
              "name": "Latest"
            }
          },
          "name": "ENBW Anthropic",
          "npm": "@ai-sdk/amazon-bedrock",
          "options": {
            "apiKey": "API_KEY",
            "baseURL": "https://example.com/anthropic",
            "headers": {
              "api-key": "API_KEY"
            },
            "region": "eu-central-1"
          }
        }
      },
      "agent": {},
      "mode": {},
      "plugin": [
        "file:///home/fbull/.config/opencode/plugin/env-protection.js"
      ],
      "command": {},
      "plugin_origins": [
        {
          "spec": "file:///home/fbull/.config/opencode/plugin/env-protection.js",
          "source": "/home/fbull/.config/opencode",
          "scope": "global"
        }
      ],
      "username": "fbull"
    }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions