File size: 6,625 Bytes
287fb04 bc0b11f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | ---
title: AnumaAI
colorFrom: blue
colorTo: purple
sdk: docker
pinned: false
license: mit
---
# Anuma 2API Gateway
[ไธญๆๆๆกฃ](README_CN.md)
A self-hosted gateway that provides OpenAI/Anthropic-compatible APIs backed by [Anuma AI](https://anuma.ai) accounts. Includes automated account registration via temporary email, account pool management, and a load-balanced API server with automatic failover.
> **Credits**: Temporary email service is powered by [ๅฐ่พฃๆค็ไธดๆถ้ฎ็ฎฑ](https://vip.215.im) (vip.215.im) โ a fast, reliable temp mail API with generous free tier.
## Features
- **Batch Account Registration** โ Automated signup using temporary email, Privy authentication, and embedded wallet creation. Web UI for monitoring progress.
- **OpenAI & Anthropic Compatible** โ Works with Claude Code, Cherry Studio, ChatBox, and any client that speaks the OpenAI or Anthropic API protocol.
- **Smart Load Balancing** โ Round-robin across available accounts. Automatically disables accounts that run out of credits or have expired tokens.
- **Token Auto-Refresh** โ Proactively refreshes JWT identity tokens before expiry. Background daemon keeps the account pool healthy.
- **Streaming Support** โ Full SSE streaming for both OpenAI and Anthropic response formats.
- **Tool Use** โ Translates tool-call requests for Claude Code compatibility.
- **SOCKS5 Proxy** โ Optional proxy support for environments that need it.
## Architecture
```
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ AI Client โโโโโโถโ api_server.py โโโโโโถโ Anuma API โ
โ (Claude Code,โ โ (FastAPI :7895) โ โ portal.anumaโ
โ Cherry St.) โ โโโโโโโโโโฌโโโโโโโโโโ โโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโ โ
โ reads
โผ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ
โ Web UI โโโโโโถโ privy_manager.py โ
โ (Flask) โ โ (Flask :7894) โ
โโโโโโโโโโโโโโโโ โโโโโโโโโโฌโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ
โ anuma_client.py โโโโโโถโ ๅฐ่พฃๆค ไธดๆถ้ฎ็ฎฑ โ
โ (SDK) โ โ (vip.215.im) โ
โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ
```
## Project Structure
```
โโโ src/
โ โโโ config.py # Configuration from environment variables
โ โโโ anuma_client.py # SDK: Privy auth, Anuma chat, temp mail
โ โโโ privy_manager.py # Web UI + batch registration engine
โ โโโ api_server.py # FastAPI gateway (OpenAI/Anthropic)
โโโ templates/
โ โโโ index.html # Web dashboard
โโโ docs/
โ โโโ yyds.txt # Mail API reference
โโโ docker-compose.yml
โโโ Dockerfile
โโโ requirements.txt
โโโ .env.example
โโโ LICENSE
```
## Quick Start
### 1. Prerequisites
- Python 3.10+
- A mail API key from [ๅฐ่พฃๆคไธดๆถ้ฎ็ฎฑ](https://vip.215.im)
- Optional: SOCKS5 proxy if Anuma is blocked in your region
### 2. Configuration
```bash
cp .env.example .env
# Edit .env and fill in your MAIL_API_KEY
```
Required: `MAIL_API_KEY` โ your temp mail API key from vip.215.im.
Optional: `SOCKS5_PROXY` โ proxy string for API requests.
### 3. Install
```bash
pip install -r requirements.txt
```
### 4. Start the Registration Manager (Web UI)
```bash
python3 src/privy_manager.py
```
Open http://localhost:7894 โ configure registration count, concurrency, and click "Start" to batch-register accounts.
### 5. Start the API Gateway
```bash
python3 src/api_server.py
```
The gateway runs on `http://localhost:7895/v1` by default (configurable via `API_PORT`).
### 6. Connect Your Client
**Claude Code:**
```bash
export ANTHROPIC_BASE_URL=http://localhost:7895/v1
export ANTHROPIC_API_KEY=sk-no-auth-needed
claude
```
**Cherry Studio:**
Add an OpenAI-compatible provider with:
- Base URL: `http://localhost:7895/v1`
- API Key: any value (not validated)
## API Endpoints
### `GET /v1/models`
Returns available model list.
### `POST /v1/chat/completions`
OpenAI-compatible chat completions. Supports streaming.
### `POST /v1/messages`
Anthropic-compatible messages endpoint. Supports streaming and tool use.
### Model Mapping
| Client model name | Anuma upstream |
|-------------------|----------------|
| `gpt-5.4` | `openai/gpt-5.4` |
| `gpt-4` | `openai/gpt-4` |
| `claude-opus` / `claude-3-7` | `anthropic/claude-opus-4-7` |
| `claude-sonnet` | `anthropic/claude-sonnet-4-6` |
## Docker Deployment
```bash
# Build and start
docker compose up -d
# View logs
docker compose logs -f api-server
```
Both services share a SQLite database mounted at `./data`. Create a `.env` file before starting.
## Environment Variables
A complete reference is in [`.env.example`](.env.example).
| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| `MAIL_API_KEY` | **Yes** | โ | Mail API key from vip.215.im |
| `MAIL_API_BASE_URL` | No | `https://maliapi.215.im/v1` | Custom mail API URL |
| `SOCKS5_PROXY` | No | โ | SOCKS5 proxy for upstream requests |
| `DB_PATH` | No | `./privy_manager.db` | SQLite database path |
| `MANAGER_PORT` | No | `7894` | Web UI port |
| `API_PORT` | No | `7895` | API gateway port |
| `API_HOST` | No | `0.0.0.0` | API bind address |
| `DEFAULT_TOTAL` | No | `10` | Default registration batch size |
| `DEFAULT_CONCURRENCY` | No | `3` | Default concurrent threads |
## Notes
1. Recommended concurrency: 2-3. Higher values may trigger rate limits or IP blocks.
2. The gateway automatically disables accounts with zero credits or expired tokens.
3. Token refresh happens both proactively (before requests) and via a background daemon (every 10 minutes).
4. The `identity_token` is session-critical โ the client handles complex token exchange logic internally.
## License
[MIT](LICENSE) |