Find your next open-source project

Search by name, purpose, or keyword — or paste a GitHub repository URL

songquanpeng/one-api

AI Engineering

Self-hosted gateway that unifies many LLM providers behind one OpenAI-compatible API, with keys, quotas and load balancing.

37,413
6,893
JavaScript
MIT
3 years old

What it does

One API is a self-hosted gateway that puts many LLM providers behind a single OpenAI-compatible interface. Upstream Anthropic Claude, Google Gemini, DeepSeek, Zhipu ChatGLM, Baidu ERNIE, Moonshot, Groq, Ollama and many others are adapted to the same request format, so existing OpenAI SDKs and clients can talk to them by changing the base URL and key feature list.

It also acts as an access-management layer. Administrators register provider API keys as channels, create tokens with expiry, quota, IP range and model limits, group users and channels with separate multipliers, and rely on load balancing and automatic retry across channels. Requests can be pinned to a specific channel by appending the channel ID to the token; otherwise the gateway balances them.

It targets teams and individuals who already hold several provider keys and want one endpoint, one billing ledger and per-user quotas instead of distributing raw provider credentials.

Quick start

Docker is the shortest path. Create a writable data directory on the host, then run the SQLite-backed container:

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

The image is also published as ghcr.io/songquanpeng/one-api if Docker Hub is unreachable Docker deployment. Open http://localhost:3000/ and log in with root / 123456; change that password immediately. Then add a provider key under Channels, create a token under Tokens, and point any OpenAI-compatible client at the instance:

OPENAI_API_KEY="sk-xxxxxx"
OPENAI_API_BASE="https://<HOST>:<PORT>/v1"

A binary release or source build is an alternative: go build the backend and npm run build the frontend, then run ./one-api --port 3000 --log-dir ./logs manual deployment.

Operating constraints

For real concurrency, set SQL_DSN to MySQL or PostgreSQL instead of SQLite; the README explicitly recommends this for larger loads. SQLite deployments rely on the mounted /data volume for persistence, and data is lost on container restart without it. Multi-node deployments require a shared database, identical SESSION_SECRET, NODE_TYPE=slave on secondary nodes, and optionally Redis for caching multi-machine setup.

Quota is computed as group multiplier × model multiplier × (prompt tokens + completion tokens × completion multiplier), and token quota is tracked separately from account quota. Model mapping rewrites request bodies instead of passing them through, so fields not yet supported may be dropped. The project is MIT licensed but additionally requires keeping the attribution link in the page footer unless separately authorized. In China, the README asks operators not to offer unregistered generative AI services to the public and to comply with OpenAI's terms notices.

HotRepo's take

On the JavaScript daily list of 11 November 2026, the project recorded 21 new stars and a best rank of 9 for that day, with 37,402 stars and 6,892 forks in total. This is a single snapshot, not a trend line, but the rank inside a crowded language list indicates sustained attention for a long-running API gateway. The README's focus on channel testing, balance polling and rate limits shows the project is aimed at operators running shared access, not just single-user proxying.

Written by AI from the project's README, updated . The project's own docs are the source of truth.

You might also like

  1. QuantumNous/new-apiA self-hosted gateway that puts many model providers behind one OpenAI-, Claude- or Gemini-compatible API for teams and agents.Go50,631
  2. Mag1cFall/AIStudio2APIExpose Google AI Studio as OpenAI, Anthropic or Gemini-compatible APIs for existing clients and agents.Go596
  3. langchain4j/langchain4jA Java library for building LLM-powered applications with unified provider APIs, tool calling, agents, and RAG.Java13,368
  4. cutetailbud/FastAITokenA paid API relay that lets developers call multiple LLMs and video models with one key.Python107
  5. eliasbiondo/antirionA self-hosted gateway that puts routing, budgets, guardrails and observability in front of calls to multiple LLM providers.Rust240