Skip to content

@ai-sdk/azure: baseURL mode appends /v1 and api-version — breaks custom gateways #13956

Closed

Description

@Dulani

[Authorship: 60% AI, 40% human]

Our Azure setup uses a corporate API gateway that proxies requests to Azure OpenAI. The gateway handles routing and API versioning internally, so we don't use /v1 path segments or api-version query params on our end. We're using @ai-sdk/azure within OpenCode.

When we configure createAzure({ baseURL: "https://our-gateway.example.com/azure" }), the provider constructs https://our-gateway.example.com/azure/v1/chat/completions?api-version=.... Both the /v1 and the api-version param break our gateway, so we've been carrying a local patch to @ai-sdk/azure to work around it.

Could we submit a PR that adds a baseURL branch to skip both? Something like:

     if (options.useDeploymentBasedUrls) {
       fullUrl = new URL(`${baseUrlPrefix}/deployments/${modelId}${path}`);
+    } else if (options.baseURL) {
+      fullUrl = new URL(`${baseUrlPrefix}${path}`);
     } else {
       fullUrl = new URL(`${baseUrlPrefix}/v1${path}`);
     }
-    fullUrl.searchParams.set('api-version', apiVersion);
+    if (!options.baseURL) {
+      fullUrl.searchParams.set('api-version', apiVersion);
+    }

The idea is: if someone explicitly provides a baseURL, they probably want full control over the URL shape. Happy to adjust the approach if there's a preferred way to handle this.

Activity

  1. added
    ai/providerrelated to a provider package. Must be assigned together with at least one `provider/*` label
    featureNew feature or request
    provider/azureIssues related to the @ai-sdk/azure provider
    on Mar 31, 2026
  2. Dulani commented on Mar 31, 2026

    @Dulani
    Author

    For context, this is related to #7372 — that issue led to the useDeploymentBasedUrls flag, which handles one URL variant. Our case is another variant in the same if/else chain: when baseURL is set, the caller likely wants the URL used as-is without /v1 or api-version appended.

  3. added a commit that references this issue on Apr 6, 2026
    7f1d168
  4. added a commit that references this issue on Apr 17, 2026
    ed331c2
  5. lgrammel commented on Jul 2, 2026

    @lgrammel
    Collaborator

    Identify issue type

    {
      "evidence": [
        "Configuring `createAzure({ baseURL: \"https://our-gateway.example.com/azure\" })` results in URLs with `/v1/chat/completions?api-version=...` appended.",
        "The reporter says both the `/v1` path segment and `api-version` query parameter break their corporate Azure OpenAI gateway.",
        "They propose changing `baseURL` handling so explicitly provided base URLs are used without adding `/v1` or `api-version`."
      ],
      "rationale": "The issue describes current `@ai-sdk/azure` URL construction producing a URL shape that breaks a configured custom gateway, i.e. existing behavior is incorrect for the reported configuration. Although a fix is suggested, the primary report is a concrete failure.",
      "type": "bug",
      "confidence": "medium"
    }
  6. added theissue type on Jul 2, 2026
  7. lgrammel commented on Jul 2, 2026

    @lgrammel
    Collaborator

    Bug Reproduction

    Bug was reproduced.

    Created and ran reproduction script packages/azure/reproductions/issue-13956.mjs with node packages/azure/reproductions/issue-13956.mjs; it observed https://our-gateway.example.com/azure/v1/chat/completions?api-version=v1 instead of the expected custom gateway URL without /v1 or api-version, failing the assertion.

    Branch: bug-reproduction/13956-1

  8. self-assigned this
    on Jul 2, 2026
  9. github-actions commented on Jul 2, 2026

    @github-actions
    Contributor

    🚀 Published in:

    Package Version
    ai 7.0.14 github npm
    @ai-sdk/alibaba 2.0.6 github npm
    @ai-sdk/amazon-bedrock 5.0.10 github npm
    @ai-sdk/angular 3.0.14 github npm
    @ai-sdk/anthropic 4.0.7 github npm
    @ai-sdk/assemblyai 3.0.5 github npm
    @ai-sdk/azure 4.0.7 github npm
    @ai-sdk/baseten 2.0.5 github npm
    @ai-sdk/black-forest-labs 2.0.5 github npm
    @ai-sdk/bytedance 2.0.6 github npm
    @ai-sdk/cerebras 3.0.5 github npm
    @ai-sdk/cohere 4.0.5 github npm
    @ai-sdk/deepgram 3.0.5 github npm
    @ai-sdk/deepinfra 3.0.5 github npm
    @ai-sdk/deepseek 3.0.5 github npm
    @ai-sdk/devtools 1.0.2 github npm
    @ai-sdk/elevenlabs 3.0.6 github npm
    @ai-sdk/fal 3.0.6 github npm
    @ai-sdk/fireworks 3.0.6 github npm
    @ai-sdk/gateway 4.0.11 github npm
    @ai-sdk/gladia 3.0.5 github npm
    @ai-sdk/google 4.0.8 github npm
    @ai-sdk/google-vertex 5.0.10 github npm
    @ai-sdk/groq 4.0.5 github npm
    @ai-sdk/harness 1.0.17 github npm
    @ai-sdk/harness-claude-code 1.0.17 github npm
    @ai-sdk/harness-codex 1.0.18 github npm
    @ai-sdk/harness-deepagents 1.0.16 github npm
    @ai-sdk/harness-opencode 1.0.17 github npm
    @ai-sdk/harness-pi 1.0.17 github npm
    @ai-sdk/huggingface 2.0.5 github npm
    @ai-sdk/hume 3.0.5 github npm
    @ai-sdk/klingai 4.0.6 github npm
    @ai-sdk/langchain 3.0.14 github npm
    @ai-sdk/llamaindex 3.0.14 github npm
    @ai-sdk/lmnt 3.0.5 github npm
    @ai-sdk/luma 3.0.6 github npm
    @ai-sdk/mcp 2.0.7 github npm
    @ai-sdk/mistral 4.0.5 github npm
    @ai-sdk/moonshotai 3.0.7 github npm
    @ai-sdk/open-responses 2.0.5 github npm
    @ai-sdk/openai 4.0.7 github npm
    @ai-sdk/openai-compatible 3.0.5 github npm
    @ai-sdk/otel 1.0.14 github npm
    @ai-sdk/perplexity 4.0.6 github npm
    @ai-sdk/policy-opa 1.0.14 github npm
    @ai-sdk/prodia 2.0.6 github npm
    @ai-sdk/provider 4.0.2 github npm
    @ai-sdk/provider-utils 5.0.5 github npm
    @ai-sdk/quiverai 2.0.5 github npm
    @ai-sdk/react 4.0.15 github npm
    @ai-sdk/replicate 3.0.6 github npm
    @ai-sdk/revai 3.0.5 github npm
    @ai-sdk/rsc 3.0.14 github npm
    @ai-sdk/sandbox-just-bash 1.0.17 github npm
    @ai-sdk/sandbox-vercel 1.0.17 github npm
    @ai-sdk/svelte 5.0.14 github npm
    @ai-sdk/togetherai 3.0.6 github npm
    @ai-sdk/tui 1.0.14 github npm
    @ai-sdk/valibot 3.0.5 github npm
    @ai-sdk/vercel 3.0.5 github npm
    @ai-sdk/voyage 2.0.5 github npm
    @ai-sdk/vue 4.0.14 github npm
    @ai-sdk/workflow 1.0.14 github npm
    @ai-sdk/workflow-harness 1.0.17 github npm
    @ai-sdk/xai 4.0.6 github npm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions