Skip to content

youngjin39/router-control-public

Repository files navigation

Router Control Public

router-control-public is a small LLM routing proxy for chat workloads.

It focuses on one job: classify a request, choose a profile and model, resolve a provider, and forward the call through an OpenAI-compatible API surface.

Features

  • Local rule-based request classification
  • Profile-driven model selection
  • Capability-aware provider filtering
  • Model pool indirection per provider
  • Fallback routing with lightweight failure tracking
  • OpenAI-compatible POST /v1/chat/completions

API Surface

  • GET /health
  • GET /providers
  • GET /config/all
  • GET /config/profiles
  • GET /config/profiles/:name
  • POST /config/profile
  • POST /classify
  • POST /v1/chat/completions

Quick Start

npm install
cp .env.example .env
npm run build
npm start

The server listens on ROUTER_PORT and defaults to 3000.

Environment

Set provider credentials with environment variables such as:

  • OPENAI_API_KEY
  • ANTHROPIC_API_KEY
  • GOOGLE_API_KEY
  • DEEPSEEK_API_KEY
  • GROQ_API_KEY
  • GITHUB_MODELS_TOKEN
  • OPENROUTER_API_KEY
  • OLLAMA_BASE_URL
  • OMLX_BASE_URL

You can also use OPENAI_API_KEYS or ANTHROPIC_API_KEYS as comma-separated key pools.

Request Headers

Routing hints can be passed with x-router-* headers:

  • x-router-feature
  • x-router-agent-id
  • x-router-session-id
  • x-router-parent-agent-id
  • x-router-project
  • x-router-model-override

Legacy x-openclaw-* aliases are still accepted for compatibility.

Example

curl http://127.0.0.1:3000/v1/chat/completions \
  -H 'content-type: application/json' \
  -H 'x-router-feature: conversation' \
  -d '{
    "messages": [
      { "role": "user", "content": "Explain how fallback routing works." }
    ]
  }'

Configuration

Routing behavior is defined in:

  • src/config/router-config.yaml
  • src/config/profiles.yaml
  • src/config/models.yaml
  • src/config/model-pools.yaml

Development

npm test

Architecture and runtime notes are in ARCHITECTURE.md and docs/architecture/router-architecture.md.

About

LLM routing proxy with profile-based model selection, fallback routing, and an OpenAI-compatible chat API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors