A Claude Code API relay service based on Go + Gin with layered architecture design. Supports multi-account pool management, intelligent load balancing, API key distribution, usage statistics, and cost calculation. Includes a complete Vue 3 admin interface built with TDesign component library.
If this project helps you, please give me a ⭐️!

Please read carefully before using this project:
🚨 Terms of Service Risk: Using this project may violate Anthropic's Terms of Service. Please carefully read Anthropic's user agreement before use. All risks from using this project are borne by the user.
📖 Disclaimer: This project is for technical learning and research purposes only. The author assumes no responsibility for account bans, service interruptions, or other losses caused by using this project.
Share a Claude Code account with friends for cost-effective usage, or serve as multiple "car owners" providing services to different users.
Supports any account pool that complies with Claude Code API specifications, such as: GLM4.5, Qwen3-Code, and even some domestic relay mirror sites' Claude Code dedicated groups, enabling intelligent switching when accounts are rate-limited.
Also provides complete usage statistics and cost calculation, allowing you to clearly understand each account's usage and expenses, and set daily limits for each API Key.
Backend Services
Frontend Interface
/stats/api-key?api_key=sk-xxx)Backend Layered Structure
├── controller/ # HTTP request handling, parameter validation, response formatting ├── service/ # Core business logic, account scheduling, usage statistics ├── model/ # Data model definitions, GORM operations ├── middleware/ # Authentication, rate limiting, logging, CORS ├── relay/ # Claude API relay layer ├── common/ # Utility functions, cost calculation, JWT handling └── router/ # Route configuration
Frontend Project Structure
web/ ├── src/ │ ├── pages/ # Business page components │ ├── components/ # Common components │ ├── api/ # API request wrappers │ ├── store/ # Pinia state management │ ├── router/ # Vue Router configuration │ └── utils/ # Utility functions ├── package.json # Dependencies configuration └── vite.config.ts # Vite configuration
common.SysLog() and common.SysError()user := c.MustGet("user").(*model.User)go mod tidy after adding new dependencies<style scoped>@/utils/request wrapped axiosCore Data Tables
users - User accounts and role permissionsaccounts - Claude account pool and usage statisticsapi_keys - API key management and usage monitoringgroups - Group management and access controllogs - Model request log dataapi_logs - API request logs and statisticsOne-Click Full Service Deployment
# Start MySQL + Redis + Application
docker-compose -f docker-compose-all.yml up -d
# Check service status
docker-compose -f docker-compose-all.yml ps
# Access URLs
echo "Application URL: http://localhost:10081"
echo "Default admin: admin / admin123"
Using Existing Database
# Copy and edit environment variables
cp .env.example .env
# Start application
docker-compose up -d
Build Multi-Platform Versions
# Build using Makefile
make build
# Check build artifacts
ls out/
Production Environment Startup
# Set required environment variables
export SESSION_SECRET=$(openssl rand -base64 32)
export JWT_SECRET=$(openssl rand -base64 32)
export SALT=$(openssl rand -base64 16)
...
# Configure database
export MYSQL_HOST=your-host
export MYSQL_USER=your-user
export MYSQL_PASSWORD=your-password
...
# Start service (The frontend files for version v0.1.10 and higher have been packaged into the binary; simply open the service domain to access the homepage.)
./claude-code-relay
Using this service in Claude Code is very simple - just replace Claude Code's request address with this service address and key. Here are the specific steps:
# Configure API request address in Claude Code (HTTPS recommended)
export ANTHROPIC_BASE_URL=https://your-server-domain/claude-code
# Configure API key in Claude Code
export ANTHROPIC_AUTH_TOKEN="your-api-key"
Alternative method - create and configure Settings file: Create ~/.claude/settings.json file and configure your API key:
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "your-api-key-here",
"ANTHROPIC_BASE_URL": "https://your-server-domain/claude-code",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": 1
},
"permissions": {
"allow": [],
"deny": []
},
"apiKeyHelper": "echo 'your-api-key-here'"
}
For more detailed instructions, go to the admin panel, click "Help Documentation" in the top right corner, or directly visit the /help/index page for comprehensive usage tutorials.

Q: How to reset admin password? A: Delete the admin user record from the database, restart the service to automatically recreate the default admin.
Q: Which Claude models are supported? A: Supports all Claude models, including Claude-3.5 series. Cost calculation automatically adapts to different models.
Q: How to view account usage statistics? A: View detailed usage statistics and cost analysis through the frontend admin interface or API endpoints.
Q: Cannot access Claude official services normally? A: Claude and other foreign model service providers block domestic IP access. Use a proxy to resolve this (high-quality proxy IP recommended).
MIT License - Contributions and issues are welcome!