Sandbox
@StringKe/claudex

Claude Code proxy and manager for multiple providers

Claudex runs a local proxy that sits between Claude Code and your chosen model provider. It translates Anthropic-style requests to OpenAI Chat Completions or Responses API calls, or passes through directly for providers that already match Claude's protocol.

50 stars20 forksMDXUpdated 6mo ago
Who it's for

Builders who use Claude Code and want to switch between model providers, subscriptions, and fallback routes from one place.

What it delivers

You can keep using Claude Code while routing sessions through different providers, with automatic translation and failover.

What it does

Multi-provider translation proxy

Routes Claude Code traffic through Anthropic passthrough, OpenAI Chat Completions, or OpenAI Responses translation paths.

Provider profiles and smart routing

Lets you run named profiles with `claudex run <profile>` or auto-select a provider with `claudex run auto`.

Circuit breaker and failover

Switches to backup providers when the active one starts failing.

OAuth subscription login

Supports login flows for ChatGPT/Codex, Claude Max, GitHub Copilot, GitLab Duo, Google Gemini, Qwen, and Kimi.

Configuration sets

Installs and manages reusable Claude Code config sets from git repositories.

TUI dashboard

Shows profile health, metrics, logs, and quick launch actions in a terminal dashboard.

Context engine

Adds conversation compression, cross-profile sharing, and local RAG with embeddings.

Self-update command

Updates the binary from GitHub Releases with `claudex update`.

How to get it

  1. 1Run
    # One-liner (Linux / macOS)
    curl -fsSL https://raw.githubusercontent.com/StringKe/claudex/main/install.sh | bash
    
    # From source
    cargo install --git https://github.com/StringKe/claudex
    
    # Or download from GitHub Releases
    # https://github.com/StringKe/claudex/releases

README

Claudex

Multi-instance Claude Code manager with intelligent translation proxy

CI Release License Latest Release

Documentation

English | 简体中文 | 繁體中文 | 日本語 | 한국어 | Русский | Français | Português do Brasil | Español | Italiano | Deutsch | Polski


Claudex is a unified proxy that lets Claude Code seamlessly work with multiple AI providers through automatic protocol translation.

Features

  • Multi-provider proxy — DirectAnthropic passthrough + Anthropic <-> OpenAI Chat Completions translation + Anthropic <-> Responses API translation
  • 20+ providers — Anthropic, OpenRouter, Grok, OpenAI, DeepSeek, Kimi, GLM, Groq, Mistral, Together AI, Perplexity, Cerebras, Azure OpenAI, Google Vertex AI, Ollama, LM Studio, and more
  • Streaming translation — Full SSE stream translation with tool call support
  • Circuit breaker + failover — Automatic fallback to backup providers with configurable thresholds
  • Smart routing — Intent-based auto-routing via local classifier
  • Context engine — Conversation compression, cross-profile sharing, local RAG with embeddings
  • OAuth subscriptions — ChatGPT/Codex, Claude Max, GitHub Copilot, GitLab Duo, Google Gemini, Qwen, Kimi
  • Configuration sets — Install and manage reusable Claude Code configuration sets from git repos
  • TUI dashboard — Real-time profile health, metrics, logs, and quick-launch
  • Self-updateclaudex update downloads the latest release from GitHub

Installation

# One-liner (Linux / macOS)
curl -fsSL https://raw.githubusercontent.com/StringKe/claudex/main/install.sh | bash

# From source
cargo install --git https://github.com/StringKe/claudex

# Or download from GitHub Releases
# https://github.com/StringKe/claudex/releases

System Requirements

  • macOS (Intel / Apple Silicon) or Linux (x86_64 / ARM64)
  • Claude Code installed
  • Windows: download pre-built binary from Releases

Quick Start

# 1. Initialize config
claudex config init

# 2. Add a provider profile interactively
claudex profile add

# 3. Test connectivity
claudex profile test all

# 4. Run Claude Code with a specific provider
claudex run grok

# 5. Or use smart routing to auto-select the best provider
claudex run auto

How It Works

claudex run openrouter-claude
    │
    ├── Start proxy (if not running) → 127.0.0.1:13456
    │
    └── exec claude with env vars:
        ANTHROPIC_BASE_URL=http://127.0.0.1:13456/proxy/openrouter-claude
        ANTHROPIC_AUTH_TOKEN=claudex-passthrough
        ANTHROPIC_MODEL=anthropic/claude-sonnet-4
        ANTHROPIC_DEFAULT_HAIKU_MODEL=...
        ANTHROPIC_DEFAULT_SONNET_MODEL=...
        ANTHROPIC_DEFAULT_OPUS_MODEL=...

The proxy intercepts requests and handles protocol translation:

  • DirectAnthropic (Anthropic, MiniMax, Vertex AI) → forward with correct headers
  • OpenAICompatible (Grok, OpenAI, DeepSeek, etc.) → Anthropic → OpenAI Chat Completions → translate response back
  • OpenAIResponses (ChatGPT/Codex subscriptions) → Anthropic → Responses API → translate response back

Provider Compatibility

ProviderTypeTranslationAuthExample Model
AnthropicDirectAnthropicNoneAPI Keyclaude-sonnet-4-20250514
MiniMaxDirectAnthropicNoneAPI Keyclaude-sonnet-4-20250514
OpenRouterOpenAICompatibleAnthropic <-> OpenAIAPI Keyanthropic/claude-sonnet-4
Grok (xAI)OpenAICompatibleAnthropic <-> OpenAIAPI Keygrok-3-beta
OpenAIOpenAICompatibleAnthropic <-> OpenAIAPI Keygpt-4o
DeepSeekOpenAICompatibleAnthropic <-> OpenAIAPI Keydeepseek-chat
KimiOpenAICompatibleAnthropic <-> OpenAIAPI Keykimi-k2-0905-preview
GLM (Zhipu)OpenAICompatibleAnthropic <-> OpenAIAPI Keyglm-4-plus
GroqOpenAICompatibleAnthropic <-> OpenAIAPI Keyllama-3.3-70b
MistralOpenAICompatibleAnthropic <-> OpenAIAPI Keymistral-large-latest
Together AIOpenAICompatibleAnthropic <-> OpenAIAPI Keymeta-llama/...
PerplexityOpenAICompatibleAnthropic <-> OpenAIAPI Keysonar-pro
CerebrasOpenAICompatibleAnthropic <-> OpenAIAPI Keyllama-3.3-70b
Azure OpenAIOpenAICompatibleAnthropic <-> OpenAIapi-key headergpt-4o
Google Vertex AIDirectAnthropicNoneBearer (gcloud)claude-sonnet-4@...
OllamaOpenAICompatibleAnthropic <-> OpenAINoneqwen2.5:72b
LM StudioOpenAICompatibleAnthropic <-> OpenAINonelocal model
ChatGPT/Codex subOpenAIResponsesAnthropic <-> ResponsesOAuth (PKCE/Device)gpt-5.3-codex
Claude Max subDirectAnthropicNoneOAuth (file)claude-sonnet-4
GitHub CopilotOpenAICompatibleAnthropic <-> OpenAIOAuth (Device+Bearer)gpt-4o
GitLab DuoOpenAICompatibleAnthropic <-> OpenAIGITLAB_TOKENclaude-sonnet-4

Configuration

Claudex searches for config files in this order:

  1. $CLAUDEX_CONFIG environment variable
  2. ./claudex.toml or ./claudex.yaml (current directory)
  3. ./.claudex/config.toml
  4. Parent directories (up to 10 levels)
  5. ~/.config/claudex/config.toml (global, recommended)

Supports TOML and YAML formats. See config.example.toml for the full reference.

CLI Reference

CommandDescription
claudex run <profile>Run Claude Code with a specific provider
claudex run autoSmart routing — auto-select best provider
claudex run <profile> -m <model>Override model for a session
claudex profile listList all configured profiles
claudex profile addInteractive profile setup wizard
claudex profile show <name>Show profile details
claudex profile remove <name>Remove a profile
claudex profile test <name|all>Test provider connectivity
claudex proxy start [-p port] [-d]Start proxy (optionally as daemon)
claudex proxy stopStop proxy daemon
claudex proxy statusShow proxy status
claudex dashboardLaunch TUI dashboard
claudex config show [--raw] [--json]Show loaded config
claudex config init [--yaml]Create config in current directory
claudex config edit [--global]Open config in $EDITOR
claudex config validate [--connectivity]Validate config
claudex config get <key>Get a config value
claudex config set <key> <value>Set a config value
claudex config export --format <fmt>Export config (json/toml/yaml)
claudex update [--check]Self-update from GitHub Releases
claudex auth login <provider>OAuth login
claudex auth login github --enterprise-url <domain>GitHub Enterprise Copilot
claudex auth statusShow OAuth token status
claudex auth logout <profile>Remove OAuth token
claudex auth refresh <profile>Force refresh OAuth token
claudex sets add <source> [--global]Install a configuration set
claudex sets remove <name>Remove a configuration set
claudex sets list [--global]List installed sets
claudex sets update [name]Update sets to latest

OAuth Subscriptions

Use existing subscriptions instead of API keys:

# ChatGPT subscription (auto-detects existing Codex CLI credentials)
claudex auth login chatgpt --profile codex-sub

# ChatGPT force browser login
claudex auth login chatgpt --profile codex-sub --force

# ChatGPT headless (SSH/no-browser)
claudex auth login chatgpt --profile codex-sub --force --headless

# GitHub Copilot
claudex auth login github --profile copilot

# GitHub Copilot Enterprise
claudex auth login github --profile copilot-ent --enterprise-url company.ghe.com

# GitLab Duo (reads GITLAB_TOKEN env)
claudex auth login gitlab --profile gitlab-duo

# Check status
claudex auth status

# Run with subscription
claudex run codex-sub

Supported: claude, chatgpt/openai, google, qwen, kimi, github/copilot, gitlab

Model Slot Mapping

Map Claude Code's /model switcher (haiku/sonnet/opus) to any provider's models:

[[profiles]]
name = "openrouter-deepseek"
provider_type = "OpenAICompatible"
base_url = "https://openrouter.ai/api/v1"
api_key = "sk-or-..."
default_model = "deepseek/deepseek-chat-v3-0324"

[profiles.models]
haiku = "deepseek/deepseek-chat-v3-0324"
sonnet = "deepseek/deepseek-chat-v3-0324"
opus = "deepseek/deepseek-r1"

Architecture

src/
├── main.rs
├── cli.rs
├── update.rs
├── util.rs
├── config/
│   ├── mod.rs          # Config discovery + parsing (figment)
│   ├── cmd.rs          # config get/set/export/validate subcommands
│   └── profile.rs      # Profile CRUD + connectivity test
├── process/
│   ├── mod.rs
│   ├── launch.rs       # Claude process launcher
│   └── daemon.rs       # PID file + process management
├── oauth/
│   ├── mod.rs          # AuthType, OAuthProvider, OAuthToken
│   ├── source.rs       # Layer 1: credential sources (env/file/keyring)
│   ├── exchange.rs     # Layer 2: token exchange (PKCE/device code/refresh)
│   ├── manager.rs      # Layer 3: cache + concurrent dedup + 401 retry
│   ├── handler.rs      # OAuthProviderHandler trait
│   ├── providers.rs    # Login/refresh/status CLI logic
│   ├── server.rs       # OAuth callback server + device code polling
│   └── token.rs        # Re-exports
├── proxy/
│   ├── mod.rs          # Axum server + ProxyState
│   ├── handler.rs      # Request routing + circuit breaker + 401 retry
│   ├── adapter/        # Provider-specific adapters
│   │   ├── mod.rs      # ProviderAdapter trait + factory
│   │   ├── direct.rs   # DirectAnthropic (passthrough)
│   │   ├── chat_completions.rs  # OpenAI Chat Completions
│   │   └── responses.rs         # OpenAI Responses API
│   ├── translate/      # Protocol translation
│   │   ├── chat_completions.rs
│   │   ├── chat_completions_stream.rs
│   │   ├── responses.rs
│   │   └── responses_stream.rs
│   ├── context_engine.rs
│   ├── fallback.rs     # Circuit breaker
│   ├── health.rs
│   ├── metrics.rs
│   ├── models.rs
│   ├── error.rs
│   └── util.rs
├── router/
│   ├── mod.rs
│   └── classifier.rs
├── context/
│   ├── mod.rs
│   ├── compression.rs
│   ├── sharing.rs
│   └── rag.rs
├── sets/               # Configuration sets management
│   ├── mod.rs
│   ├── schema.rs
│   ├── source.rs
│   ├── install.rs
│   ├── lock.rs
│   ├── conflict.rs
│   └── mcp.rs
├── terminal/           # Terminal detection + hyperlinks
│   ├── mod.rs
│   ├── detect.rs
│   ├── osc8.rs
│   └── pty.rs
└── tui/
    ├── mod.rs
    ├── dashboard.rs
    ├── input.rs
    └── widgets.rs

License

MIT

Files in the repo

Repository payload31 top-level entries
  • .claude
  • .github
  • schemas
  • src
  • tests
  • website
  • .gitignore
  • Cargo.lock
  • Cargo.toml
  • CLAUDE.md
  • cliff.toml
  • CODE_OF_CONDUCT.md
  • config.example.toml
  • config.example.yaml
  • CONTRIBUTING.md
  • install.sh
  • LICENSE
  • README.de.md
  • README.es.md
  • README.fr.md
  • README.it.md
  • README.ja.md
  • README.ko.md
  • README.md
  • README.pl.md
  • README.pt-BR.md
  • README.ru.md
  • README.zh-CN.md
  • README.zh-TW.md
  • SECURITY.md
  • sets.json

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More tools

JuliusBrussee/
caveman

🪨 why use many token when few token do trick — Claude Code skill that cuts 65% of tokens by talking like caveman

105k
1 add
MemPalace/
mempalace

The best-benchmarked open-source AI memory system. And it's free.

59k
stablyai/
orca

Orca is the ADE for working with a fleet of parallel agents. Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

66k

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

132k

Never stop coding. Free MIT AI gateway: one endpoint, 352 providers (150+ free), 1200+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 550+ contributors

64k
headroomlabs-ai/
headroom

Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.

71k