Smart Routing in NadirClaw

How NadirClaw decides if a prompt is simple or complex with an embedding classifier, routes across two or three model tiers, and applies routing modifiers.

NadirClaw uses a binary classifier built on sentence embeddings to decide whether a prompt is simple or complex. Classification adds roughly 10ms of overhead per request.

How it works

By default, NadirClaw routes across two tiers:

  • Simple -- routed to your cheap model (e.g. Gemini Flash, GPT-4o Mini)
  • Complex -- routed to your premium model (e.g. Claude Sonnet, GPT-4o)

Set NADIRCLAW_CLASSIFIER=cascade and add a NADIRCLAW_MID_MODEL to enable optional 3-tier routing with a mid-range model in between.

Routing modifiers

Beyond the base classifier, NadirClaw applies a set of heuristic modifiers that override or adjust the routing decision:

Agentic detection

Tool-use calls, agent system prompts, or conversations with more than 10 messages are automatically routed to the complex model.

Reasoning detection

Prompts containing phrases like "step by step", "think carefully", or "reason through" are routed to the reasoning model when configured.

Vision routing

Requests containing image content parts are automatically detected and routed to a vision-capable model.

Session persistence

Multi-turn conversations stick to the same model for the entire session (30-minute TTL) to maintain consistency.

Context window filtering

If a prompt exceeds a model's context window, NadirClaw automatically selects a model with a larger window.

Test the classifier

Use the CLI to see how NadirClaw would classify a prompt without making an actual LLM call:

Classify a prompt
nadirclaw classify "Explain the tradeoffs between microservices and monoliths"

# Output:
# Tier:       complex
# Confidence: 0.91
# Model:      claude-sonnet-4-20250514
# Modifiers:  none

Routing profiles

Set model in your request to one of these profile names to override the default routing behaviour:

ProfileBehaviour
autoDefault -- classifier decides (simple or complex)
ecoAlways route to the simple model
premiumAlways route to the complex model
freeRoute to the free model
reasoningRoute to the reasoning model

Model aliases

For convenience, NadirClaw recognises short aliases for popular models:

AliasModel
sonnetclaude-sonnet-4-20250514
opusclaude-opus-4-20250514
haikuclaude-3-5-haiku-20241022
gpt4gpt-4o
gpt5gpt-5
flashgemini-2.0-flash
gemini-progemini-2.5-pro
deepseekdeepseek-chat
llamallama-3.3-70b

Pages on this site

Machine-readable summaries of this site: llms.txt and llms-full.txt.