Self-hosted service
Nya-Foundation/NyaProxy avatar
Nya-Foundation/NyaProxy

NyaProxy: an API-key gateway whose first-run config is open, whose Docker mount must be a directory, and whose edits restart the process

NyaProxy acts like a smart, central manager for accessing various online services (APIs) – think AI tools (like OpenAI, Gemini, Anthropic), image generators, or almost any web service that uses access keys. It helps you use these services more reliably, efficiently, and securely.

981 stars20 forksPythonMIT

At a glance

What is it?
NyaProxy is a Python gateway that puts your internal proxy keys in front of pooled upstream credentials and adds rate limits, queues, retries and key quarantine. Its sharp edges are operational: authentication starts disabled, config saves restart the service, and a bind-mounted file breaks the UI.
Who is it for?
Use NyaProxy when a team wants one place to inject and rotate upstream API keys and apply per-key, per-IP and per-user limits, and you are comfortable operating a small Python service that restarts on every config change. Do not expose it before setting server.api_key, and do not mount the config file itself into Docker.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 128 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 25, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • Nya-Foundation/NyaProxy981 ★ · -1
Star history
Repository2026-09-112026-11-25
Nya-Foundation/NyaProxy982981

-1 Stars in the last 75 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

The starter config has no server.api_key, so authentication is off until you set one

NyaProxy installs from PyPI under the name nya-proxy and starts with two commands:

bash
pip install nya-proxy
nyaproxy

On first run it writes a starter config.yaml into the current directory and listens on 127.0.0.1:8080. The starter config has no server.api_key, so authentication is disabled. The project says this is safe only while the service is bound to loopback, and that you must set server.api_key before using --host 0.0.0.0 or otherwise exposing it.

The consequence is easy to state and easy to forget. Anyone who can reach the port can send requests that are forwarded with your upstream credentials, and anyone who can reach the config UI can read and change the setup. The Docker command and the Docker image both bind to 0.0.0.0 inside the container, so the same rule applies there. The compose file is more careful: it publishes the port as 127.0.0.1:8080:8080, which keeps it on the host's loopback unless you change it.

Mount the directory, not config.yaml, or every UI save returns a 500

The Docker route is where the project is most specific about failure. The README example copies a ready-made config from configs/ and runs the image:

bash
mkdir -p data
cp configs/openai.yaml data/config.yaml  # then replace every placeholder key

docker run -d \
  -p 8080:8080 \
  -v ${PWD}/data:/app \
  --user "$(id -u):$(id -g)" \
  k3scat/nya-proxy:latest --config /app/config.yaml --host 0.0.0.0

The mount is a directory on purpose. Saving from the /config UI writes a temporary file and renames it over the target, and that rename fails with EBUSY against a bind-mounted single file, so every save returns a 500. The mount must also be writable, since a read-only mount blocks saves for the same reason.

The --user flag exists because the image runs as uid 100 and could not otherwise write a directory you own. Docker Desktop on macOS and Windows maps ownership for you, so you can drop the flag there. The compose file offers an alternative to the flag, which is running sudo chown -R 100:101 ./data on the host directory. Remember to replace every placeholder key in the copied example before starting.

Clients hold an internal proxy key, and the upstream keys never leave the gateway

NyaProxy sits between applications and upstream APIs. Applications call it with an internal proxy key, and it forwards each request to the configured upstream with the correct upstream credentials. Credential injection adds those credentials through headers without exposing them to clients, configured with the headers and variables settings. Credential pooling spreads traffic across multiple upstream keys or tokens, defined under variables.<name>.

Selection among the pool is a setting called load_balancing_strategy, with five values: round_robin, random, least_requests, fastest_response and weighted. The weighted option reads key_weights. The sample config uses round_robin as the default for every API, and any API block can override anything set under default_settings.

The gateway is meant for services that authenticate with API keys, bearer tokens or custom request headers. If an upstream signs requests in some other way, this design does not apply. The README also asks you to use only credentials and traffic patterns that the upstream service terms allow, which matters here because pooling many keys behind one endpoint is exactly the kind of pattern some providers restrict.

Limits apply at four scopes, and a queue holds requests until quota returns

The rate_limit block can limit at four levels: endpoint, upstream key, client IP and proxy user. The sample config shows how that reads: endpoint_rate_limit 1000/h, key_rate_limit 60/m, ip_rate_limit 5000/d and user_rate_limit 5000/d. These are example values in a minimal config, not recommended defaults.

Instead of rejecting a request when quota is used up, the queue setting holds requests until configured quota becomes available. In the sample it has max_size 200, max_workers 10 and expiry_seconds 300. The practical implication is that a client may wait rather than fail, so client timeouts need to be longer than the time a request can sit queued, and a full queue is a separate failure mode from an exhausted key.

Retry and failover retries selected status codes, cools down the failing key and rotates to the next one. Key quarantine, under key_blocking, temporarily removes credentials that return configured upstream error statuses. Both depend on you choosing the right status codes; the gateway cannot guess which errors mean a dead key.

Every configuration change restarts the service, and the Docker image depends on that

Changes made through the /config UI trigger an automatic restart so they take effect immediately. The same is true of edits to the file once you re-save through the UI. The command-line reference lists --no-reload to disable the file-watch supervisor, for production setups where restarts should be explicit, and with it set, config changes require a manual restart.

The Dockerfile is blunt about the trap: its CMD leaves hot-reload on, because restarting is how a configuration change is applied, so passing --no-reload silently strands every edit made through the config UI.

A restart would normally reset counters, so NyaProxy writes a .nya_state.json file next to the config. It carries rate-limit windows and key cool-downs across restarts, so a configuration change does not reset your quotas. That file sits in the mounted directory in the Docker setup, which is another reason the directory must be writable. Use --check-config to validate schema and cross-field configuration and exit, before you commit to a restart.

Request policy and JMESPath body rules shape what reaches the upstream

Two features act on the request before it is forwarded. Request policy allows or blocks paths and methods through allowed_paths and allowed_methods, which lets you expose only the endpoints you intend rather than the whole upstream surface. Body transformation, configured as request_body_substitution, sets or removes JSON fields with conditional JMESPath rules, so a gateway can enforce a field or strip one without changing client code.

Both are conveniences with a limit: they act on the request, and the README's feature table lists no equivalent that rewrites responses. If you need to alter what comes back, this is not the layer. An outbound proxy option, server.proxy, can send upstream traffic through an HTTP or SOCKS proxy, and the dependency list includes httpx with socks support to back that.

The config file is validated against a bundled JSON schema. Putting the yaml-language-server modeline pointing at nya/schema.json on the first line gives editors autocomplete and inline validation, and the shipped examples in configs/ already include it.

Three endpoints give you visibility, but remote config switches the UI off

Once running, three pages are served: /config is the configuration UI with validation, /dashboard shows metrics, request history and queue status, and /info lists the configured APIs and service status. A Prometheus /metrics endpoint is listed alongside the web dashboard, and the container's health check calls /health on port 8080.

The first key under server.api_key is the master key, used for the dashboard and config UI, while additional keys serve regular proxy traffic. That means the people who can see request history are the holders of the master key.

There is one configuration mode that removes the UI. Passing --remote-url, --remote-api-key and --remote-app-name pulls configuration from a remote config server instead of a local file, and this disables the local /config UI. In that mode you manage changes at the server, not in the browser. The default bind address and port can also be set with SERVER_HOST and SERVER_PORT environment variables rather than flags, which is convenient for container platforms where you would rather not change the command line. The flags are --host or -H and --port or -p, and the defaults are 127.0.0.1 and 8080. A related convenience for source installs is that the entry point can be launched either as nyaproxy or as python -m nya, so a virtual environment without the script on its path still works. Taken together, these switches mean the same package serves a laptop test and a hardened deployment, with the difference being only the flags you pass and whether server.api_key is set.

Beta classifier, Python 3.11 and a burst of three releases on one day

The package version is 0.8.2, classified Development Status 4 - Beta, and it requires Python 3.11 or newer, with classifiers for 3.11 through 3.14. It is released under the MIT license. Dependencies are fastapi, uvicorn, httpx with socks, watchfiles, jmespath, orjson, prometheus-client and nacho-python with its remote, schema and server extras. The watchfiles pin is commented as not imported directly, serving as uvicorn's file-watch backend for config hot-reload.

The three latest releases, v0.8.0, v0.8.1 and v0.8.2, were all published on 2026-07-20, hours apart, and the last push is the same day. Three releases in one day mean the 0.8 line was still moving fast when this was written, and for a Beta package that is a reason to pin an exact version in production and read CHANGELOG.md before each upgrade. Nothing in the release list tells you what v0.8.0 changed, so the changelog is the only place to find out whether a config key was renamed or a default shifted.

For contributors, the Makefile offers install, check, test, test-unit, test-e2e, coverage, lint, typecheck, format, clean and build targets, where check runs lint, typecheck and test, the same quality checks as CI. The mypy setup only checks modules known to be type-clean, so legacy modules are analysed but their errors are not reported.

Editorial conclusion

Use NyaProxy when a team wants one place to inject and rotate upstream API keys and apply per-key, per-IP and per-user limits, and you are comfortable operating a small Python service that restarts on every config change. Do not expose it before setting server.api_key, and do not mount the config file itself into Docker. Before relying on it, remember it is classified Beta at v0.8.2 and that pooling keys must stay within each upstream provider's terms.

Frequently asked questions

How do I install NyaProxy?

Run pip install nya-proxy and then nyaproxy. It writes a starter config.yaml in the current directory and listens on 127.0.0.1:8080. You can also install from source with pip install -e . or use the k3scat/nya-proxy Docker image.

Is NyaProxy safe to expose to the internet right after installing it?

No. The starter config has no server.api_key, so authentication is disabled, which is safe only while bound to loopback. Set server.api_key before using --host 0.0.0.0 or exposing the service.

Why do config saves fail with a 500 in the NyaProxy Docker setup?

If config.yaml itself is bind-mounted, the UI's rename of a temporary file over it fails with EBUSY. Mount the whole directory instead, and make sure it is writable.

Official sources

  1. License: MIT
  2. Nya-Foundation/NyaProxy on GitHub
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/nya-foundation-nyaproxy.svg)](https://hysenlabs.com/projects/nya-foundation-nyaproxy)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/nya-foundation-nyaproxy.svg)](https://hysenlabs.com/projects/nya-foundation-nyaproxy)

Was this useful?