yym68686/uni-api
This is a project that unifies the management of LLM APIs. It can call multiple backend services through a unified API interface, convert them to the OpenAI format uniformly, and support load balancing. Currently supported backend services include: OpenAI, Anthropic, DeepBricks, OpenRouter, Gemini, Vertex, etc.
What it solves
Running multiple LLM providers (OpenAI, Anthropic, Gemini, Vertex, Azure, AWS, etc.) usually means juggling separate API formats, keys, and management tools. uni-api solves this by acting as a single gateway: you configure all your backend services in one YAML file, and uni-api exposes them all through a standard OpenAI-compatible API. It removes the need for a complex frontend or commercial management platform, giving you a lightweight, self-hosted way to route requests, balance load, and handle failures automatically.
How it works
uni-api is configured entirely via a api.yaml file (or a URL pointing to it). You define providers — each with a base URL, API key(s), and optional model lists or renaming rules. You also define api_keys for your users, with per-key model permissions and rate limits. When a request comes in, uni-api matches it to the appropriate provider(s), converts the request to the native format of the backend (OpenAI, Anthropic, Gemini, etc.), and returns the response in OpenAI format. It supports multiple load-balancing strategies: weighted channel-level, round-robin across channels or API keys, and automatic key rotation. On failure, it retries the next channel or cools down the failing one. Advanced options include per-model timeouts, custom request body overrides, proxy support, and even a moderation hook to review user messages.
Who it's for
This is for individuals or small teams who want to run their own LLM API endpoint without the overhead of a complex management system. It's ideal for developers who are comfortable editing a YAML file, want support for a wide range of providers (OpenAI, Anthropic, Gemini, Vertex, Azure, AWS, Cloudflare, OpenRouter, and more), and need features like load balancing, retries, and rate limiting — all in a single, self-contained tool. It's beginner-friendly because the configuration is plain text and documented.
Highlights
- No frontend — configure everything in a single
api.yamlfile. - Unified OpenAI-compatible interface for many providers, including image generation and embeddings.
- Three load-balancing methods: channel-level weighted, channel-level round-robin, and API-key round-robin.
- Automatic retry and channel cooling when a backend fails.
- Fine-grained per-model timeouts, per-key permissions, and rate limiting (e.g., 5/min, 10/day).
- Supports tool use (function calls), image recognition, and custom request body overrides.
- Optional moderation endpoint to review user messages.
Related
- Project
- Project
- Project
- Project
- Project