Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

AgentRouter Proxy — Free AI API Gateway

Use Claude Opus 5, GPT-5.6 Sol and more with $175+ free credits.
One API key. Works with Cline, Cursor, Claude Code CLI and more.


What Is This?

AgentRouter is a free API gateway that unifies multiple AI providers (Anthropic, OpenAI, DeepSeek, etc.) behind a single endpoint. You get $125 welcome bonus on sign-up + $25 daily just for logging in.

The catch: AgentRouter uses a WAF (Web Application Firewall) that blocks requests from unauthorized clients. This proxy solves that.

This repo includes:

File Purpose
agentrouter_proxy.py Main proxy — WAF bypass, auto-retry, streaming, live dashboard
format_bridge.py Anthropic ↔ OpenAI format translation (enables GPT models)

Features

  • WAF Bypass — Automatic header masking to pass through AgentRouter's firewall
  • Dual Format Support — Use both Claude and GPT models from the same client
  • Bridge Mode — Translates Anthropic-format requests to OpenAI format (and back)
  • Smart Text Bypass — Evades content filters via Cyrillic character substitution without breaking Russian text
  • Live Dashboard — Monitor requests, model usage, and logs from your browser
  • Auto Retry — Automatically retries on 502/503/504 gateway errors
  • SSE Streaming — Responses arrive chunk-by-chunk with zero buffering
  • Tool Call Support — Full function calling compatibility

Quick Start

1. Sign Up for AgentRouter

Go to agentrouter.org/register and sign in with your GitHub account.

You'll receive $125 bonus instantly. Log in daily for an extra +$25.

After signing up, go to API KeysCreate Key → copy your token (starts with sk-...).

2. Requirements

  • Python 3.10+ (pre-installed on macOS)
  • Node.js 18+ (for Cline / Claude Code)
  • VS Code + Cline extension

Install Python dependencies:

pip3 install fastapi uvicorn httpx

3. Clone the Repo

git clone https://github.com/justbiar/agent-router.git
cd agent-router

Or download manually — just make sure both .py files are in the same folder.

4. Start the Proxy

python3 agentrouter_proxy.py

You should see:

Proxy started: http://127.0.0.1:8318 → https://agentrouter.org
Bridge: gpt-5.6-sol | WAF bypass: on | Dashboard: http://127.0.0.1:8318/dashboard

Keep this terminal open! The proxy needs to stay running.

5. Open the Dashboard

Visit http://127.0.0.1:8318/dashboard in your browser.

You'll see:

  • Total request count
  • Success / failure rates
  • Model usage breakdown
  • Live log stream (real-time via WebSocket)

Client Setup

Cline / Roo Code (VS Code) — Recommended

  1. Install the Cline extension in VS Code
  2. Open Cline panel → ⚙️ Settings
  3. Enter these values:
Field Value
API Provider Anthropic
API Key sk-... (your AgentRouter key)
Use custom base URL ✅ check
Base URL http://127.0.0.1:8318
Model claude-opus-5 or claude-opus-4-8

Tip: If you can't find the model in the dropdown, type it manually.


Claude Code CLI

Set environment variables in your terminal:

macOS / Linux:

# Add to ~/.zshrc or ~/.bashrc:
export ANTHROPIC_BASE_URL="http://127.0.0.1:8318"
export ANTHROPIC_API_KEY="sk-YOUR_KEY"
export ANTHROPIC_AUTH_TOKEN="sk-YOUR_KEY"

Restart your terminal, then run:

claude

Windows (PowerShell):

[System.Environment]::SetEnvironmentVariable('ANTHROPIC_BASE_URL', 'http://127.0.0.1:8318', 'User')
[System.Environment]::SetEnvironmentVariable('ANTHROPIC_API_KEY', 'sk-YOUR_KEY', 'User')
[System.Environment]::SetEnvironmentVariable('ANTHROPIC_AUTH_TOKEN', 'sk-YOUR_KEY', 'User')

If you get "Not logged in" error:

New-Item -ItemType Directory -Force -Path "$HOME\.claude"
Set-Content -Path "$HOME\.claude\.credentials.json" -Value '{"hasCompletedOnboarding": true}'

Cursor IDE

  1. SettingsModels
  2. Disable Cursor Tab
  3. Enable Override Base URLhttp://127.0.0.1:8318
  4. Enter your API key and save

VS Code Claude Code Extension

Cmd/Ctrl+Shift+POpen User Settings (JSON) → add:

{
  "claudeCode.environmentVariables": [
    { "name": "ANTHROPIC_AUTH_TOKEN", "value": "sk-YOUR_KEY" },
    { "name": "ANTHROPIC_BASE_URL", "value": "http://127.0.0.1:8318" },
    { "name": "ANTHROPIC_MODEL", "value": "claude-opus-5" }
  ],
  "claudeCode.disableLoginPrompt": true
}

OpenCode

Want to use these models inside OpenCode? There's a full, beginner-friendly, step-by-step guide here:

📖 OpenCode Setup Guide → OPENCODE.md

This fork also includes SSE compatibility fixes for OpenCode: it filters malformed data: null chunks that OpenCode's AI SDK rejects, and auto-corrects a missing /v1 prefix in the base URL — so the stream always arrives clean.



Available Models

Model Provider Pricing (Input / Output)
claude-opus-5 Anthropic $5 / $25 per M tokens
claude-opus-4-8 Anthropic Higher
claude-sonnet-4-20250514 Anthropic Lower
gpt-5.6-sol OpenAI (via bridge) Varies

With bridge mode enabled, you can use GPT models from any Anthropic-compatible client.


Environment Variables

Customize proxy behavior with these environment variables:

Variable Default Description
AGENTROUTER_UPSTREAM https://agentrouter.org Upstream server URL
AGENTROUTER_HOST 127.0.0.1 Listen address
AGENTROUTER_PORT 8318 Listen port
AGENTROUTER_BRIDGE true Bridge mode (GPT support)
AGENTROUTER_BRIDGE_MODEL gpt-5.6-sol Bridge target model
AGENTROUTER_MODEL (empty) Force a specific model for all requests
AGENTROUTER_WAF true WAF text bypass
AGENTROUTER_RETRY true Auto retry on gateway errors
AGENTROUTER_RETRY_MAX 2 Max retry attempts
AGENTROUTER_LOGLEVEL INFO Log level

Example: Force claude-opus-5 for all requests:

AGENTROUTER_MODEL=claude-opus-5 python3 agentrouter_proxy.py

Example: Disable bridge mode (Claude models only):

AGENTROUTER_BRIDGE=false python3 agentrouter_proxy.py

Troubleshooting

Q: python command not found? Use python3 on macOS. Use pip3 instead of pip.

Q: format_bridge.py not found warning? Make sure both files are in the same folder. Without the bridge, only Claude models work — GPT models won't.

Q: 401 Unauthorized error? Check your API key. Generate a new one from the AgentRouter dashboard.

Q: Connection drops? Make sure the proxy terminal is still open. Restart with python3 agentrouter_proxy.py if you closed it.

Q: Is it safe? The proxy runs on localhost only — it's not accessible from outside. However, all requests pass through AgentRouter's servers — don't use it for sensitive or NDA-protected code.


Get Free Credits

agentrouter.org/register — Sign in with GitHub, get $125 instantly. +$25 daily login bonus.


License

MIT — Use it, modify it, share it. Free forever.

About

No description, website, or topics provided.

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages