[FEATURE]: Add BYOK (Bring Your Own Key) Support in Claude Code for OpenAI, Gemini, OpenRouter, Azure OpenAI, and Other AI Providers
Title
Claude Code: Add BYOK (Bring Your Own Key) Support to Claude Code for OpenAI, Gemini, OpenRouter, Azure OpenAI, and Other AI Providers
Description
Summary
Please add BYOK (Bring Your Own Key) support to Claude Code so users can connect their own API keys and use models from other AI providers while continuing to use the Claude Code interface and workflow.
Supported providers could include:
- Anthropic (custom API key)
- OpenAI
- Google Gemini
- OpenRouter
- Azure OpenAI
- Ollama
- LM Studio
- Other OpenAI-compatible APIs
- Self-hosted model endpoints
Problem
Claude Code currently only supports Anthropic-hosted models. While Claude models are excellent, many developers and organizations already have subscriptions, credits, or infrastructure built around other providers.
This creates several challenges:
- Developers cannot use Claude Code as a single interface for all coding models.
- Organizations with existing OpenAI, Gemini, or Azure AI budgets cannot leverage them within Claude Code.
- Users must constantly switch between multiple tools and extensions depending on which model they want to use.
- There is no straightforward way to compare model outputs inside the same workflow.
- Users who have already purchased API credits elsewhere must pay for an additional AI service to use Claude Code.
Proposed Solution
Introduce a Bring Your Own Key (BYOK) configuration system that allows users to configure one or more AI providers.
Example settings:
{
"providers": {
"anthropic": {
"apiKey": "YOUR_API_KEY"
},
"openai": {
"apiKey": "YOUR_API_KEY"
},
"gemini": {
"apiKey": "YOUR_API_KEY"
},
"openrouter": {
"apiKey": "YOUR_API_KEY"
}
},
"defaultProvider": "openai",
"defaultModel": "gpt-5"
}
Desired Features
Provider Selection
Allow users to choose:
- Anthropic
- OpenAI
- Gemini
- OpenRouter
- Azure OpenAI
- Ollama
- LM Studio
- Custom/OpenAI-compatible endpoint
Model Selection
Allow users to select models such as:
- Claude models
- GPT models
- Gemini models
- Open-source models exposed through OpenRouter
- Local models running through Ollama or LM Studio
Workspace-Level Configuration
Support:
- Global default provider
- Per-workspace provider settings
- Per-project model selection
This would be especially useful for organizations that standardize on different AI providers for different projects.
Custom Endpoints
Allow users to specify:
{
"provider": "custom",
"baseUrl": "https://api.example.com/v1",
"apiKey": "YOUR_API_KEY"
}
This would enable support for:
- Self-hosted models
- Enterprise gateways
- OpenAI-compatible APIs
- Internal company AI infrastructure
Secure Credential Storage
Store API keys securely using:
- Windows Credential Manager
- macOS Keychain
- Linux Secret Service / Keyring
instead of plain-text storage wherever possible.
Benefits
For Developers
- One coding interface for all major AI providers.
- Easier experimentation and model comparison.
- Ability to use existing API credits.
- Reduced context switching between tools.
For Teams
- Better alignment with company AI policies.
- Ability to use approved enterprise providers.
- Easier migration between model vendors.
For Claude Code
- Increased adoption among developers.
- Reduced vendor lock-in concerns.
- More attractive for enterprise customers.
- Ability to become a best-in-class AI coding interface regardless of model provider.
Example Use Cases
Use Case 1
A developer wants:
- Claude Opus for architecture discussions.
- GPT-5 for code generation.
- Gemini for large-context analysis.
All within Claude Code.
Use Case 2
A company already spends thousands of dollars monthly on Azure OpenAI and wants developers to use Claude Code as the coding interface without purchasing additional subscriptions.
Use Case 3
A user runs local models through Ollama and wants to use them for routine coding tasks while reserving premium cloud models for more complex work.
Use Case 4
A developer uses OpenRouter to access multiple providers and wants Claude Code to work with their existing OpenRouter API key.
Why This Matters
Claude Code has one of the best AI-assisted development experiences available today. Adding BYOK support would make it significantly more flexible and accessible by allowing developers to use the models and providers that best fit their requirements, budgets, and organizational constraints.
This feature would position Claude Code as a leading AI development environment rather than a tool limited to a single provider ecosystem.
Additional Notes
This request is not about replacing Claude models. Claude should remain the default and first-class experience.
The goal is to give developers the flexibility to choose the provider and model that best suits their workflow while continuing to benefit from Claude Code's excellent tooling, terminal integration, workflow automation, and developer experience.
Thank you for considering this feature request.
5 Comments
BYOK would be useful, but I’d treat provider configuration as more than just
apiKey + baseUrl + model.Once Claude Code supports multiple providers, the risky edge cases become operational:
A safer config shape might include policy fields alongside credentials:
```json id="x65d0k"
{
"defaultProvider": "openrouter",
"defaultModel": "anthropic/claude-sonnet",
"budgets": {
"perRunUsd": 2,
"perWorkspaceMonthlyUsd": 100
},
"allowedModels": [
"anthropic/claude-sonnet",
"openai/gpt-5",
"google/gemini-pro"
],
"unknownPricing": "block"
}
awesome that there is some 1 talking about this tbh i would love to add my custom provider which is openai compatible once u place ur api base url and ur api key u will be able to get all available models cuz it is openai compatible or u add the models manually i really hope i can see this in claude code someday !
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
Hey, this is maybe not what you are looking for, but we solved this issue using Nori, one CLI for Claude Code, Codex, or any ACP-compatible agent.
https://github.com/tilework-tech/nori-cli
https://noriagentic.com
If you want this today without switching CLIs: I built ThinkWatch Lite, an open-source local gateway. Claude Code points at it, and it forwards to your own OpenAI, Gemini, OpenRouter or any OpenAI-compatible key, converting the request format on the way. You pick the model with ANTHROPIC_DEFAULT_SONNET_MODEL etc., or a rule that maps claude-* to whatever you want.
It also covers some of the policy stuff above: per-key model allowlists, and request/token/cost caps per day, month and so on.
Won't help with a Pro/Max login, and Anthropic's server-side tools like web search don't carry over.
https://thinkwat.ch/docs/lite/features/#upstreams