claude-code - 💡(How to fix) Fix [FEATURE] Support third-party inference providers in Claude Code (parity with Cowork 3P) [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52572Fetched 2026-04-24 06:03:34
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
labeled ×3

Root Cause

Claude Desktop's Cowork 3P supports a Gateway connection mode for third-party inference:

Developer → Configure third-party inference → Connection: Gateway This mode accepts a base URL and an API key, and authenticates with Authorization: Bearer <token> — enabling direct connections to any gateway that implements /v1/messages (GitHub Copilot, Azure AI Foundry, corporate API gateways, etc.). The underlying configuration: { "inferenceProvider": "gateway", "inferenceGatewayBaseUrl": "https://api.githubcopilot.com", "inferenceGatewayApiKey": "<bearer_token>", "inferenceModels": "["claude-sonnet-4-6","claude-opus-4-6"]" } Claude Code has no equivalent Gateway mode. It only supports:

  • Anthropic direct (x-api-key header)
  • AWS Bedrock (SigV4)
  • Google Vertex AI (Google OAuth) Because Claude Code hardcodes x-api-key, connecting to any gateway that expects Authorization: Bearer requires running a local reverse proxy solely to rewrite one HTTP header — unnecessary overhead when the upstream already speaks native Anthropic Messages API.
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing requests and this feature hasn't been requested yet
  • This is a single feature request (not multiple features)

Problem Statement

Claude Desktop's Cowork 3P supports a Gateway connection mode for third-party inference:

Developer → Configure third-party inference → Connection: Gateway This mode accepts a base URL and an API key, and authenticates with Authorization: Bearer <token> — enabling direct connections to any gateway that implements /v1/messages (GitHub Copilot, Azure AI Foundry, corporate API gateways, etc.). The underlying configuration: { "inferenceProvider": "gateway", "inferenceGatewayBaseUrl": "https://api.githubcopilot.com", "inferenceGatewayApiKey": "<bearer_token>", "inferenceModels": "["claude-sonnet-4-6","claude-opus-4-6"]" } Claude Code has no equivalent Gateway mode. It only supports:

  • Anthropic direct (x-api-key header)
  • AWS Bedrock (SigV4)
  • Google Vertex AI (Google OAuth) Because Claude Code hardcodes x-api-key, connecting to any gateway that expects Authorization: Bearer requires running a local reverse proxy solely to rewrite one HTTP header — unnecessary overhead when the upstream already speaks native Anthropic Messages API.

Proposed Solution

Add the same Gateway connection mode to Claude Code, for example via environment variables: export ANTHROPIC_AUTH_MODE="bearer" export ANTHROPIC_BASE_URL="https://api.githubcopilot.com" export ANTHROPIC_API_KEY="gho_xxxxxxxxxxxx" Or via ~/.claude/settings.json, mirroring the Cowork 3P config: { "inferenceProvider": "gateway", "inferenceGatewayBaseUrl": "https://api.githubcopilot.com", "inferenceGatewayApiKey": "gho_xxxxxxxxxxxx" } The implementation is minimal — the only behavioral difference from the current ANTHROPIC_BASE_URL flow is sending the key as Authorization: Bearer <key> instead of x-api-key: <key>.

Alternative Solutions

No response

Priority

Medium - Would be very helpful

Feature Category

Other

Use Case Example

GitHub Copilot includes access to all Claude models via an endpoint that supports /v1/messages natively. Developers with Copilot subscriptions could use Claude Code directly without any middleware. The same applies to any Anthropic-compatible gateway.

Additional Context

No response

extent analysis

TL;DR

Add a Gateway connection mode to Claude Code to support Authorization: Bearer authentication.

Guidance

  • Implement environment variable support for ANTHROPIC_AUTH_MODE, ANTHROPIC_BASE_URL, and ANTHROPIC_API_KEY to enable Gateway mode.
  • Update the authentication logic to send the API key as Authorization: Bearer <key> instead of x-api-key: <key> when ANTHROPIC_AUTH_MODE is set to "bearer".
  • Consider adding support for configuring Gateway mode via ~/.claude/settings.json to mirror the Cowork 3P config.
  • Verify the implementation by testing connections to gateways that expect Authorization: Bearer authentication, such as GitHub Copilot.

Example

// Example settings.json configuration
{
  "inferenceProvider": "gateway",
  "inferenceGatewayBaseUrl": "https://api.githubcopilot.com",
  "inferenceGatewayApiKey": "gho_xxxxxxxxxxxx"
}

Notes

The proposed solution requires minimal implementation changes, and the existing Anthropic Messages API support can be leveraged to reduce development overhead.

Recommendation

Apply the proposed workaround by implementing the Gateway connection mode in Claude Code, as it provides a flexible and compatible solution for connecting to various gateways.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING