# Repository Briefing: QuantumNous/new-api
> Source: https://repoforai.com/repo/QuantumNous/new-api (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/QuantumNous/new-api
- **Official Docs / Website**: https://www.newapi.ai
- **Category**: LLMs & Inference (大模型与推理微调)
- **Primary Language**: Go
- **License**: AGPL-3.0
- **Engineering Health**: A+ (91/100 · Maintenance 35/35 · Adoption 25/25 · Releases 20/20 · License 11/20)
- **Latest Release**: v1.0.0-rc.52 (2026-11-27) — https://github.com/QuantumNous/new-api/releases
- **Review Snapshot**: 2026-12-03
- **Deployment / Stack Signals**: Docker, Self-Hosted, API
- **Momentum**: 52,989 ★ total (+21 24h / +343 7d) · 12,992 forks
- **Topics**: `ai-gateway`, `api-management`, `claude`, `deepseek`, `gemini`, `llm-gateway`, `model-routing`, `newapi`, `openai`, `rerank`, `self-hosted`
- **When to Use**: Best for: Teams operating several authorized model APIs that want a stable client endpoint, centrally managed keys and quotas, and usage-based cost allocation. Skip if: 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.

## Overview
```text
### Architecture & 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.
```

## Key Capabilities
```text
- Protocol conversion: RelayKit handles requests, responses, and streams across OpenAI Chat Completions, OpenAI Responses, Anthropic Messages, and Gemini.
- Model-aware routing: Model mappings, weighted channel priorities, retries, affinity, and multiple upstream keys give operators control over upstream selection.
- Access controls: Group and model permissions and API-key restrictions sit alongside OAuth/OIDC, passkeys, two-factor authentication, and session management.
- Cost accounting: Usage logs, quotas, subscriptions, cache accounting, and expression-based prices support usage-based cost allocation.
- Plugin scopes: Provider plugins add channel types, request-processing plugins can apply at several scopes, and JavaScript task plugins expose submission and status APIs.
- Storage choices: SQLite supports a single-container trial; PostgreSQL or MySQL can back the main store, shared Redis can coordinate rate limits, and ClickHouse is an option for separate logs.
```

## Quick Start / Clone
```bash
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
```
