NadirRouter/NadirClaw

Source-available LLM router and AI cost optimizer. Routes simple prompts to cheap or local models and complex ones to premium models, automatically. Drop-in OpenAI-compatible proxy for Claude Code, Codex, Cursor and OpenClaw. Self-hosted, no middleman.

What it solves

Most LLM requests don't need a premium model. In typical coding sessions, 60-70% of prompts are simple — reading files, short questions, formatting — and can be handled by models that cost 10-20x less. NadirClaw cuts AI API costs by routing each prompt to the smallest, cheapest model likely to answer correctly, then verifying the result so you don't pay for a big model when a small one is enough. It also provides built-in cost tracking, fallback chains, and a dashboard so you can see exactly what you saved.

How it works

NadirClaw runs locally as a proxy server (default on localhost:8856) that accepts OpenAI-compatible chat requests. Every request goes through three steps:

  1. Route — a ~10ms embedding classifier predicts the smallest capable model and sends the prompt there first. Routing modifiers (agentic tool loops, reasoning markers, vision content, long context) can override the score and force a stronger tier.
  2. Verify — the cheap answer is scored against quality heuristics (refusal, truncation, JSON-format failures) before it ships. If the score is below a threshold (τ = 0.80), it moves to the next step.
  3. Escalate — when quality fails, NadirClaw automatically steps up to the next-best model in a configurable tier chain. You only pay for the big model when the small one wasn't enough.

It supports three-tier routing (simple/mid/complex) with configurable thresholds, and an N-tier YAML config system with hot-reload. Additional features include fallback chains for model outages, context optimization to reduce token usage, prompt caching, and full streaming via SSE. It works with any tool that speaks the OpenAI or Anthropic API — including Claude Code, Cursor, Aider, and more.

Who it’s for

NadirClaw is for solo developers, self-hosters, and anyone who wants a cost-cutting LLM router running locally. It's source-available under PolyForm Noncommercial 1.0.0 (free for noncommercial use; commercial licenses available). If you're routing production traffic or a team, the hosted Nadir Pro version adds a trained classifier, a live dashboard, and team billing — but NadirClaw gives you the same core routing philosophy without giving up control of your API keys.

Highlights

  • Routes in ~10ms with an embedding classifier — overhead you won't notice
  • Verifier-gated cascade: cheap answer first, escalate only when needed (threshold τ=0.80)
  • Built-in cost tracking: nadirclaw savings, dashboard with per-model and per-day reports
  • Drop-in replacement for any OpenAI-compatible client (also exposes an Anthropic-compatible /v1/messages endpoint)
  • Runs entirely on your machine — your API keys never leave it
  • Fallback chains, context optimization, prompt caching, and session persistence
  • Pluggable classifiers: binary centroid (default), optional DistilBERT or Laya
  • N-tier routing with hot-reloadable YAML profiles and cascade rules
  • Works with Gemini, OpenAI, Anthropic, Ollama, and any LiteLLM-supported provider
  • Includes streaming support, vision routing, agentic detection, and reasoning detection

Related

  • Project
  • Project
  • Project
  • Project
  • Project