About this project
# One API
Access all large language models through the standard OpenAI API format, ready to use out of the box.
## Supported Models and Channels
- OpenAI ChatGPT series (including Azure OpenAI)
- Anthropic Claude series (including AWS Claude)
- Google PaLM2 / Gemini series
- Mistral series
- ByteDance Doubao (Volcengine)
- Baidu Wenxin Yiyan
- Alibaba Tongyi Qianwen
- iFlytek Spark
- Zhipu ChatGLM
- 360 Brain
- Tencent Hunyuan
- Moonshot AI, Baichuan, MINIMAX, DeepSeek
- Groq, Ollama, Zero One Everything, StepFun, Coze
- Cohere, Cloudflare Workers AI, together.ai, novita.ai
- SiliconCloud, xAI, DeepL, and others
## Core Features
1. **Unified API Adaptation**: All channels expose interfaces in OpenAI-compatible format; callers can switch models without modifying code.
2. **Load Balancing**: Supports multi-channel routing with automatic request allocation based on group multipliers.
3. **Token Management**: Set expiration time, quota limits, allowed IP ranges, and model lists for each access token.
4. **Channel Management**: Batch create and manage multiple downstream channels with independent model configurations.
5. **User Grouping**: Different user groups can be configured with different multipliers and permissions.
6. **Redeem Codes**: Batch generate and export redeem codes for account top-ups.
7. **Automatic Retry on Failure**: When an upstream channel fails, automatically switch to another available channel.
8. **Image Generation Interface**: Supports image generation interface relay.
9. **Invite Rewards**: Supports user invitation mechanisms.
10. **Multi-Node Deployment**: Supports master/slave distributed deployment with Redis for cache synchronization.
11. **Customization**: Supports custom system name, logo, footer, homepage, and about page.
12. **Login Methods**: Supports email registration, Feishu authorization, GitHub authorization, and WeChat Official Account authorization.
13. **Cloudflare AI Gateway**: Can directly connect to Cloudflare AI Gateway.
14. **Theme Switching**: Supports UI theme changes.
## Deployment Methods
### Docker Deployment (Recommended)
```
# SQLite mode
docker run --name one-api -d --restart always -p 3000:3000 \
-e TZ=Asia/Shanghai -v /home/ubuntu/data/one-api:/data \
justsong/one-api
# MySQL mode
docker run --name one-api -d --restart always -p 3000:3000 \
-e SQL_DSN="root:123456@tcp(localhost:3306)/oneapi" \
-e TZ=Asia/Shanghai -v /home/ubuntu/data/one-api:/data \
justsong/one-api
```
Initial account: username `root`, password `123456`.
### Docker Compose Deployment
```
docker-compose up -d
```
Data is stored in the `./data/mysql` directory.
### Manual Deployment
```
git clone https://github.com/songquanpeng/one-api.git
cd one-api/web/default && npm install && npm run build
cd ../.. && go mod download && go build -ldflags "-s -w" -o one-api
./one-api --port 3000 --log-dir ./logs
```
### Third-Party Platforms
Supports one-click deployment on Sealos, Zeabur, Render, and is compatible with Baota panel.
## Usage
1. Add API keys for each model on the "Channels" page.
2. Create access tokens for specified users on the "Tokens" page.
3. Set the API Base to the One API address (e.g., `https://your-domain/v1`) and the API Key to the generated token in your client.
To specify a channel, append `-CHANNEL_ID` to the token, e.g.: `Authorization: Bearer ONE_API_KEY-1`.
## Key Environment Variables
| Variable | Description |
|---|---|
| `REDIS_CONN_STRING` | Enable Redis cache |
| `SESSION_SECRET` | Fixed session key to maintain login state across restarts |
| `SQL_DSN` | Use MySQL/PostgreSQL instead of SQLite |
| `SYNC_FREQUENCY` | Cache sync frequency in seconds, recommended for multi-node deployment |
| `NODE_TYPE` | `master` or `slave`, for multi-node deployment |
| `FRONTEND_BASE_URL` | Redirect frontend requests from the server |
| `INITIAL_ROOT_TOKEN` | Automatically create root token on first launch |
## Open Source License
MIT license, requires retaining attribution and a link to this project at the bottom of the page.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.