Overview of One API Frontend
mainminimal-ui-kit.repository·main·Indexed 13 days ago
https://github.com/songquanpeng/one-apiA unified gateway that standardizes access to various large language models (LLMs) using the OpenAI API format. It provides multi-model support for providers like OpenAI, Anthropic, Google Gemini, Mistral, DeepSeek, and Ollama, featuring load balancing, token and user management, and integration with Cloudflare AI Gateway.
minimal-ui-kit.One API provides a unified interface to access multiple Large Language Models (LLMs) using the standard OpenAI API format. It acts as a proxy/aggregator that simplifies integration by encapsulating various model providers into a single, consistent API structure.
Key Capabilities:
wechat-server).One API is a tool that allows you to access various large language models (LLMs) through a standardized OpenAI API format. It acts as a unified gateway, enabling out-of-the-box compatibility with many different model providers.
Key capabilities include:
THEME environment variable.The One API frontend supports multiple themes. Note that not all themes are guaranteed to be synchronized with all features immediately; the default theme is prioritized for updates.
For specific development instructions regarding the berry theme, refer to web/berry/README.md.
For high availability and scaling across multiple servers, follow these requirements:
SESSION_SECRET on all servers.SQL_DSN. All nodes must connect to the same database.NODE_TYPE=slave on all nodes except the master.SYNC_FREQUENCY (in seconds) to periodically sync configurations from the database.FRONTEND_BASE_URL to redirect page requests to the master server.REDIS_CONN_STRING to achieve zero-latency access to cached data.SYNC_FREQUENCY.One API calculates quota based on a multiplier system to account for different model costs.
Formula:
Quota = Group multiplier * Model multiplier * (number of prompt tokens + number of completion tokens * completion multiplier)
Key Details:
1.33 for GPT-3.5 and 2 for GPT-4, matching official definitions.By default, One API uses load balancing to distribute requests across available channels. To force a request to use a specific channel, append the CHANNEL_ID to your token using a hyphen.
Requirement: The token must be created by an administrator to support channel ID specification.
Format:
Authorization: Bearer ONE_API_KEY-CHANNEL_ID
Authorization: Bearer ONE_API_KEY-CHANNEL_IDOne API uses JSON for all requests and responses. A standard successful response body follows this structure:
{
"message": "请求信息",
"success": true,
"data": {}
}For high availability or distributed setups, you can deploy multiple One API instances. To ensure they work together, follow these requirements:
SESSION_SECRET.SQL_DSN.NODE_TYPE set to slave.SYNC_FREQUENCY to allow servers to periodically sync configurations from the database. It is recommended to enable Redis for this.FRONTEND_BASE_URL to redirect page requests back to the master server.REDIS_CONN_STRING. This allows slaves to serve cached data without hitting the database.One API calculates quotas using a specific formula involving group multipliers, model multipliers, and token counts. Note that completion tokens may have a different multiplier than prompt tokens.
Quota Formula:
Quota = Group Multiplier * Model Multiplier * (Prompt Tokens + Completion Tokens * Completion Multiplier)
Fixed Completion Multipliers:
Note: In non-streaming mode, the official API returns the total tokens consumed, but you must account for the different multipliers for prompt and completion tokens.
If you prefer Docker Compose, you can use the following setup. Note that the parameter settings remain the same as the standard Docker deployment.
# Start the service (supports MySQL startup)
docker-compose up -d
# Check deployment status
docker-compose psdocker-compose up -dTo deploy manually, you must build both the frontend and the backend.
Clone the repository:
git clone https://github.com/songquanpeng/one-api.gitBuild the Frontend:
cd one-api/web/default
npm install
npm run buildBuild the Backend:
cd ../..
go mod download
go build -ldflags "-s -w" -o one-apiRun the application:
chmod u+x one-api
./one-api --port 3000 --log-dir ./logsDefault Credentials:
root123456chmod u+x one-api
./one-api --port 3000 --log-dir ./logs