QuantumNous/new-api
Self-hosted Go API gateway for multi-provider model routing, access, and costs
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
New API is a self-hosted Go/Gin gateway, not an inference engine. Requests enter through router/, middleware/, and controller/ for endpoint handling and access checks. The relay/ layer selects configured channels and adapts traffic to upstream providers; service/ and model/ separate business logic from persistence. The Go backend embeds the built React 19 and TypeScript console from web/dist, so frontend build tooling is not a production service dependency.
RelayKit is an independently buildable Go module for protocol data types and request, response, and streaming conversion. Plugins extend different parts of the gateway: provider plugins introduce upstream channel types, request-processing plugins can act on requests and replies by global, group, channel, or model scope, and JavaScript task plugins handle asynchronous submission, status, and output retrieval.
Key Capabilities & Differentiators
Clients can use OpenAI Chat Completions and Responses, Anthropic Messages, or Gemini endpoints. Upstream choices include OpenAI, Anthropic, Google Gemini, Azure OpenAI, AWS Bedrock, Vertex AI, DeepSeek, and Qwen. Model mappings, priorities, weights, retries, channel affinity, and multiple upstream keys let operators change provider selection without changing every client. Separate endpoints cover embeddings, reranking, images, and audio; Realtime and Responses WebSocket routes need a compatible channel and upstream.
The console manages models, channels, group access, key restrictions, and audit and usage logs. Quotas, subscriptions, cache accounting, and expression-based pricing help allocate costs across users and usage tiers. Streaming, tool calls, reasoning, and multimodal input depend on the model and conversion path. An endpoint being available is not evidence that every provider-specific field or tool behaves identically.
Trade-offs & Limitations
Compared with direct provider SDKs, New API centralizes routing, access, and accounting, but inserts another hop and a shared point of failure. A thin reverse proxy is simpler if the goal is only a stable URL or transparent forwarding. New API earns its operational cost when clients need model-aware routing and shared governance. Validate streaming, tool schemas, and usage accounting for each conversion path you depend on before treating providers as interchangeable.
Self-hosting gives operators control of the gateway and its records, not offline inference or guaranteed local data residency: requests still go to the configured upstreams. The AGPLv3 and additional Section 7 terms matter for modified deployments, including source availability for network users and preservation of attribution and the visible project link in modified UIs. Adding community plugins also expands what operators must review before granting code access to request or response data.
Hardware & Deployment Guide
For a local trial, run the container on Linux amd64 or arm64, bind 127.0.0.1:3000, and mount /data for SQLite. The supplied Compose stack uses PostgreSQL and Redis by default; MySQL is a main-store alternative, and LOG_SQL_DSN can separate logs, including to ClickHouse. For production, replace example passwords, pin a tested image instead of relying on latest, and serve the console over HTTPS with SESSION_COOKIE_SECURE, the exact trusted HTTPS origin, and explicit TRUSTED_PROXIES. Cluster nodes need the same persistent SESSION_SECRET; nodes sharing Redis also need the same effective CRYPTO_SECRET. Use shared Redis when rate limits must span nodes.
A source build requires Bun to produce web/dist before building the backend with the Go version specified in go.mod. For release selection, rc.50 introduced provider and request-processing plugins and migrated legacy sensitive-word settings to a request-filter instance. Rolling back that migration requires re-entering the legacy settings to restore filtering. rc.51 fixed rc.50 request-time crashes on x86-64 machines with AES-NI but without AVX. rc.52 added per-channel provider plugin route switches and a Responses-to-Anthropic Messages conversion path for advanced custom channels and provider plugins.
Teams operating several authorized model APIs that want a stable client endpoint, centrally managed keys and quotas, and usage-based cost allocation.
You need local or offline inference, depend on exact provider-native behavior across every feature, or have one upstream and no need for shared access controls or accounting.
Quick Start & Installation
mkdir -p data docker run --name new-api -d --restart unless-stopped \ -p 127.0.0.1:3000:3000 \ -e TZ=Asia/Shanghai \ -v "$(pwd)/data:/data" \ calciumion/new-api:latest
Comparison vs. Top LLMs & Inference Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| new-api ★ | 53k | +343 | Go | AGPL-3.0 | Self-hosted Go API gateway for multi-provider model routing, access, and costs |
| gpt-load | 7.2k | +6 | Go | MIT | Self-hosted Go gateway for routing LLM traffic across providers and credentials |
| bifrost | 10.2k | +125 | Go | Apache-2.0 | Self-hosted Go gateway for routing and governing multi-provider LLM traffic |
| one-api | 37.5k | +56 | JavaScript | MIT | Self-hosted OpenAI-compatible gateway for LLM routing and API key management |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/QuantumNous/new-api.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about new-api
How do I connect an existing client without sharing the upstream API key?
http://localhost:3000/v1 for a local deployment and authenticate with a New API-issued key, not the provider key. Check /v1/models, then test the endpoint and features the client actually uses.Does the gateway need a GPU, and what should I size for?
Can we self-host New API for commercial use?
When is New API preferable to direct SDK calls or a thin reverse proxy?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
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