# Nenya AI Gateway

> A lightweight, zero-dependency AI API gateway written in Go that redacts secrets, routes across LLM providers with fallback and caching, and enforces security hardening between local AI coding clients and upstream providers.

Nenya AI Gateway is an open-source, self-hosted API gateway written in Go that sits between local AI coding clients (such as Cursor, OpenCode, and Aider) and upstream LLM providers. It intercepts every request to redact secrets, compress context, and route traffic intelligently — all without any external runtime dependencies. The project is maintained by GitHub user gumieri and is licensed under Apache 2.0.

## What It Is

Nenya is a privacy-first, security-hardened middleware layer for AI development workflows. It implements OpenAI- and Anthropic-compatible endpoints, meaning existing clients work unchanged while Nenya handles provider routing, secret redaction, caching, and MCP tool integration transparently. The README describes it as "the gatekeeper in between" — a single static binary that requires no plugins, interpreters, or sidecars.

## Security and Privacy Architecture

The gateway's core value proposition is keeping sensitive data from leaking to cloud LLM providers. Its layered approach includes:

- **Tier-0 regex filter** — always-on redaction of AWS keys, GitHub tokens, passwords, and similar secrets before any payload leaves the machine
- **3-tier content pipeline** — pluggable interceptor chain covering regex redaction, entropy filtering, TF-IDF relevance scoring, and engine summarization
- **Hardened deployment** — mlock-sealed secrets, seccomp and no-new-privileges, non-root containers (UID 65532), read-only filesystem, and systemd socket activation for zero-downtime restarts
- **RBAC** — per-API key roles (admin, user, read-only) with agent and endpoint restrictions

## Routing and Provider Support

Nenya ships with 23 built-in provider adapters covering wire format differences across OpenAI, Anthropic, and Gemini-style APIs. Key routing capabilities include:

- Config-driven provider registry with zero code changes
- Dynamic model discovery at startup and on hot reload
- Agent fallback chains with round-robin or sequential strategies, circuit breakers, and automatic failover
- Latency-aware routing that auto-reorders targets by historical median response time with jitter to prevent thundering herd
- Sticky sessions that keep provider-side prefix caches warm across conversation turns
- Stream-head failover: upstream streams are probed before headers commit, so empty or early-error streams fail over to the next target

## MCP Tool Integration

Nenya supports the Model Context Protocol (MCP) for tool discovery and multi-turn execution. Agents can connect to MCP servers for automatic tool injection, run multi-turn tool loops without exposing MCP complexity to the client, pre-fetch relevant context via auto-search, and persist assistant responses to MCP memory servers via auto-save.

## Deployment Model

Nenya is designed for self-hosted deployment across multiple environments:

- **Container**: Podman or Docker with hardened flags (`--cap-drop=ALL`, `--read-only`, `--security-opt=no-new-privileges:true`)
- **Bare metal**: Systemd service and socket units with hot reload via `systemctl reload nenya`
- **Kubernetes**: Helm chart with ConfigMap/Secret and ingress support
- **Package managers**: Native `.deb`, `.rpm`, `.pkg.tar.zst` packages; AUR (`nenya-bin`); Nix/NixOS via NUR

The binary is built from Go's standard library only — zero external dependencies — making it straightforward to audit and deploy in air-gapped or security-sensitive environments.

## Update: Nenya v0.14.1

The latest release is v0.14.1, published on 2026-09-17, with the repository last pushed the same day. The project was created in March 2026 and has seen active development through its changelog. The README references Go 1.26 as the build target and lists ongoing features including context-limit auto-retry, local Ollama model lifecycle management, and a Google Agent-to-Agent (A2A) protocol endpoint — signaling a direction toward broader agentic infrastructure support.

## Features
- Secret redaction via Tier-0 regex filter (AWS keys, GitHub tokens, passwords)
- 3-tier content pipeline: regex, entropy filtering, TF-IDF pruning, engine summarization
- 23 built-in LLM provider adapters
- OpenAI and Anthropic compatible endpoints
- Agent fallback chains with circuit breakers and automatic failover
- Latency-aware routing with jitter
- Sticky session routing for prefix cache warmth
- Stream-head failover and stream continuation
- MCP tool discovery and multi-turn execution
- MCP auto-search and auto-save
- Role-Based Access Control (RBAC)
- mlock-sealed secrets
- Seccomp and no-new-privileges hardening
- Non-root container execution (UID 65532)
- Read-only filesystem support
- Systemd socket activation for zero-downtime restarts
- Hot reload via systemctl reload
- In-memory LRU response cache with SHA-256 fingerprinting
- Dynamic model discovery at startup
- Context window compaction and sliding window summarization
- Stale tool call pruning
- Thought pruning from assistant history
- Prometheus-compatible metrics endpoint
- Kubernetes Helm chart support
- Native Linux packages (deb, rpm, pkg.tar.zst, AUR, Nix)
- Zero external runtime dependencies (Go stdlib only)
- Google Agent-to-Agent (A2A) protocol endpoint

## Integrations
OpenAI API, Anthropic API, Google Gemini, DeepSeek, Zhipu AI (z.ai), Ollama, OpenCode / OpenCode Zen, Cursor, Aider, Model Context Protocol (MCP), Prometheus, Podman, Docker, Kubernetes / Helm, systemd, Nix/NixOS

## Platforms
LINUX, API, CLI

## Pricing
Open Source

## Version
v0.14.1

## Links
- Website: https://github.com/gumieri/nenya
- Documentation: https://github.com/gumieri/nenya/blob/main/docs/CONFIGURATION.md
- Repository: https://github.com/gumieri/nenya
- EveryDev.ai: https://www.everydev.ai/tools/nenya-ai-gateway
