Skip to content

Shreai/shre-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

141 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

shre-router — Intelligent Prompt Router

Port: 5497 Status: Active License: Proprietary — source-available. A written license from NirLab Inc is required before production/commercial use. Contact: legal@nirlab.com · https://nirlab.com/aros/enterprise


Overview

shre-router is the intelligent prompt routing engine for the Shre platform. It analyzes incoming prompts across 5 signal dimensions and routes them through a 10-gate decision engine to select the optimal model for each request.

5 Signal Dimensions

  1. Modality — Text, image, audio, video, or multimodal input
  2. Task Type — Classification, generation, code, tool use, reasoning, chat
  3. Complexity — Token depth, chain-of-thought requirements, domain expertise needed
  4. Latency — Real-time (<500ms), interactive (<5s), batch (unbounded)
  5. Budget — Cost ceiling per request, local-preferred, cloud-allowed

Model Connectivity Status

Model ID Provider Status
Qwen 3 8B ollama/qwen3:8b Ollama (local) Connected
LLaMA 3.2 3B ollama/llama3.2:3b Ollama (local) Connected
Claude Haiku 4.5 anthropic/claude-haiku-4-5-20251001 Anthropic Connected
Claude Sonnet 4.6 anthropic/claude-sonnet-4-6 Anthropic Connected
Claude Opus 4.6 anthropic/claude-opus-4-6 Anthropic Connected
GPT-5.2 openai/gpt-5.2 OpenAI Not Connected
Gemini 1.5 Pro google/gemini-1.5-pro Google Not Connected
G5 Ensemble ensemble/G5 Ensemble Connected

10-Gate Routing Decision Tree

                    ┌─────────────────┐
                    │  Incoming Prompt │
                    └────────┬────────┘
                             │
                    ┌────────▼────────┐
                    │ Analyze Signals  │
                    │ (5 dimensions)   │
                    └────────┬────────┘
                             │
              ┌──────────────▼──────────────┐
              │ G1: Multimodal?             │──yes──→ google/gemini-1.5-pro
              └──────────────┬──────────────┘
                             │ no
              ┌──────────────▼──────────────┐
              │ G2: Realtime + high conf?   │──yes──→ ollama/llama3.2:3b
              └──────────────┬──────────────┘
                             │ no
              ┌──────────────▼──────────────┐
              │ G3: Simple classification?  │──yes──→ ollama/qwen3:8b
              └──────────────┬──────────────┘
                             │ no
              ┌──────────────▼──────────────┐
              │ G4: Code generation?        │──yes──→ openai/gpt-5.2
              └──────────────┬──────────────┘
                             │ no
              ┌──────────────▼──────────────┐
              │ G5: Tool use / function?    │──yes──→ openai/gpt-5.2
              └──────────────┬──────────────┘
                             │ no
              ┌──────────────▼──────────────┐
              │ G6: Deep reasoning needed?  │──yes──→ anthropic/claude-opus-4-6
              └──────────────┬──────────────┘
                             │ no
              ┌──────────────▼──────────────┐
              │ G7: Multi-expert consensus? │──yes──→ ensemble/G5
              └──────────────┬──────────────┘
                             │ no
              ┌──────────────▼──────────────┐
              │ G8: Budget = local only?    │──yes──→ ollama/qwen3:8b
              └──────────────┬──────────────┘
                             │ no
              ┌──────────────▼──────────────┐
              │ G9: Quick chat / low stakes?│──yes──→ anthropic/claude-haiku-4-5-20251001
              └──────────────┬──────────────┘
                             │ no
              ┌──────────────▼──────────────┐
              │ G10: DEFAULT                │──────→ anthropic/claude-sonnet-4-6
              └─────────────────────────────┘

Self-hosting

Heads-up: the production Docker build copies two sibling NirLab packages — shre-sdk and shre-model-config — which are not part of this public repo. The source here is complete enough to read, evaluate, and integrate against the API, but a from-scratch build requires those packages. Contact licensing for the full build context.

Requirements: Node.js 22+, an Ollama instance for local models, and provider API keys (Anthropic / OpenAI / Google) for cloud routes.

# Install
npm install

# Develop (hot reload on port 5497)
npm run dev

# Production build + run
npm run build
npm start        # serves on PORT (default 5497)

Configuration is via environment variables (provider keys, PORT, Ollama host). Verify with curl localhost:5497/health.


API Endpoints

Method Path Description
GET /health Health check — returns service status and model connectivity
GET /v1/models List all configured models and their connection status
POST /v1/route Route a single prompt — returns selected model + reasoning
POST /v1/route/batch Route multiple prompts in one request
GET /v1/stats Routing statistics — gate hit counts, latency, model usage

License

Proprietary — All Rights Reserved. © 2026 NirLab Inc. Published source-available for evaluation and integration reference. See LICENSE. A separate written license is required before production or commercial use: legal@nirlab.com.


Service: shre-router | Port: 5497 | Part of the Shre AI platform

About

Shre AI Smart Gateway — routes prompts to optimal models, multi-key pools, tool execution

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors