General Introduction
One API is an open source interface management and distribution system that supports a variety of big models like OpenAI ChatGPT, Anthropic Claude, Google PaLM 2 & Gemini etc. The system accesses all big models through the standard OpenAI API format, providing load balancing, token management, redemption code management, channel management and other functions. Users can quickly deploy and utilize One API out-of-the-box via Docker.
New API A secondary development version based on One API with support for Midjourney. support for payments and per-model-use charges.
one api branch: changed from songquanpeng/one-api. support more models, add statistics page, improve function call for non-openai models.
Function List
- API interfaces to access and manage multiple big models: Azure, OpenAI ChatGPT, Anthropic Claude, Google PaLM 2 & Gemini, etc.
- Provide load balancing function to support multiple channels of access
- Single API to integrate different language model interfaces
- Token Management: Set token expiration time, amount, allowed IP ranges, and model access rights
- Redemption code management: batch generate and export redemption codes to top up accounts
- Channel management: batch create channels, set up model lists
- User grouping and channel grouping management
- View limit details and user invitation rewards
- Support for mapping interfaces and Cloudflare AI Gateway
- Customize system name, logo and footer
- Support multiple user login registration methods: email, Flybook, GitHub, WeChat public number
- Docker image support for one-click deployment
Using Help
Installation and Deployment
The One API supports rapid deployment via Docker. The following deployment commands use SQLite and MySQL:
Deployment commands using 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
Use the MySQL deploy command:
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
Please modify the database connection parameters as necessary.
Function Operation Guide
- token management: In the management interface, users can set the token's expiration time, amount, allowed IP range, and model access rights.
- Redemption Code Management: Supports batch generation and export of redemption codes, which can be used by users to top up their accounts.
- channel management: Users can create channels in bulk and set up model lists for different channels.
- User Grouping and Channel Grouping: Supports setting different multipliers for different groups for easy management.
- View Line Breakdown: Users can view detailed credit utilization.
- User Invitation Rewards: Earn reward credits by inviting new users.
- Customized settings: Users can customize the system name, logo and footer, and even the home page and about page.
usage example
Users can call the One API with the following sample code:
import requests
url = "http://localhost:3000/v1/completions"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {
"model": "gpt-3.5-turbo",
"prompt": "Hello, world!",
"max_tokens": 50
}
response = requests.post(url, headers=headers, json=data)
print(response.json())