# Weave Router

> One endpoint that picks the right model for every request

- Category: Evaluation & Production Ops / Gateways & Routing
- Language: Go
- Licence: Apache-2.0 (from router-v0.2.24; earlier releases shipped under the Elastic License 2.0)
- Repository: https://github.com/weave-os/router
- Website: https://weaveos.com/products/router
- Canonical page: https://ai-tldr.dev/tools/weave-router/
- Updated: 2026-09-24

## In short

Weave Router is a drop-in proxy that speaks the Anthropic Messages, OpenAI Chat Completions and Gemini native APIs, including streaming, tools and vision. It sits in the Gateways & Routing category of the Evaluation & Production Ops tools and is open-source, written in Go and licensed Apache-2.0 (from router-v0.2.24; earlier releases shipped under the Elastic License 2.0).

## Overview

Weave Router is a drop-in proxy that speaks the Anthropic Messages, OpenAI Chat Completions and Gemini native APIs, including streaming, tools and vision. You point Claude Code, Codex, opencode, pi, Cursor or your own application at it instead of the provider, and it decides which model should answer each individual request rather than making you pick one model for a whole session.

The decision is made by a cluster scorer derived from the Avengers-Pro routing paper, running as an in-process ONNX embedder on the same box — not by asking another model to guess. The project's terminology is that it routes per action, not per turn, so a single agent run can mix a cheap model for routine steps with a frontier model for the hard ones. Alongside the hosted providers it can reach open-weight models such as DeepSeek, Kimi, GLM, Qwen, Llama and Mistral through OpenRouter or any OpenAI-compatible endpoint. An optional HMM policy sidecar can run next to the router as an alternative strategy.

In a self-hosted deployment the router, the scorer, Postgres and your provider keys all stay on your machine, with BYOK keys encrypted at rest; prompts go from the router straight to the configured provider, never to Weave. The router emits OTLP traces, shows routing decisions in a bundled dashboard, and returns per-request cost headers. Weave also runs a hosted router that the npm installer points at by default. The code is published by Workweave under the Apache License 2.0 starting with the router-v0.2.24 release line (September 2026); earlier tags keep the Elastic License 2.0 they shipped with.

## What it does

- Per-action routing driven by an on-box cluster scorer derived from Avengers-Pro, not a prompt-based heuristic
- Speaks Anthropic Messages, OpenAI Chat Completions and Gemini native, with streaming, tools and vision supported
- Reaches open-weight models — DeepSeek, Kimi, GLM, Qwen, Llama, Mistral — via OpenRouter or any OpenAI-compatible endpoint
- Bring-your-own-key by default: provider keys stay on your box and are encrypted at rest
- A /v1/route endpoint that returns the routing decision without calling upstream, plus per-session cost and savings and an NDJSON export of raw routing decisions
- OTLP traces out of the box, viewable in the built-in dashboard or exported to Honeycomb, Datadog or Grafana
- An npm installer that wires up Claude Code, the Codex CLI, opencode or pi at user or project scope, with on/off/status switches and model enable/disable from the terminal

## Getting started

The npm installer is the fastest path: with no flags it opens the hosted setup page, and flags pick a client, a scope or a self-hosted router. Self-hosting boots the router and dashboard on your own machine.

1. Wire up your agent

   Requires Node 18 or newer (the Claude Code, opencode and pi paths also need jq). The bare command opens the hosted setup page; the flags install directly from the terminal. Project scope commits the settings file to the repo, and --local targets a self-hosted router on localhost:8080.

```bash
npx @weave-os/router
npx @weave-os/router --claude
npx @weave-os/router --codex
npx @weave-os/router --scope project
npx @weave-os/router --local
```

2. Or self-host the stack

   Drop a provider key into .env.local — OpenRouter is the recommended baseline — and set a dashboard password (without one, inference still runs but dashboard administration is disabled). Then bring up Postgres and the router on port 8080; the setup seeds an rk_ router key and prints it in the logs.

```bash
echo "OPENROUTER_API_KEY=sk-or-v1-..." >> .env.local
echo "ROUTER_ADMIN_PASSWORD=replace-with-a-strong-password" >> .env.local
make full-setup
```

3. Call it like your usual provider

   The same endpoint answers Anthropic-shaped and OpenAI-shaped requests; the router chooses the model behind it. Clients send the rk_ key as a Bearer token — your upstream provider key stays in .env.local.

```bash
curl -sS http://localhost:8080/v1/messages \
  -H "Authorization: Bearer rk_..." \
  -d '{"model":"claude-sonnet-4-5","max_tokens":256,
       "messages":[{"role":"user","content":"hi"}]}'

curl -sS http://localhost:8080/v1/chat/completions \
  -H "Authorization: Bearer rk_..." \
  -d '{"model":"gpt-4o-mini",
       "messages":[{"role":"user","content":"hi"}]}'
```

4. Inspect and toggle routing

   Peek at a routing decision without proxying, watch traffic in the dashboard at http://localhost:8080/ui/, and switch a client back to its normal provider without losing the router config.

```bash
curl -sS http://localhost:8080/v1/route -H "Authorization: Bearer rk_..." -d '...'

npx @weave-os/router off --claude
npx @weave-os/router status --claude
npx @weave-os/router models --claude
```

## When to use it

- Cut the cost of an agentic coding session by sending routine steps to a cheap model and only the hard ones to a frontier model
- Give a team one endpoint that fronts several providers, so model choice is a server-side policy rather than a per-developer setting
- Mix hosted and open-weight models behind a single API without changing application code
- Trace which model answered which request, and at what cost, from the bundled dashboard, the analytics export or an existing OTLP backend

## Version history

- 2026-09-24 router-v0.2.24: The router moved from the Elastic License 2.0 to the Apache License 2.0, starting with router-v0.2.24 (npm @weave-os/router and @workweave/router 0.2.24). Earlier tags and packages keep the licenses they shipped with.
- 2026-06-27: Weave open-sourced the router: a proxy for Claude Code, Codex and Cursor that scores each prompt with an on-box embedder and forwards it to the best model across Anthropic, OpenAI, Gemini and OpenRouter providers. The repository has since moved from workweave/router to weave-os/router, and the npm package from @workweave/router to @weave-os/router (the old name stays as a compatibility alias).
