One endpoint in front of a pool of API keys.
Rotation, rate limits, queueing, and failover for any HTTP API that authenticates with a key.
NyaProxy sits between your applications and an upstream API. Applications call it with a key you issue; it forwards each request with one of your upstream keys, chosen so that no key exceeds its quota. When every key is busy, requests wait in a queue instead of failing.
It forwards requests as they are, so it works with any HTTP API: OpenAI and OpenAI-compatible providers, Gemini, NovelAI, or an internal service. Use it only with credentials and traffic the upstream's terms allow.
- Key pool. Spread traffic over many keys with one of five strategies.
- Rate limits. Per upstream key, per API, per client IP, and per proxy key. A key can carry several windows at once, such as 40/m and 1000/d.
- Queueing. Requests over quota wait for the next free key, in priority order, instead of returning an error.
- Failover. Retry on the statuses you choose with the next key, and take a failing key out of rotation for a while.
- Policy. Allow or block paths and methods, and rewrite JSON request bodies with conditional rules.
- Live configuration. Edit settings in the browser; changes apply without a restart and without dropping requests in flight.
- Visibility. A dashboard and a Prometheus
/metricsendpoint.
pip install nya-proxy
nyaproxyThe first run writes a starter config.yaml to the current directory and
listens on http://127.0.0.1:8080. Open /config/ui to edit the
configuration and /dashboard to watch traffic.
With Docker, put a config.yaml that sets server.api_key in ./data, then:
docker run -d -p 8080:8080 -v "$PWD/data:/app" --user "$(id -u):$(id -g)" k3scat/nya-proxySee Deployment for Docker Compose, reverse proxies, and the security settings to review before exposing the service.
server:
api_key:
- admin-key # the first key also opens the dashboard and config UI
- app-key # further keys are for proxy traffic only
apis:
openai:
name: OpenAI
endpoint: https://api.openai.com/v1
headers:
Authorization: "Bearer ${{keys}}"
variables:
keys:
- sk-first-upstream-key
- sk-second-upstream-key
rate_limit:
enabled: true
key_rate_limit: 60/mA request to /api/openai/chat/completions is forwarded to
https://api.openai.com/v1/chat/completions with one of the two keys. A
client only changes its base URL and its key:
from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:8080/api/openai", api_key="app-key")Complete examples for OpenAI-compatible providers, Gemini, and NovelAI are in configs/.
| Guide | Covers |
|---|---|
| Configuration | Every setting, how requests are routed, limits, retries, and error responses |
| Deployment | Installing, Docker, authentication, reloading, monitoring, security |
| Body substitution | Rules that set or remove fields in JSON request bodies |
NyaProxy is feature-complete and in maintenance mode. It receives bug fixes, security fixes, and dependency updates; new features are not planned.
It is a transparent key-pool proxy and deliberately not an LLM gateway: token accounting, model routing, translation between provider formats, and multi-instance clustering are out of scope. Rate limits and queues live in memory, so run one instance per pool of keys.
See CONTRIBUTING.md. Questions and bug reports go to the issue tracker or the Nya Foundation Discord.