Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

42 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Agent Nexus Gateway

The most advanced local AI Gateway. Universal routing, streaming, MCP, A2A, plugins, and a beautiful dashboard.

CI License: Apache-2.0 TypeScript Node PRs Welcome


What is Agent Nexus Gateway?

Agent Nexus Gateway is a production-grade, open-source AI Gateway that sits between your applications and your LLM providers. It gives you a single, OpenAI-compatible API endpoint that intelligently routes requests across multiple providers, with failover, caching, observability, and a real-time dashboard.

It is designed to be the last AI gateway you ever install β€” flexible enough for a solo developer running Ollama on a laptop, powerful enough to back an enterprise multi-agent platform.

Why another gateway?

Existing gateways (OpenRouter, LiteLLM, etc.) make tradeoffs that don't fit everyone. Agent Nexus Gateway is built on three principles:

  1. Local-first. Runs on your machine, your cluster, your air-gapped network. No vendor lock-in.
  2. Universal. OpenAI-compatible REST, streaming SSE, WebSocket, MCP server, MCP client, A2A protocol β€” all from one process.
  3. Honest. No tricks to evade rate limits. No undocumented APIs. Just intelligent routing, retries, failover, and caching on top of providers' official APIs.

Features

Universal AI Gateway

  • βœ… OpenAI-compatible REST API (/v1/chat/completions, /v1/embeddings, /v1/models)
  • βœ… Streaming support (SSE)
  • βœ… WebSocket support (real-time dashboard feed)
  • βœ… MCP Server (expose gateway tools to Claude Code, Continue, Cline, etc.)
  • βœ… MCP Client (consume external MCP servers and aggregate their tools)
  • βœ… A2A Protocol (Agent-to-Agent coordination)
  • βœ… Plugin Framework (lifecycle hooks: onRequest, onRouteResolved, onProviderStart, onProviderChunk, onProviderEnd, onError, onResponse, onStartup, onShutdown)
  • βœ… 19 Native Integrations with auto-setup (Claude Code, Codex CLI, Gemini CLI, Hermes CLI, OpenCode, OpenCode Go, OpenCode Zen, Cursor, Continue, Cline, Roo Code, OpenHands, Aider, Zed, VS Code, JetBrains, Neovim, Emacs)
  • βœ… Extension Marketplace (browse, install, update, rollback, signature verification)
  • 🚧 Desktop App (planned β€” Electron shell)

Provider Adapters (17 supported + 20 auto-discoverable)

Provider Status Streaming Tools Vision Embeddings
OpenAI βœ… βœ… βœ… βœ… βœ…
Anthropic βœ… βœ… βœ… βœ… β€”
Google Gemini βœ… βœ… βœ… βœ… βœ…
OpenRouter βœ… βœ… βœ… βœ… β€”
DeepSeek βœ… βœ… βœ… β€” β€”
Mistral βœ… βœ… βœ… βœ… βœ…
xAI (Grok) βœ… βœ… βœ… β€” β€”
Groq βœ… βœ… βœ… β€” β€”
Together βœ… βœ… βœ… β€” β€”
Fireworks βœ… βœ… βœ… β€” β€”
Cerebras βœ… βœ… βœ… β€” β€”
Cloudflare AI βœ… βœ… βœ… β€” β€”
Ollama βœ… βœ… βœ… β€” βœ…
vLLM βœ… βœ… βœ… β€” βœ…
LM Studio βœ… βœ… βœ… β€” βœ…
LiteLLM βœ… βœ… βœ… β€” β€”
Azure OpenAI βœ… βœ… βœ… βœ… βœ…
AWS Bedrock 🚧 β€” β€” β€” β€”
Vertex AI 🚧 β€” β€” β€” β€”

Routing Engine (8 strategies)

  • Weighted β€” random selection weighted by weight field
  • Round-robin β€” fair distribution
  • Least latency β€” EWMA latency per endpoint
  • Least cost β€” minimize $/1K tokens
  • Highest quality β€” prefer high-priority endpoints
  • Capability matching β€” filter by required capabilities (vision, tools, etc.)
  • Priority β€” strict priority ordering
  • Budget-aware β€” stay within remaining budget

Plus:

  • βœ… Automatic failover with up to N alternatives
  • βœ… Circuit breakers (open after failureThreshold retryable errors in failureWindowMs)
  • βœ… Retries with exponential backoff
  • βœ… Health monitoring (active probes + passive observation)
  • βœ… Fallback chains
  • βœ… Connection pooling (via Node's fetch)
  • βœ… Affinity routing (sticky sessions)

Performance

  • βœ… Streaming (SSE)
  • βœ… Prompt caching (provider-side, e.g. Anthropic cache_control)
  • βœ… Semantic cache (vector similarity via cosine)
  • βœ… Compression (prompt compression: system dedup, stop-words, schema, summarization)
  • βœ… Token optimization (character-based estimation; tiktoken integration planned)
  • βœ… Connection pooling
  • 🚧 Batching (Anthropic batching API)
  • 🚧 Request deduplication
  • 🚧 Parallel execution

Dashboard (Next.js + TypeScript + Tailwind)

  • βœ… Real-time metrics via WebSocket
  • βœ… Token usage charts
  • βœ… Cost analytics
  • βœ… Latency graphs
  • βœ… Provider health table
  • βœ… Request logs (live event feed)
  • βœ… Audit log viewer
  • βœ… Network diagnostics page
  • 🚧 Workflow editor (drag-and-drop)
  • βœ… Plugin manager UI
  • βœ… Settings
  • 🚧 User management
  • βœ… Dark mode
  • βœ… API Keys management (multi-key per provider, intelligent rotation)
  • βœ… Router Studio (visual routing config, alias management)
  • βœ… Budget tracking
  • βœ… Cost analytics
  • βœ… Request tracing

Networking

  • βœ… HTTP / HTTPS / SOCKS5 proxy support (via undici ProxyAgent)
  • βœ… Latency measurement
  • βœ… Health-check endpoints
  • βœ… Automatic failover between proxies
  • βœ… DNS over HTTPS (Cloudflare, Google, custom)
  • βœ… IPv4 / IPv6 support
  • βœ… Enterprise proxy authentication (basic auth in URL)
  • βœ… Connection diagnostics

Security

  • βœ… Encrypted credential vault (AES-256-GCM at rest, scrypt-derived key)
  • βœ… RBAC with wildcard permissions
  • βœ… JWT (HS256; RS256 planned)
  • 🚧 OAuth2 (planned)
  • βœ… Audit logs
  • βœ… Secrets management
  • βœ… Zero Trust architecture

AI Features

  • βœ… Workflow engine (multi-step agent workflows with pause/resume/replay)
  • βœ… Multi-agent orchestration (via @anx/a2a β€” in-process; planner/executor/critic roles planned)
  • βœ… Memory (short-term + long-term with vector search, Qdrant adapter)
  • 🚧 Prompt templates
  • βœ… Tool calling (passthrough)
  • βœ… Function calling (passthrough)
  • βœ… Vision (full translation for Anthropic + Gemini)
  • 🚧 Audio
  • 🚧 Speech (TTS)
  • βœ… Embeddings
  • 🚧 RAG
  • 🚧 Knowledge graphs
  • βœ… Agent coordination (A2A protocol β€” message routing, teams, proposals)

Observability

  • 🚧 OpenTelemetry (interface ready; OpenTelemetry SDK integration planned)
  • βœ… Prometheus metrics endpoint (/metrics)
  • 🚧 Grafana dashboards (dashboard JSON in deploy/grafana/)
  • βœ… Distributed tracing (in-process request tracer with /v1/traces)
  • βœ… Structured logs (JSON to stdout)
  • βœ… Metrics (counters, gauges, histograms, unified /v1/metrics endpoint)
  • 🚧 Alerts (Alertmanager rules planned)
  • βœ… Health endpoints (/health)

Quick Start

One-Command Install (recommended)

Windows (PowerShell):

irm https://raw.githubusercontent.com/rachidSabah/codingghosts/main/scripts/install.ps1 | iex

Linux / macOS / WSL:

curl -fsSL https://raw.githubusercontent.com/rachidSabah/codingghosts/main/scripts/install.sh | bash

The installer automatically:

  1. Installs Node.js 22+ (via nvm/winget if missing)
  2. Installs pnpm
  3. Clones the repo
  4. Installs all dependencies
  5. Builds all packages
  6. Registers the anx CLI globally
  7. Starts the gateway (background, 127.0.0.1:8787)
  8. Starts the dashboard (background, localhost:3000)
  9. Verifies health
  10. Detects coding agents
  11. Opens the dashboard in your browser

After installation:

Run with Docker

# Clone
git clone https://github.com/rachidSabah/codingghosts.git
cd codingghosts

# Set at least one provider key
export OPENAI_API_KEY=sk-...

# Run
docker compose up

# Gateway: http://localhost:8787
# Dashboard: http://localhost:3000

Run natively

# Requires Node 22+ and pnpm 9+
corepack enable
pnpm install
pnpm build

# Start gateway
pnpm --filter @anx/gateway start

# In another terminal, start dashboard
pnpm --filter @anx/dashboard dev

Use it

# Drop-in replacement for OpenAI API
curl http://localhost:8787/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "gpt-4",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'
// Or use the SDK
import { NexusClient } from '@anx/sdk';

const client = new NexusClient({
  baseUrl: 'http://localhost:8787',
  apiKey: process.env.NEXUS_API_KEY,
});

const response = await client.chat.completions.create({
  model: 'gpt-4',
  messages: [{ role: 'user', content: 'Hello!' }],
});

Use the CLI

# Install
pnpm --filter @anx/cli build
ln -s $(pwd)/packages/cli/dist/bin.js /usr/local/bin/anx

# Chat
anx chat --model gpt-4 --message "Hello, world"

# List providers
anx providers list

# Health check
anx health

Auto-configure native integrations

The gateway ships with 19 native integrations that auto-configure AI tools to route through it:

# List all integrations + their status
anx integrations list

# Configure Claude Code to use the gateway (writes ~/.claude/settings.json)
anx integrations install claude-code

# Configure OpenCode + OpenCode Go + OpenCode Zen together
anx integrations install opencode opencode-go opencode-zen

# Configure every installed tool in one shot (idempotent)
anx integrations install --all

# Verify a tool can reach the gateway
anx integrations verify claude-code
CLI tools Editors IDEs
claude-code cursor vscode
codex-cli continue jetbrains
gemini-cli cline
hermes-cli roo-code
opencode zed
opencode-go neovim
opencode-zen emacs
aider
openhands

See docs/INTEGRATIONS.md for the full table and per-tool config paths.

πŸ’‘ Prefer automation? Use anx integrations install claude-code (or --all) instead of editing config files by hand. See docs/INTEGRATIONS.md.

Architecture

See docs/ARCHITECTURE.md for the full design. TL;DR:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Dashboard (Next.js)                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚ WebSocket + REST
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Gateway (Fastify, port 8787)            β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ REST API β”‚  β”‚   SSE    β”‚  β”‚   WS     β”‚  β”‚   MCP   β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜  β”‚
β”‚       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β”‚
β”‚                         β”‚                                β”‚
β”‚                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”                       β”‚
β”‚                β”‚  ChatCompletion β”‚                       β”‚
β”‚                β”‚    Use Case     β”‚                       β”‚
β”‚                β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜                       β”‚
β”‚       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”              β”‚
β”‚       β”‚                 β”‚                 β”‚              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”        β”‚
β”‚  β”‚ Routing β”‚     β”‚   Plugins   β”‚    β”‚ Failover  β”‚        β”‚
β”‚  β”‚ Engine  β”‚     β”‚   Runtime   β”‚    β”‚           β”‚        β”‚
β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚
β”‚       β”‚                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚            Provider Adapters                    β”‚    β”‚
β”‚  β”‚  OpenAI Β· Anthropic Β· Google Β· DeepSeek Β· ...   β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Repository Layout

agent-nexus-gateway/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ gateway/        # Fastify HTTP server (the gateway itself)
β”‚   β”œβ”€β”€ dashboard/      # Next.js dashboard
β”‚   └── desktop/        # Electron app (planned)
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ core/           # Hexagonal core: domain, ports, use cases
β”‚   β”œβ”€β”€ providers/      # 17 provider adapters
β”‚   β”œβ”€β”€ routing/        # Routing engine extensions
β”‚   β”œβ”€β”€ plugins/        # Plugin framework
β”‚   β”œβ”€β”€ integrations/   # 19 native tool integrations (Claude Code, OpenCode, …)
β”‚   β”œβ”€β”€ networking/     # Proxy, DoH, diagnostics
β”‚   β”œβ”€β”€ security/       # Vault, RBAC, JWT
β”‚   β”œβ”€β”€ observability/  # Telemetry, Prometheus, structured logs
β”‚   β”œβ”€β”€ mcp-server/     # MCP server
β”‚   β”œβ”€β”€ mcp-client/     # MCP client
β”‚   β”œβ”€β”€ a2a/            # Agent-to-Agent protocol
β”‚   β”œβ”€β”€ cli/            # CLI
β”‚   β”œβ”€β”€ sdk/            # TypeScript SDK
β”‚   └── shared/         # Common utilities
β”œβ”€β”€ deploy/
β”‚   β”œβ”€β”€ docker/         # Dockerfile + Prometheus config
β”‚   β”œβ”€β”€ k8s/            # Kubernetes manifests
β”‚   └── helm/           # Helm chart
β”œβ”€β”€ docs/               # Architecture, roadmap, API docs
β”œβ”€β”€ .github/            # CI, issue templates, SECURITY.md, CONTRIBUTING.md
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ package.json
β”œβ”€β”€ pnpm-workspace.yaml
β”œβ”€β”€ turbo.json
└── tsconfig.base.json

Documentation

Roadmap

See docs/ROADMAP.md. Highlights:

  • 0.2 β€” Semantic cache, prompt cache (Anthropic cache_control), OpenTelemetry SDK integration
  • 0.3 β€” Workflow engine v1, RAG, MCP marketplace
  • 0.4 β€” Multi-agent orchestration UI, knowledge graphs
  • 0.5 β€” AWS Bedrock, Vertex AI adapters
  • 1.0 β€” Stable API, desktop app, extension marketplace

Comparison

Feature Agent Nexus Gateway OmniRoute Free Claude Code
Architecture Hexagonal + DDD Monolithic Single-purpose
OpenAI-compat API βœ… βœ… β€”
Streaming βœ… βœ… βœ…
WebSocket βœ… β€” β€”
MCP Server βœ… β€” β€”
MCP Client βœ… β€” β€”
A2A βœ… β€” β€”
Plugin framework βœ… β€” β€”
Dashboard βœ… β€” β€”
CLI βœ… β€” βœ…
Docker βœ… βœ… β€”
Kubernetes βœ… β€” β€”
RBAC βœ… β€” β€”
Encrypted vault βœ… β€” β€”
Audit log βœ… β€” β€”
Proxy support βœ… β€” β€”
17 provider adapters βœ… ~10 1
Honest (no limit evasion) βœ… βœ… ❌

Uninstall

Windows (PowerShell):

irm https://raw.githubusercontent.com/rachidSabah/codingghosts/main/scripts/uninstall.ps1 | iex

Linux / macOS / WSL:

curl -fsSL https://raw.githubusercontent.com/rachidSabah/codingghosts/main/scripts/uninstall.sh | bash

Or manually:

# Stop processes
pkill -f 'node.*gateway/dist/bin'
pkill -f 'next dev'

# Remove files
rm -rf ~/.agent-nexus/codingghosts
rm -f ~/.local/bin/anx

# Windows PowerShell:
#   Stop-Process -Name node -Force
#   Remove-Item -Recurse -Force "$env:USERPROFILE\.agent-nexus"
#   Remove-Item "$env:USERPROFILE\.local\bin\anx.cmd"

Node.js and pnpm are left installed (remove manually if needed).

License

Apache-2.0. See LICENSE.

Acknowledgements

Built on the shoulders of giants. Inspired by:

  • LiteLLM β€” for the OpenAI-compat abstraction idea
  • OpenRouter β€” for the routing-as-a-service model
  • Anthropic's MCP β€” for the protocol design
  • Fastify β€” for the best Node.js HTTP framework
  • Next.js β€” for the dashboard framework

Star History

Star History Chart

About

codingghosts

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages