Use Claude Code for free — run it with Kimi, GLM, DeepSeek, OpenRouter and any OpenAI-compatible provider
Run Claude Code without an Anthropic API key. Point it at any free or low-cost AI provider through a single Claude-compatible endpoint.
Quick Start · Providers · Admin Dashboard · Client Setup · Running Locally · API Reference
Free Claude Code Gateway lets you use the Claude Code CLI, VS Code extensions (Cline, Roo Code), Continue.dev, and any Anthropic-compatible tool — without paying for an Anthropic API key. Instead, it routes your Claude Code requests to free or affordable AI providers like Kimi, GLM, DeepSeek, or OpenRouter.
Free Claude Code · Claude Code without API key · Claude Code alternative · Claude Code proxy
This is a community-built open-source tool. It is not affiliated with Anthropic. If you can afford Claude Code, please support Anthropic and buy it — this project is for developers who cannot.
Claude Code CLI Free Claude Code Gateway Free/Cheap Provider
Cline / Roo Code ──▶ POST /v1/messages ──▶ Kimi / GLM / DeepSeek
Continue.dev POST /v1/chat/completions OpenRouter (free tier)
Any Anthropic Client Admin UI at /admin Any OpenAI-compatible API
Free Claude Code Gateway is an open-source TypeScript proxy that sits between Claude Code (and any Anthropic-compatible client) and your chosen AI provider. It accepts requests in the Anthropic Messages API format and converts them to OpenAI-compatible format before forwarding to any provider you configure — then converts the response back. Fully transparent.
Claude Code CLI Free Claude Code Gateway Your Provider
Cline / Roo Code ──▶ POST /v1/messages ──▶ Kimi / GLM / DeepSeek
Continue.dev POST /v1/chat/completions OpenRouter / Mistral
Any Anthropic Client Admin UI at /admin Any OpenAI-compatible API
This project is built by the community, for the community — specifically for developers who want to use the Claude Code interface with alternative AI providers they already have access to.
Please read before using:
- This gateway does not bypass, crack, or circumvent Anthropic's systems in any way. It is a standard API format converter — the same thing any OpenAI-compatible client library does.
- You are responsible for complying with the terms of service of both Anthropic and your chosen upstream provider.
- This project is not affiliated with, endorsed by, or supported by Anthropic.
- We do not condone using this tool to abuse free tiers, violate provider rate limits, or circumvent usage policies.
- If you use Claude Code professionally or can afford a subscription, please support Anthropic by purchasing Claude Code — it funds the research and engineering that makes Claude great.
If this gateway is useful to you and you can afford it, the right thing to do is support the people who built Claude:
→ Get Claude Code (Official) — Anthropic's official Claude Code subscription
→ Anthropic Pricing — View all plans and options
This project exists for students, hobbyists, developers in regions where pricing is prohibitive, and open-source contributors who want to experiment with Claude-compatible tooling using providers they already pay for. It is not a way to get Claude for free — you are using a different AI model from a different provider. The Claude Code interface is just the client.
POST /v1/messages— Full Claude/Anthropic-compatible endpoint. Validates, converts, routes, and returns Anthropic-format responses.POST /v1/chat/completions— OpenAI-compatible passthrough with server-side key injection.GET /v1/models— Lists models from your configured upstream provider.- Smart Model Router — Glob pattern family rules + exact mappings. Auto-Map feature detects prefix style (
vendor/modelvs baremodel) and auto-suggests the correct provider ID with one click. - Full Streaming — Server-Sent Events with
message_start,content_block_*,message_delta,message_stop— exactly what Claude Code expects. - Tool Calling — Anthropic
tools/tool_use/tool_result↔ OpenAItools/tool_callsbidirectional conversion. - Admin Dashboard — Full SPA at
/adminwith real-time analytics, request monitoring, model router management, playground, and diagnostics. - Data Persistence — Request history, config overrides, and model mappings survive restarts.
- Runtime Config — Update provider URL, API key, rate limits, and timeouts from the Admin UI without restarting.
- Easy to Deploy — Docker, Docker Compose, PM2, and Nginx configs included.
- Safe Logging — API keys and auth headers always redacted. Zero sensitive data in logs.
- Node.js 20 or newer
- An API key from any OpenAI-compatible provider
git clone https://github.com/rajakumar865465/Free-Claude-Code-Gateway.git
cd Free-Claude-Code-Gateway
npm installcp .env.example .envEdit .env:
BLUESMINDS_API_KEY=sk-your-provider-api-key
BLUESMINDS_BASE_URL=https://api.moonshot.cn/v1
PORT=8787
DEFAULT_MODEL=moonshotai/kimi-k2npm run dev # Development with live reload
npm run build # Compile TypeScript
npm start # ProductionThe gateway starts and prints:
Free Claude Code Gateway v1.0.0 listening on http://localhost:8787
Admin dashboard: http://localhost:8787/admin
That's it. Point Claude Code at http://localhost:8787 and start coding.
The gateway works with any OpenAI-compatible API endpoint. Just set BLUESMINDS_BASE_URL and BLUESMINDS_API_KEY:
| Provider | Base URL | Notes |
|---|---|---|
| Kimi (MoonShot) | https://api.moonshot.cn/v1 |
kimi-k2, moonshot-v1-8k |
| GLM / Z.ai | https://api.z.ai/api/paas/v4 |
glm-5.1, glm-5-turbo |
| DeepSeek | https://api.deepseek.com/v1 |
deepseek-chat, deepseek-coder |
| OpenRouter | https://openrouter.ai/api/v1 |
Access 100+ models via one key |
| Mistral | https://api.mistral.ai/v1 |
mistral-large, devstral-small |
| Fireworks AI | https://api.fireworks.ai/inference/v1 |
llama-v3p3-70b-instruct |
| Cerebras | https://api.cerebras.ai/v1 |
Ultra-fast inference |
| Groq | https://api.groq.com/openai/v1 |
llama-3.3-70b, gemma2-9b |
| LM Studio | http://localhost:1234/v1 |
Local models |
| Ollama | http://localhost:11434/v1 |
Any Ollama model |
| Any OpenAI-compat | your URL | Self-hosted, vLLM, llama.cpp, etc. |
Edit config/models.json to map Claude model names to your provider's models:
{
"anthropic_to_bluesminds": {
"claude-opus-4-5-20251101": "moonshotai/kimi-k2",
"claude-3-5-sonnet-latest": "moonshotai/kimi-k2",
"claude-opus-4-20250514": "moonshotai/kimi-k2",
"claude-haiku-4-20250514": "moonshotai/kimi-k2"
},
"default": "moonshotai/kimi-k2",
"family_rules": [
{ "name": "Sonnet", "pattern": "claude*sonnet*", "primary": "moonshotai/kimi-k2" },
{ "name": "Haiku", "pattern": "claude*haiku*", "primary": "moonshotai/kimi-k2" },
{ "name": "Opus", "pattern": "claude*opus*", "primary": "moonshotai/kimi-k2" },
{ "name": "Default","pattern": "*", "primary": "moonshotai/kimi-k2" }
]
}Resolution order: Exact match → Family rule (glob) → Pass-through (non-strict) → Default → Error (strict mode)
You can also manage all mappings live from the Admin Dashboard → Model Router without editing files.
OpenAI-compatible providers are inconsistent about model ID format. Some return moonshotai/kimi-k2.6 (vendor prefixed), others return kimi-k2.6 (bare name). This causes the UNSAVED status in the Model Router when you switch providers.
Auto-Map solves this automatically:
Your mapping table: Provider returns:
claude-3-5-sonnet → kimi-k2.6 moonshotai/kimi-k2.6 ← different format
claude-opus-4 → kimi-k2.6 kimi-k2.5
glm-4.6
gpt-4o
How to use it:
- Go to Admin Dashboard → Model Router
- Click Sync Models — fetches the live model list from your provider
- Click Auto-Map (unlocks after sync) — scores every row against the model list
- Yellow badges appear showing the suggested correct ID:
→ moonshotai/kimi-k2.6 - Click Apply N suggestions to fix all rows at once
- Click Save Router to persist
How the scoring works:
The matcher normalizes both sides — strips vendor prefixes, strips suffixes like -latest/-preview, collapses separators — then scores on multiple signals:
| Signal | Score |
|---|---|
Exact raw match (glm-4.6 = glm-4.6) |
1.0 |
| Same name after stripping vendor prefix | 0.9 |
| Same name after stripping suffixes | 0.85 |
Token similarity (Jaccard on --split tokens) |
0–0.7 |
Vendor alias bonus (moonshotai ↔ kimi) |
+0.1 |
Only suggestions with confidence ≥ 0.75 are shown. A green ✓ Correct badge appears when your current mapping already uses the right format.
The Provider Model input field also gets autocomplete — start typing and see all synced models as options.
Access at http://localhost:8787/admin. A full SPA with 7 views:
| View | What You Get |
|---|---|
| Overview | KPI cards (requests, success rate, latency, tokens), Chart.js request timeline, per-model usage table, failure list, gateway info |
| Live Requests | Real-time SSE feed of every request, pause/resume, filters by status/model/endpoint, per-request detail drawer |
| Playground | Send Claude or OpenAI requests directly from the UI, inspect the full translation pipeline, streaming support |
| Providers | Upstream provider connection card, API key status, model sync, stats |
| Model Router | CRUD for Claude→provider model mappings, family routing rules, Auto-Map to sync and auto-suggest correct provider IDs, available provider models with autocomplete |
| Settings | Runtime config — provider URL, API key, default model, rate limits, timeout, CORS — applied instantly |
| Diagnostics | Step-by-step connection health check with timeline, error reference, quick connection test |
Press ⌘K / Ctrl+K from anywhere in the dashboard to navigate instantly.
ADMIN_PASSWORD=your-secure-passwordHTTP Basic auth protects /admin and /admin/api/*. Leave empty in development.
All data saved to .blueclaude-data/ (gitignored):
.blueclaude-data/
├── request-log.json # Request history (last 1000 entries)
├── config-overrides.json # Runtime config changes
└── model-registry.json # Model mapping overrides
Delete to reset everything. No database required.
Point any of these at http://localhost:8787 with any API key value:
# Linux / macOS
export ANTHROPIC_BASE_URL=http://localhost:8787
export ANTHROPIC_AUTH_TOKEN=any-value
export ANTHROPIC_MODEL=claude-opus-4-5-20251101
claude# Windows PowerShell
$env:ANTHROPIC_BASE_URL = "http://localhost:8787"
$env:ANTHROPIC_AUTH_TOKEN = "any-value"
$env:ANTHROPIC_MODEL = "claude-opus-4-5-20251101"
claudeOr add to ~/.claude.json / .claude.json in your project:
{
"env": {
"ANTHROPIC_BASE_URL": "http://localhost:8787",
"ANTHROPIC_AUTH_TOKEN": "any-value",
"ANTHROPIC_MODEL": "claude-opus-4-5-20251101"
}
}| Setting | Value |
|---|---|
| API Provider | Anthropic |
| Base URL | http://localhost:8787 |
| API Key | any value (or your PROXY_API_KEY if set) |
| Model | claude-opus-4-5-20251101 |
{
"models": [{
"title": "Free Claude Code Gateway",
"provider": "anthropic",
"model": "claude-opus-4-5-20251101",
"apiBase": "http://localhost:8787",
"apiKey": "any-value"
}]
}export ANTHROPIC_API_BASE=http://localhost:8787
export ANTHROPIC_API_KEY=any-value
aider --model claude-opus-4-5-20251101| Setting | Value |
|---|---|
| Base URL | http://localhost:8787/v1 |
| API Key | any value |
| Model | your configured provider model |
{
"name": "Free Claude Code Gateway",
"status": "running",
"version": "1.0.0",
"endpoints": ["/health", "/v1/models", "/v1/messages", "/v1/chat/completions"]
}{ "ok": true, "name": "Free Claude Code Gateway", "version": "1.0.0" }Full Anthropic Messages API. Streaming supported with "stream": true.
curl http://localhost:8787/v1/messages \
-H "Content-Type: application/json" \
-H "Authorization: Bearer any-value" \
-d '{
"model": "claude-opus-4-5-20251101",
"max_tokens": 1024,
"messages": [{ "role": "user", "content": "Write a quicksort in TypeScript." }]
}'OpenAI-compatible passthrough:
curl http://localhost:8787/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer any-value" \
-d '{
"model": "moonshotai/kimi-k2",
"messages": [{ "role": "user", "content": "Hello" }]
}'# Stats
curl http://localhost:8787/admin/api/stats
# Request log
curl http://localhost:8787/admin/api/requests
# Current config (no API key exposed)
curl http://localhost:8787/admin/api/config
# Model mappings
curl http://localhost:8787/admin/api/models/mappings
# Test upstream connection
curl -X POST http://localhost:8787/admin/api/test-connectionAll admin endpoints require HTTP Basic auth when ADMIN_PASSWORD is set.
| Variable | Required | Default | Description |
|---|---|---|---|
BLUESMINDS_API_KEY |
yes | — | Your upstream provider API key |
BLUESMINDS_BASE_URL |
no | https://api.example.com/v1 |
Provider base URL |
PORT |
no | 8787 |
Port the gateway listens on |
DEFAULT_MODEL |
no | gpt-4.1 |
Fallback model when no mapping matches |
STRICT_MODEL_MAPPING |
no | false |
If true, reject unknown models with 400 |
PROXY_API_KEY |
no | — | Require Authorization: Bearer <key> on all proxy routes |
ADMIN_PASSWORD |
no | — | HTTP Basic auth password for /admin |
REQUEST_TIMEOUT_MS |
no | 120000 |
Upstream request timeout (ms) |
RATE_LIMIT_PER_MINUTE |
no | 60 |
Per-IP rate limit |
MAX_BODY_SIZE |
no | 20mb |
Max request body size |
ALLOWED_ORIGINS |
no | — | Comma-separated CORS origins (allow all in dev) |
DEBUG_LOGS |
no | false |
Verbose logging (keys always redacted) |
CLEAR_LOG_ON_RESTART |
no | false |
Wipe request log and server logs on restart |
NODE_ENV |
no | development |
development / production / test |
All settings except BLUESMINDS_API_KEY and BLUESMINDS_BASE_URL can also be updated live from the Admin Dashboard → Settings without restarting.
- Upstream API key read from env only — never logged, never returned to clients.
- Auth headers stripped by Pino's
redactpaths. safeStringifyhelper redacts any field matching/authorization|api[-_]?key|secret|password|token/i.PROXY_API_KEY— optional bearer token to protect all proxy routes.ADMIN_PASSWORD— optional HTTP Basic auth for the admin dashboard.- CORS is open in development, locked down when
ALLOWED_ORIGINSis set. - Rate limiting active by default (60 req/min/IP).
This is a local tool — just run it on your machine and point Claude Code at it.
npm run dev # Start with live reload (development)npm run build # Compile TypeScript once
npm start # Run the compiled versionThe gateway runs at http://localhost:8787. That's it.
If you prefer containers:
docker compose up --buildnpm run typecheck # TypeScript — must be clean
npm test # 6 test suites (node --test)
npm run build # Full compileTest coverage:
| File | What's Tested |
|---|---|
tests/converter.test.ts |
Anthropic ↔ OpenAI request/response conversion |
tests/errors.test.ts |
Upstream error → Anthropic error mapping |
tests/messages.test.ts |
Request validation (body, temperature, tools, streaming) |
tests/models.test.ts |
Model mapping resolution, strict mode, family rules |
tests/redact.test.ts |
API key and sensitive field redaction |
tests/config.test.ts |
Config manager persistence and env sync |
Free-Claude-Code-Gateway/
├── src/
│ ├── server.ts # Express app entry point
│ ├── config/
│ │ ├── env.ts # Config parsing from env vars
│ │ └── models.ts # Model mapping loader + resolver
│ ├── middleware/
│ │ ├── auth.ts # PROXY_API_KEY bearer auth
│ │ ├── cors.ts # CORS config
│ │ ├── error-handler.ts # Express error handler + 404
│ │ ├── rate-limit.ts # Per-IP rate limiter
│ │ └── request-logger.ts # Request ID injection + Pino logging
│ ├── routes/
│ │ ├── health.routes.ts # GET /health, GET /
│ │ ├── models.routes.ts # GET /v1/models
│ │ ├── messages.routes.ts # POST /v1/messages (Claude endpoint)
│ │ └── chat-completions.routes.ts # POST /v1/chat/completions (OpenAI)
│ ├── services/
│ │ └── bluesminds.service.ts # Upstream HTTP client with retry
│ ├── converters/
│ │ ├── anthropic-to-openai.ts # Claude request → OpenAI request
│ │ ├── openai-to-anthropic.ts # OpenAI response → Claude response
│ │ └── errors.ts # Upstream error → Anthropic error
│ ├── types/
│ │ ├── anthropic.ts # Claude API types
│ │ ├── openai.ts # OpenAI API types
│ │ └── config.ts # ModelMappingConfig, FamilyRule
│ ├── utils/
│ │ ├── logger.ts # Pino logger with redaction
│ │ ├── redact.ts # Safe stringify + key redaction
│ │ ├── request-id.ts # X-Request-Id injection
│ │ └── timeout.ts # AbortController wrapper
│ └── admin/
│ ├── admin-state.ts # Wires all admin services
│ ├── persist.ts # JSON file persistence
│ ├── request-log.ts # Circular buffer + SSE subscribers
│ ├── request-log-middleware.ts # Captures response body for token count
│ ├── stats-engine.ts # Per-model stats + latency percentiles
│ ├── config-manager.ts # Runtime config with persistence
│ ├── model-registry.ts # Runtime model mappings with persistence
│ ├── connection-tester.ts # Sends real test request upstream
│ ├── middleware/
│ │ └── admin-auth.ts # HTTP Basic auth
│ └── routes/
│ └── admin-api.routes.ts # All admin REST endpoints
├── public/admin/
│ ├── index.html # Admin SPA (sidebar layout)
│ └── assets/
│ ├── dashboard.css # Light theme, Inter font, responsive
│ └── dashboard.js # Vanilla JS, Chart.js, SSE, command palette
├── config/
│ └── models.json # Default Claude → provider model mappings
├── tests/ # Node.js built-in test runner
├── assets/ # Images and diagrams for documentation
├── deploy/nginx/ # Nginx config for reverse proxy
├── .github/workflows/ci.yml # GitHub Actions CI (Node 20 + 22)
├── .env.example # Environment variable template
├── Dockerfile # Docker build
├── docker-compose.yml # Docker Compose with persistent volume
├── ecosystem.config.cjs # PM2 configuration
└── package.json
See CONTRIBUTING.md for the full guide.
Quick rules:
- Open an issue before starting any significant change.
- Keep PRs focused — one fix or feature per PR.
- Run
npm run typecheck && npm test && npm run buildbefore submitting. - Don't open Docker integration PRs.
See CHANGELOG.md.
MIT — see LICENSE for details.
This software is provided as-is for educational and personal use. The authors are not responsible for how it is used. Always comply with the terms of service of any AI provider you connect to this gateway.
Built with ❤️ by the open-source community.
If Claude Code works well for you — please support Anthropic and buy a subscription. It's the right thing to do.
⭐ Star this repo · 🐛 Report a Bug · 💡 Request a Feature · 💙 Buy Claude Code
This project is not affiliated with or endorsed by Anthropic. Claude® is a trademark of Anthropic, PBC.