{"id":31580974,"url":"https://github.com/jodagreyhame/claude-code-proxy","last_synced_at":"2025-10-05T21:51:48.595Z","repository":{"id":317834213,"uuid":"1068554326","full_name":"jodagreyhame/claude-code-proxy","owner":"jodagreyhame","description":"Weekly rate limits? Resolved! Route each Claude Code model tier to different providers. Use GLM for Haiku/Opus, Gemini for alternatives, and keep Sonnet on your Claude subscription - all at the same time.","archived":false,"fork":false,"pushed_at":"2025-10-03T10:39:39.000Z","size":30,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-03T11:37:36.078Z","etag":null,"topics":["claude","claude-code","gemini","glm","proxy","rate-limits"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jodagreyhame.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-02T14:58:38.000Z","updated_at":"2025-10-03T10:39:42.000Z","dependencies_parsed_at":"2025-10-03T11:37:39.028Z","dependency_job_id":"5d904bc1-d276-4b17-b650-3403b066d813","html_url":"https://github.com/jodagreyhame/claude-code-proxy","commit_stats":null,"previous_names":["jodagreyhame/claude-code-proxy"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/jodagreyhame/claude-code-proxy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jodagreyhame%2Fclaude-code-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jodagreyhame%2Fclaude-code-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jodagreyhame%2Fclaude-code-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jodagreyhame%2Fclaude-code-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jodagreyhame","download_url":"https://codeload.github.com/jodagreyhame/claude-code-proxy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jodagreyhame%2Fclaude-code-proxy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278526242,"owners_count":26001325,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["claude","claude-code","gemini","glm","proxy","rate-limits"],"created_at":"2025-10-05T21:51:43.915Z","updated_at":"2025-10-05T21:51:48.588Z","avatar_url":"https://github.com/jodagreyhame.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Claude Code Proxy: Weekly Rate Limits? Resolved!\n\nRoute **each Claude Code model tier** to **different providers**! Use [GLM](https://z.ai/subscribe?ic=CAO6LGU9S1) for Haiku/Opus and keep Sonnet on your [Claude](https://claude.ai/) subscription - all at the same time.\n\n## Why This Exists\n\nApparently I'm one of the \"2%\" of users that should encounter or be affected by Anthropic's new weekly limits. So I built this proxy to route certain models to LLM providers of your choice - welcome to the good ol days when we didn't need to worry about hitting our weekly limit. These models work with agents too!\n\n## Key Features\n\n- ✨ **3 independent providers** - Route Haiku, Opus, and Sonnet to different APIs simultaneously\n- 🔄 **Mix and match** - GLM for speed/cost, Claude for premium\n- 💰 **Cost optimized** - Route cheap tasks to alternatives, premium to Claude\n- 🔐 **OAuth preserved** - Keep your Claude subscription active for Sonnet\n- 🎯 **Dead simple** - Each tier configured with just 2 environment variables\n- 🌐 **Cross-platform** - Works on macOS, Linux, and Windows\n\n## What It Does\n\n```\nClaude Code UI          Proxy Routes To\n─────────────────       ───────────────────────────────\nHaiku  (glm-4.6)        → GLM API\nOpus   (glm-4.5-air)    → GLM API\nSonnet (claude-sonnet)  → Real Anthropic (OAuth)\n```\n\n## How It Works\n\nThe proxy intercepts Claude Code's API requests:\n\n1. **You set:** `ANTHROPIC_BASE_URL=http://localhost:8082`\n2. **Claude Code sends requests to:** `localhost:8082` instead of `api.anthropic.com`\n3. **Proxy checks model name:**\n   - `glm-4.6` → Routes to GLM (HAIKU_PROVIDER_BASE_URL)\n   - `glm-4.5-air` → Routes to GLM (OPUS_PROVIDER_BASE_URL)\n   - `claude-sonnet-4-5` → Routes to real Anthropic (OAuth passthrough)\n\n## Quick Start\n\n**macOS/Linux:**\n```bash\n# 1. Install dependencies\npip install -r requirements.txt\n\n# 2. Configure providers - Create .env file with:\ncat \u003e .env \u003c\u003c 'EOF'\n# Provider configurations\nHAIKU_PROVIDER_API_KEY=sk-glm-xxx\nHAIKU_PROVIDER_BASE_URL=https://api.z.ai/api/anthropic\n\nOPUS_PROVIDER_API_KEY=sk-glm-xxx\nOPUS_PROVIDER_BASE_URL=https://api.z.ai/api/anthropic\n\n# Sonnet uses OAuth (leave commented)\n# SONNET_PROVIDER_API_KEY=\n# SONNET_PROVIDER_BASE_URL=\n\n# Model name configuration\nANTHROPIC_DEFAULT_HAIKU_MODEL=glm-4.6\nANTHROPIC_DEFAULT_OPUS_MODEL=glm-4.5-air\nEOF\n\n# 3. Configure Claude Code (add to ~/.zshrc or ~/.bashrc)\nexport ANTHROPIC_BASE_URL=http://localhost:8082  # ⚠️ CRITICAL\n\n# 4. Start proxy \u0026 use Claude Code\npython proxy.py \u0026\nclaude\n```\n\n**Windows (PowerShell):**\n```powershell\n# 1. Install dependencies\npip install -r requirements.txt\n\n# 2. Configure providers - Create .env file with:\n@\"\n# Provider configurations\nHAIKU_PROVIDER_API_KEY=sk-glm-xxx\nHAIKU_PROVIDER_BASE_URL=https://api.z.ai/api/anthropic\n\nOPUS_PROVIDER_API_KEY=sk-glm-xxx\nOPUS_PROVIDER_BASE_URL=https://api.z.ai/api/anthropic\n\n# Sonnet uses OAuth (leave commented)\n# SONNET_PROVIDER_API_KEY=\n# SONNET_PROVIDER_BASE_URL=\n\n# Model name configuration\nANTHROPIC_DEFAULT_HAIKU_MODEL=glm-4.6\nANTHROPIC_DEFAULT_OPUS_MODEL=glm-4.5-air\n\"@ | Out-File -FilePath .env -Encoding utf8\n\n# 3. Configure Claude Code (add to PowerShell $PROFILE)\n$env:ANTHROPIC_BASE_URL = \"http://localhost:8082\"  # ⚠️ CRITICAL\n\n# 4. Start proxy \u0026 use Claude Code\nStart-Process python -ArgumentList \"proxy.py\" -WindowStyle Hidden\nclaude\n```\n\n**What goes where:**\n- **`.env` file** → Provider configs + model name mappings (read by proxy)\n- **Shell env vars** → Only `ANTHROPIC_BASE_URL` pointing to localhost:8082\n\n## Supported Providers\n\n- **[GLM](https://z.ai/subscribe?ic=CAO6LGU9S1)** (via Z.AI) - Fast, cheap Chinese models\n- **[Claude](https://claude.ai/)** - Premium Anthropic models via OAuth\n- **Any Anthropic-compatible API** - Works with any provider supporting `/v1/messages`\n\n## Use Cases\n\n```bash\nHaiku  → GLM (glm-4.6)      # $0.02/1M tokens\nOpus   → GLM (glm-4.5-air)  # $0.01/1M tokens\nSonnet → Claude (real)      # Your subscription\n```\n\n## Benefits\n\n| Benefit | Description |\n|---------|-------------|\n| ✅ **Keep your Claude subscription** | Uses OAuth, no API key needed |\n| ✅ **3 providers simultaneously** | Different provider for each tier |\n| ✅ **Native Claude Code support** | Uses built-in environment variables |\n| ✅ **Update-proof** | No SDK modifications, survives updates |\n| ✅ **Transparent** | `/model` command shows actual routed model names |\n| ✅ **Simple** | Just environment variables, no complex config |\n\n## Requirements\n\n- Python 3.8+\n- Claude Code installed globally\n- Provider(s) with Anthropic-compatible API\n\n## Using with Agents\n\nAgents automatically use your configured models:\n\n```yaml\n---\nname: my-agent\nmodel: haiku  # Uses glm-4.6 (your ANTHROPIC_DEFAULT_HAIKU_MODEL)\n---\n```\n\n## API Endpoint Support\n\nThe proxy implements the following Anthropic API endpoints:\n\n| Endpoint | GLM Providers | Real Anthropic | Notes |\n|----------|--------------|----------------|-------|\n| `POST /v1/messages` | ✅ Full support | ✅ Full support | Main chat completion endpoint |\n| `POST /v1/messages/count_tokens` | ⚠️ Returns 501 | ✅ Full support | Token counting before sending. GLM doesn't support this - use token counts from message responses instead |\n| `GET /health` | ✅ Proxy health | ✅ Proxy health | Proxy status endpoint (not forwarded to providers) |\n\n**About Token Counting:**\n- **Sonnet (Real Anthropic)**: Token counting works normally via `/v1/messages/count_tokens`\n- **Haiku/Opus (GLM)**: Token counting returns HTTP 501 with a helpful message. Token usage is still available in every `/v1/messages` response under the `usage` field.\n\n## Troubleshooting\n\n**Proxy not intercepting requests?**\n\nmacOS/Linux:\n```bash\necho $ANTHROPIC_BASE_URL  # Should output: http://localhost:8082\n# If empty: export ANTHROPIC_BASE_URL=http://localhost:8082\n```\n\nWindows:\n```powershell\necho $env:ANTHROPIC_BASE_URL  # Should output: http://localhost:8082\n# If empty: $env:ANTHROPIC_BASE_URL = \"http://localhost:8082\"\n```\n\n**Check if proxy is running:**\n```bash\ncurl http://localhost:8082/health\n```\n\nExpected response:\n```json\n{\n  \"status\": \"healthy\",\n  \"haiku\": {\"model\": \"glm-4.6\", \"provider_set\": true},\n  \"opus\": {\"model\": \"glm-4.5-air\", \"provider_set\": true},\n  \"sonnet\": {\"uses_oauth\": true}\n}\n```\n\n**Models not routing correctly?**\n- Verify model names in `.env` match `ANTHROPIC_DEFAULT_*_MODEL` vars\n- Check proxy logs for routing info\n- Test provider API keys directly with `curl`\n\n**Sonnet OAuth not working?**\n```bash\nclaude --login  # Refresh your Claude session\n```\n\n## License\n\nMIT\n\n---","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjodagreyhame%2Fclaude-code-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjodagreyhame%2Fclaude-code-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjodagreyhame%2Fclaude-code-proxy/lists"}