Managing API keys across a dozen different AI providers is chaotic. One API simplifies the process. It is a lightweight distribution system that utilizes the standard OpenAI API format while routing requests to over a hundred models—ranging from Claude and Gemini to DeepSeek and Qwen. This provides a single endpoint, a unified token system, and a centralized dashboard to track your usage and spending.
The platform supports an extensive list of providers, including:
If a service offers an API, One API can likely integrate with it.
THEME variable.For SQLite:
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
For MySQL:
Add -e SQL_DSN="root:123456@tcp(localhost:3306)/oneapi" to the command and adjust the connection string to match your database credentials.
If you encounter issues pulling the image, use the GitHub Container Registry mirror: ghcr.io/songquanpeng/one-api.
To update the container:
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower -cR
server{
server_name openai.justsong.cn;
location / {
client_max_body_size 64m;
proxy_http_version 1.1;
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_cache_bypass $http_upgrade;
proxy_set_header Accept-Encoding gzip;
proxy_read_timeout 300s;
}
}
After configuring Nginx, secure your instance with Let's Encrypt:
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot --nginx
sudo service nginx restart
The initial login credentials are root and 123456. You should change these immediately upon first login.
Docker tab and install the Docker service if prompted.One-API in the App Store, click install, and configure your domain name.docker-compose up -d
docker-compose ps
Persistent data will be stored in ./data/mysql.
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
To run the binary:
chmod u+x one-api
./one-api --port 3000 --log-dir ./logs
SESSION_SECRET.SQL_DSN.NODE_TYPE=slave on all secondary servers.SYNC_FREQUENCY to reduce database load.FRONTEND_BASE_URL on slave nodes to the primary server.REDIS_CONN_STRING on each node.PORT and SQL_DSN environment variables, and deploy.One API works with most OpenAI-compatible clients:
ChatGPT Next Web:
docker run --name chat-next-web -d -p 3001:3000 yidadaa/chatgpt-next-web
Input your One API address (e.g., https://openai.justsong.cn) and your generated token in the settings.
ChatGPT Web:
docker run --name chatgpt-web -d -p 3002:3002 -e OPENAI_API_BASE_URL=https://openai.justsong.cn -e OPENAI_API_KEY=sk-xxx chenzhaoyu94/chatgpt-web
QChatGPT (QQ Bot):
Modify data/provider.json, set requester.openai-chat-completions.base-url to your One API instance, and input your token under keys.openai.
Create a .env file from the provided .env.example. Essential variables include:
REDIS_CONN_STRING: Enables Redis for caching.SESSION_SECRET: Ensures user sessions remain valid after service restarts.SQL_DSN: Configures the connection for MySQL or PostgreSQL instead of the default SQLite.Useful command-line flags include --port, --log-dir, --version, and --help.
https://your-domain.com and use your One API token as the API key.To route a request to a specific channel, append the channel ID to your token: Authorization: Bearer YOUR_TOKEN-CHANNEL_ID. (Note: This is restricted to admin-created tokens.)
invalid character '<': This usually indicates that the IP address or proxy is being blocked by Cloudflare's security layers.BASE_URL incorrectly. Verify your API address and ensure you are using the correct protocol (HTTPS vs. HTTP).one-api.db. MySQL users are generally unaffected by container updates.ability table. These records must be cleared manually from the database.One API transforms a fragmented collection of AI subscriptions into a single, manageable interface. Once configured, you can add keys as needed and stop juggling multiple endpoints.
Sora 2 AI Watermark Remover: Remove Sora Watermarks Cleanly
Akaunting Review: Free Open-Source Accounting Software for Small Business
OpenCut: Free, Open-Source Video Editor (No Watermark, No Subscription)
NetBird Setup Guide: Building a WireGuard Mesh VPN
ERPNext Open Source ERP: Installation Guide for Accounting and Inventory
Chatterbox TTS API: Open Source Text-to-Speech for Developers
How to Install and Use Vosk Offline Speech Recognition
BiliNote: Convert YouTube and Bilibili Videos Into Markdown Notes
Nping: A High-Performance Concurrent Ping Tool in Rust with Live Charts
Cuby Text: Open-Source Block-Based Knowledge Management
Wasteland SLG Guide: Survival Tips & Alliance Strategy
IOPaint: Free Open-Source Image Inpainting and Object Removal