explaingit

songquanpeng/one-api

33,878JavaScriptAudience · developerComplexity · 3/5MaintainedLicenseSetup · hard

TLDR

A unified gateway that lets you manage multiple AI provider APIs (OpenAI, Claude, Gemini, etc.) through a single interface with centralized billing, user tokens, and usage tracking.

Mindmap

mindmap
  root((One API))
    What it does
      Unified AI gateway
      Multi-provider routing
      Token management
      Usage tracking
    Key features
      Spending limits
      Load balancing
      Auto-retry logic
      Streaming support
    Deployment
      Single binary
      Docker container
      SQLite or MySQL
    Use cases
      Team API access
      Provider switching
      Internal quotas
      Cost per user

Things people build with this

USE CASE 1

Give your development team access to multiple AI models without sharing raw API keys or credentials.

USE CASE 2

Switch between AI providers (OpenAI, Claude, Gemini) without changing your application code.

USE CASE 3

Track and limit AI API spending per user, team, or project with automatic quota enforcement.

USE CASE 4

Build an internal AI service where different departments pay for their own model usage.

Tech stack

GoJavaScriptDockerSQLiteMySQL

Getting it running

Difficulty · hard Time to first run · 1day+

Requires Docker, database setup (SQLite or MySQL), multiple API keys from external providers, and likely backend/frontend coordination to see a working gateway.

Use freely for any purpose including commercial, as long as you keep the copyright notice.

In plain English

One API is a management and distribution system for large language model APIs. Instead of having to integrate separately with OpenAI, Anthropic Claude, Google Gemini, Azure, DeepSeek, and dozens of other AI providers, each with their own authentication, request formats, and billing, One API acts as a single gateway that sits in front of all of them. Your application sends requests to One API using the standard OpenAI API format, and One API routes those requests to whichever providers and models you have configured. The key idea is centralized control over API keys and usage. As an administrator, you create "channels" (each connected to a real AI provider), then issue tokens to users or teams. Each token can have spending limits, expiry dates, allowed IP addresses, and restrictions on which models it can access. When a user's application calls One API with their token, the system handles routing, load balancing across multiple channels, automatic retry on failures, and usage tracking, all transparently. This is useful for teams or businesses that want to give developers access to AI models without sharing raw provider API keys, or for anyone who wants to switch between providers without rewriting application code. It is also used to build internal API-as-a-service setups where usage quotas and costs are tracked per user or group. The system deploys as a single binary or via Docker, connects to either SQLite or MySQL for storage, and exposes a web admin panel for managing channels, users, tokens, and viewing usage statistics. The frontend is JavaScript and the backend is Go. It supports streaming responses for real-time typewriter effects in chat interfaces, and integrates with services like Cloudflare AI Gateway for additional routing options.

Copy-paste prompts

Prompt 1
How do I set up One API to route requests from my app to both OpenAI and Claude, and switch between them without code changes?
Prompt 2
Show me how to create user tokens in One API with spending limits and IP restrictions for my team.
Prompt 3
How do I deploy One API with Docker and connect it to my existing MySQL database?
Prompt 4
Can you explain how One API's load balancing works across multiple channels to the same provider?
Prompt 5
How do I integrate One API into my existing application that currently calls OpenAI directly?
Open on GitHub → Explain another repo

Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.