← Back to Leaderboard
Osongquanpeng

songquanpeng/one-api

Self-hosted OpenAI-compatible gateway for LLM routing and API key management

Open-Source AI AppQuickstart ↓
Engineering Health (Methodology)
B · 62/100
Maintenance Activity
● Updated 10mo ago
Latest Release
v0.6.10
Commercial License Check
MIT · Commercial Friendly

Automated SPDX check for reference only — not legal advice. Disclaimer

Maintenance6/35
Fork Adoption25/25
Release Cadence11/20
License Clarity20/20
DockerSelf-HostedAPI
Total Stars
★ 37,512
24h Growth
+4
7d Growth
+56
Forks
6,890

GitHub Star History

Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.

songquanpeng/one-api Star History (2023-04-22 - 2026-12-03) ALL-TIME STAR HISTORY (2023-04 – 2026-12) +37.5k in 1321d · avg +28/day 39.6k 19.8k 0 2023-04-22: ★ 12023-07-15: ★ 1,2332023-10-07: ★ 4,3322023-12-30: ★ 7,2372024-03-23: ★ 11,0482024-06-15: ★ 14,5512024-09-07: ★ 16,7872024-11-30: ★ 18,6512025-02-22: ★ 21,6852025-05-17: ★ 24,1642025-08-09: ★ 25,5812025-11-01: ★ 26,8292026-01-24: ★ 28,3862026-04-18: ★ 31,4912026-07-11: ★ 35,1472026-10-03: ★ 36,8332026-12-03: ★ 37,512 ★ 37.5k 2023-04 2025-02 2026-12

Evidence-Backed Technical Brief

AI Deep Review

Architecture & Core Mechanics

One API is a self-hosted relay, not an inference engine. The service starts at main.go, targets Go 1.20 in go.mod, and depends on Gin; the JavaScript frontend is built from web/default before compiling the single executable. The tree separates router/, middleware/, controller/, model/, and relay/, while the dependency manifest includes a Redis client and the AWS Bedrock Runtime SDK.

Clients authenticate to the gateway with a One API token and request a model through an OpenAI-compatible endpoint. The gateway selects an eligible upstream channel and uses that channel's credentials. For compatible upstreams it relays the request; for other providers it adapts the request and response bodies. The client-facing protocol stays consistent, but the available operations and behavior still depend on the selected provider adapter.

Key Capabilities & Differentiators

One API lets existing OpenAI-compatible clients use configured channels for OpenAI and Azure OpenAI, Anthropic Claude including AWS-backed access, Google Gemini, DeepSeek, and Ollama, among other providers. The gateway supports streaming, and default load balancing spreads requests across eligible channels. An explicit channel override is available with administrator-created tokens. Operators can also schedule channel availability checks and balance updates.

The web console separates upstream credential management from downstream token issuance. Token limits are distinct from account limits. Quota accounting weights prompt tokens plus completion tokens adjusted by a completion multiplier, then applies model and group ratios. This is a gateway usage policy, not a substitute for reconciling upstream invoices. Model names and provider-specific behavior still need testing on the intended route.

Trade-offs & Limitations

Compared with direct provider SDKs, One API reduces duplicate client integrations and centralizes who can use which upstream credentials. In return, it adds a network hop, a shared failure point, and a compatibility layer that may not expose native features as soon as a provider SDK does. Load balancing distributes traffic; it does not remove upstream rate limits. Unlike Ollama, the gateway does not run model weights or make a cloud-backed setup work offline.

Start with SQLite for a small single instance and prefer MySQL for higher concurrency or multiple nodes. Redis is useful when database access is slow, but caching and batched writes can delay the visibility of configuration or quota changes. Benchmark with the expected request mix and stream concurrency rather than sizing for model parameters. Because traffic and upstream credentials pass through the gateway, restrict admin access and define a log retention policy before production use.

Hardware & Deployment Guide

Start with a release binary or a Docker image from justsong/one-api or ghcr.io/songquanpeng/one-api. The default port is 3000; mount /data for SQLite persistence and set --log-dir if logs need a separate path. The supplied Compose example uses MySQL via SQL_DSN, Redis via REDIS_CONN_STRING, and a health check against /api/status. Before exposing the service, replace the initial administrator password and sample secrets, and terminate HTTPS at a reverse proxy configured for streaming requests.

Use shared MySQL and the same strong SESSION_SECRET on every node in the documented multi-node setup. Mark secondary nodes with NODE_TYPE=slave and tune SYNC_FREQUENCY if caching is enabled. PostgreSQL is listed as still being adapted, so verify it before treating it as a production substitute. Pin and test the release you deploy: v0.6.10 (2025-02-02) added Replicate chat models, OpenAI o1, and gemini-2.0-flash-exp; v0.6.9 added SiliconFlow and updated Ollama embeddings to accept multiple input texts.

Relay architecture: A Go/Gin service and web console separate upstream channel credentials from client-facing tokens.
Protocol adaptation: OpenAI-shaped requests are forwarded to compatible upstreams or translated by provider adapters, with streaming on supported routes.
Channel routing: Model and group eligibility determine the available channels for load balancing; tokens created by administrators can explicitly select a channel.
Quota accounting: Account and token limits are separate, and metered usage applies group and model ratios plus a completion-token multiplier.
Persistence and caching: SQLite supports a single-instance setup; the Compose example uses MySQL and Redis, and LOG_SQL_DSN can separate log storage.
Release coverage: v0.6.10 added Replicate chat models, OpenAI o1, and gemini-2.0-flash-exp; v0.6.9 updated Ollama embeddings for multiple input texts.
Best For

Teams with several OpenAI-compatible clients that need to share approved upstream providers without distributing provider credentials to each application.

Skip If

You need local inference, immediate access to provider-native APIs, or only one provider and no central token, quota, or routing requirements.

Reviewed on 2026-12-03 · Grounded in GitHub README, root file tree & releasesMethodology

Quick Start & Installation

DockerSelf-HostedAPI
# 使用 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
# 使用 MySQL 的部署命令,在上面的基础上添加 `-e SQL_DSN="root:123456@tcp(localhost:3306)/oneapi"`,请自行修改数据库连接参数,不清楚如何修改请参见下面环境变量一节。
# 例如:
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

Comparison vs. Top LLMs & Inference Alternatives

Full comparison →
RepositoryStars7d TrendStackLicenseCore Positioning
one-api ★37.5k+56JavaScriptMITSelf-hosted OpenAI-compatible gateway for LLM routing and API key management
new-api53k+343GoAGPL-3.0Self-hosted Go API gateway for multi-provider model routing, access, and costs
gpt-load7.2k+6GoMITSelf-hosted Go gateway for routing LLM traffic across providers and credentials
bifrost10.2k+125GoApache-2.0Self-hosted Go gateway for routing and governing multi-provider LLM traffic

AI Context Briefing (for Claude / Cursor / Windsurf)

Standardized architecture summary & quickstart commands ready to paste into coding agents.

Raw .md ↗
curl -sL https://repoforai.com/repo/songquanpeng/one-api.md

Embed Star History Chart & Badges in README.md

Full-history Star History SVGs and velocity cards on GitHub Camo: drop-in replacement for OSSInsight and Star History widgets.

songquanpeng/one-api Star History on RepoForAI

Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).

Frequently Asked Questions about one-api

How do I connect an existing OpenAI-compatible client?

Configure an upstream credential and its available models in a channel, then issue a separate One API token to the application. Point the client at the gateway, usually using a base URL ending in /v1 if the SDK expects it. If routing returns no available channel, check the user's group, the channel's group, and the configured model name.

Does the gateway need a GPU, and what drives resource usage?

No GPU or model VRAM is needed for the gateway itself. Size its CPU, memory, and network capacity around concurrent requests, long-lived streams, and database activity. If the upstream is a local Ollama instance, size that server separately for the models it runs.

What should a commercial self-hosted deployment check?

The repository includes an MIT license and separately asks operators of deployments and derivative projects to retain a footer attribution and link, or obtain authorization before removing them. Review both before a branded rollout. Self-hosting the gateway does not change upstream terms on credential sharing or redistribution, or any applicable data-handling and service obligations.

When should I bypass One API and connect directly?

Use a provider's own SDK if you need its latest APIs and provider-specific semantics. Connect directly to Ollama if a local inference endpoint is all you need. Choose One API when multiple applications need one client interface, centrally managed upstream credentials, and separate access tokens or quotas.

Upstream README & Documentation

This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.

Maintaining songquanpeng/one-api? Pin to Homepage + competitor /alternatives pages with a custom Cloud/Demo CTA.Feature songquanpeng/one-api on Homepage & Alternatives ($19)
WEEKLY BREAKOUT DIGEST

Top 10 Breakout Open-Source AI Repos, Every Thursday

Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.

Zero spam · 1-click unsubscribe · Privacy Policy

Saved in your browser · Export Markdown RFC tables or jump into /vs compare