NadirClaw is an open-source LLM router designed to optimize costs and performance in AI applications. By intelligently classifying and routing prompts, it directs simple queries to affordable models and complex requests to premium providers, enhancing efficiency and saving resources. Compatible with any tool using the OpenAI API.
NadirClaw: An Open-source LLM Router for Efficient Prompt Management
NadirClaw is an innovative routing solution designed specifically for LLM (Large Language Model) interactions. This router intelligently classifies prompts and directs them to the most suitable LLM providers, automatically optimizing costs and performance. By routing simple prompts to economical or local models and complex prompts to premium models, NadirClaw enables users to effectively manage their resources without compromising on quality.
How Does It Work?
NadirClaw serves as an OpenAI-compatible proxy, functioning seamlessly with any AI tool that interacts with the OpenAI API. It processes incoming prompts in less than 10 milliseconds, utilizing a binary complexity classifier based on sentence embeddings. The architecture can be visualized as follows:
Your AI Tool ──> NadirClaw (:8856/v1) ──> simple prompts ──> Gemini Flash / Ollama (free/cheap)
──> complex prompts ──> GPT / Claude / Gemini Pro (premium)
──> reasoning tasks ──> o3 / DeepSeek-R1 (reasoning)
──> agentic requests ──> complex model (auto-detected)
Key Features
- Intelligent Routing: Classifies prompts rapidly and directs them accordingly to achieve cost efficiency.
- Complexity Detection: Automatically identifies agentic requests, ensuring proper model assignment for multi-step or tool interactions.
- Reasoning Optimization: Routes prompts that require advanced reasoning to suitable models optimized for such tasks.
- Session Management: Maintains session persistence, allowing for consistent model usage across multi-turn conversations.
- Model Aliases and Handling Profiles: Use concise model references and optimize routing based on individual needs with profiles like auto, eco, premium, or reasoning.
- Seamless Integration: Works with leading AI tools such as OpenClaw, and Codex, and supports various LLM providers through an OpenAI-compatible API.
Getting Started
NadirClaw is easy to install and configure. Installation can be completed in a single line:
pip install nadirclaw
Followed by an interactive setup to configure models and API keys:
nadirclaw setup
To initiate the router:
nadirclaw serve --verbose
Example API Interaction
Deploy NadirClaw and interact with your AI tool simply:
curl http://localhost:8856/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"messages": [{"role": "user", "content": "What is 2+2?"}]}'
NadirClaw automatically determines the best model for processing this request, ensuring optimal results.
Conclusion
NadirClaw stands out as a practical and cost-effective solution for managing LLM interactions. Through its smart routing capabilities and versatile integrations, it significantly enhances the efficiency of AI tool deployments, making it an invaluable asset for developers and organizations aiming to leverage LLM technology effectively.
No comments yet.
Sign in to be the first to comment.