Skip to content

Anthropic Bridge - OpenRouter Proxy Service | Translate Anthropic API format to OpenAI format and route to OpenRouter for multi-model access

License

Notifications You must be signed in to change notification settings

marcodelpin/anthropic-bridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Anthropic Bridge - OpenRouter Proxy Service

Translation Service: Anthropic API format β†’ OpenAI format β†’ OpenRouter

Convert Anthropic's message format to OpenAI's chat completions format and route to OpenRouter for multi-model access.

πŸš€ Deployment Options

βœ… LXC Container (Proxmox) - RECOMMENDED FOR PRODUCTION

Status: βœ… ACTIVE - All 6 models verified working Documentation: docs/LXC_DEPLOYMENT.md

Quick Access:

# Health check
curl http://localhost:3000/health

# Test with Claude CLI
export ANTHROPIC_BASE_URL="http://localhost:3000"
claude --settings config/glm.json -p "Your query"

Service Management (on Proxmox host):

# Restart service
pct exec <container-id> -- systemctl restart anthropic-bridge

# View logs
pct exec <container-id> -- journalctl -u anthropic-bridge -f

🐳 Docker - WORKS WITH LIMITATIONS

Status: βœ… Container works internally, ⚠️ Network access from host may have IPv6 issues on WSL2 Documentation: docs/DOCKER_LXC_DEPLOYMENT.md

Deploy:

docker-compose up -d

Test from inside container:

docker exec anthropic-bridge curl http://localhost:3000/health

πŸ’» Native - DEVELOPMENT

Status: βœ… All 6 models verified working

Start:

./scripts/start-anthropic-bridge.sh

Or manually:

cd smart-router
export OPENROUTER_API_KEY="your-key-here"
node src/anthropic-bridge.js

🎯 Supported Models (6 Total)

All models verified working:

  1. GLM 4.6 Exacto - z-ai/glm-4.6:exacto
  2. Deepseek Chat - deepseek/deepseek-chat
  3. Qwen 2.5 Coder 32B - qwen/qwen-2.5-coder-32b-instruct
  4. GPT-4o - openai/gpt-4o
  5. Claude Sonnet 4 - anthropic/claude-sonnet-4
  6. Gemini 2.5 Pro - google/gemini-2.5-pro-preview

πŸ“ Project Structure

smart-router/
β”œβ”€β”€ src/
β”‚   └── anthropic-bridge.js         # Main service (Anthropic to OpenAI translator)
β”œβ”€β”€ config/                          # Claude CLI configuration files
β”‚   β”œβ”€β”€ glm.json                    # GLM 4.6 Exacto
β”‚   β”œβ”€β”€ deepseek-v3.1-terminus.json # Deepseek Chat
β”‚   β”œβ”€β”€ qwen3-coder-plus.json       # Qwen 2.5 Coder 32B
β”‚   β”œβ”€β”€ gpt-5-pro.json              # GPT-4o
β”‚   β”œβ”€β”€ claude-sonnet-4.5.json      # Claude Sonnet 4
β”‚   └── gemini-2.5-pro.json         # Gemini 2.5 Pro
β”œβ”€β”€ scripts/
β”‚   └── start-anthropic-bridge.sh   # Native startup script
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ LXC_DEPLOYMENT.md           # LXC production deployment (RECOMMENDED)
β”‚   β”œβ”€β”€ DOCKER_LXC_DEPLOYMENT.md    # Docker deployment guide
β”‚   └── CLI_TESTING.md              # Claude CLI testing guide
β”œβ”€β”€ .env                             # OpenRouter API key
β”œβ”€β”€ package.json
└── README.md

πŸ”§ Configuration

Environment Variables

Required:

Optional:

  • PORT - Server port (default: 3000)
  • NODE_ENV - Environment (development/production)

Claude CLI Configuration

Each model has a configuration file in config/ directory:

{
  "env": {
    "ANTHROPIC_BASE_URL": "http://localhost:3000",
    "ANTHROPIC_MODEL": "z-ai/glm-4.6:exacto"
  },
  "model": "z-ai/glm-4.6:exacto"
}

Usage:

# Use GLM 4.6
claude --settings config/glm.json -p "Your query"

# Use Deepseek
claude --settings config/deepseek-v3.1-terminus.json -p "Your query"

# Use Claude Sonnet 4
claude --settings config/claude-sonnet-4.5.json -p "Your query"

πŸ“Š Service Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     Anthropic      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     OpenAI       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Claude CLI  │────────────────────▢│ anthropic-bridge │──────────────────▢│ OpenRouter β”‚
β”‚             β”‚   Format Request   β”‚ (Translation)     β”‚   Format Request β”‚            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                            β”‚
                                            β–Ό
                                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                    β”‚ Model Router β”‚
                                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                            β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β–Ό                       β–Ό                       β–Ό
                β”Œβ”€β”€β”€β”€β”€β”               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚ GLM β”‚               β”‚ Deepseek β”‚            β”‚ Claude   β”‚
                β”‚GPT-4β”‚               β”‚ Qwen     β”‚            β”‚ Gemini   β”‚
                β””β”€β”€β”€β”€β”€β”˜               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ˆ Monitoring

Service Logs (LXC)

# Real-time logs
pct exec <container-id> -- journalctl -u anthropic-bridge -f

# Last 50 lines
pct exec <container-id> -- journalctl -u anthropic-bridge -n 50

# Follow routing activity
pct exec <container-id> -- journalctl -u anthropic-bridge -f | grep -E 'Forwarding|Response'

Health Check

curl http://localhost:3000/health

Expected response:

{
  "status": "healthy",
  "service": "Smart Router",
  "provider": "OpenRouter",
  "mode": "anthropic-to-openai-translator"
}

πŸ” Security

  • API key stored in .env file (not committed to git)
  • Service runs in isolated container
  • Unprivileged container (non-root user namespace)
  • Internal network only (no external exposure by default)

πŸ“ License

MIT

πŸ‘€ Author

Marco Del Pin - marco.delpin@gmail.com

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Status: βœ… PRODUCTION READY - All 6 models operational Last Updated: 2025-11-06

About

Anthropic Bridge - OpenRouter Proxy Service | Translate Anthropic API format to OpenAI format and route to OpenRouter for multi-model access

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors