Skip to content

openai provider fails with 401 on API Gateway using Ocp-Apim-Subscription-Key due to conflicting Authorization header #9527

@jaroslavkolin-sa

Description

@jaroslavkolin-sa

Before submitting your bug report

Relevant environment info

OS: [win 11]
    Continue version: [latest 14/1/26]

VS Code version: Version: 1.108.0 (system setup)
Commit: 94e8ae2b28cb5cc932b86e1070569c4463565c37
Date: 2026-01-08T13:53:10.781Z
Electron: 39.2.7
ElectronBuildId: 12953945
Chromium: 142.0.7444.235
Node.js: 22.21.1
V8: 14.2.231.21-electron.0
OS: Windows_NT x64 10.0.22631

models:
  - title: "Custom LLM"
    provider: "openai"
    model: "my-custom-model"
    apiBase: "https://my-api-gateway.com/v1"
    apiKey: "some_dummy_value" # Required by the provider, but not used by the API
    headers:
      Ocp-Apim-Subscription-Key: "my_real_subscription_key"

Description

When configuring the openai provider to connect to a custom OpenAI-compatible endpoint hosted behind an API Gateway (like Azure APIM), the request fails with a 401 Unauthorized error. The gateway requires an Ocp-Apim-Subscription-Key header for authentication and does not use the standard Authorization: Bearer header.

The issue seems to be that the openai provider automatically injects an Authorization: Bearer header, which conflicts with the required Ocp-Apim-Subscription-Key, causing the API Gateway to reject the request.

To reproduce

To Reproduce

Configure a model using the openai provider to point to an endpoint that uses a subscription key header for auth.
My configuration in config.yaml:

models:
  - title: "Custom LLM"
    provider: "openai"
    model: "my-custom-model"
    apiBase: "https://my-api-gateway.com/v1"
    apiKey: "some_dummy_value" # Required by the provider, but not used by the API
    headers:
      Ocp-Apim-Subscription-Key: "my_real_subscription_key"

Attempt to send a request to the model from the Continue sidebar.
The request fails with a 401 Unauthorized error (with no response body).

Expected behavior

The request should succeed with a 200 OK status, as the correct authentication key is provided in the headers section. The provider should ideally not send the Authorization header if it's not needed or allow it to be fully overridden.

Validation and Troubleshooting

I have confirmed that the endpoint, API key (Ocp-Apim-Subscription-Key), and network configuration (including proxy) are all correct.

Log output

401 status code (no body)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:configurationRelates to configuration optionside:vscodeRelates specifically to VS Code extensionkind:bugIndicates an unexpected problem or unintended behavioros:windowsHappening specifically on Windows

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions