> ## Documentation Index
> Fetch the complete documentation index at: https://docs.morphllm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Enterprise Model Routing

> Route every Claude Code turn to the right Claude model with an org-wide policy. Configure it in Administration, install it per developer, uninstall in one command.

Most Claude Code turns don't need Opus. A "rename this variable" turn and a "design the migration"
turn hit the same model unless someone intervenes, and that someone is never the developer mid-flow.
Enterprise Model Routing intervenes automatically: a local proxy classifies each turn (difficulty,
ambiguity, domain), walks your org's routing matrix, and sends the turn to the model the policy
picks. Easy turns go to Haiku, hard ones to Opus, and your Opus quota lasts the week.

Developers change nothing about how they work. The proxy sits between the `claude` CLI and Anthropic,
routing against either your org's Anthropic API key or each developer's Claude Pro/Max subscription.
Admins own the policy centrally; edits reach every developer's agent within the hour, no redeploy.

<Note>
  Enterprise Model Routing is part of the enterprise plan. Installing needs only a Morph API key
  from your org's [dashboard](https://morphllm.com/dashboard). Contact
  [info@morphllm.com](mailto:info@morphllm.com) if your org doesn't have the plan yet.
</Note>

## Configure routing in Administration

Open [morphllm.com/dashboard/administration](https://morphllm.com/dashboard/administration) and
select **Model Router**. This is the single control point for your org's policy; clients pull it
from `GET /api/router/matrix` (per-org, ETag cached, refreshed within 12 hours).

Three things live here:

1. **The routing matrix.** Rows match on the three classifier axes (difficulty x ambiguity x domain)
   and map to a model plus an effort level. First matching row wins. The default matrix routes easy
   turns to `claude-haiku-4-5`, medium to `claude-sonnet-4-6`, hard to `claude-opus-4-8`, and keeps
   Claude Code's background calls on Haiku, off the Opus quota.
2. **Permission groups.** Per-user model allowlists, for example: engineers may route to any model,
   everyone else gets the default set. A matrix row that picks a model outside a user's allowlist is
   clamped down a tier for that user.
3. **Seats.** Which users the policy applies to.

To spend less on Opus, point the hard and medium cells at cheaper models. The matrix is the knob;
there is nothing to configure on developer machines when policy changes.

### Analytics

The **Analytics** tab (Administration, next to Model Router) shows what the policy is doing across
the org: model mix per tier, turn volume over time, estimated savings versus routing every turn to
Opus, and a per-user breakdown. Spend figures are input-token estimates at Anthropic list prices,
not billed amounts. Routing events reach the dashboard through a metadata-only emitter; prompt and
completion text never leave the developer's machine.

## Install

Each developer runs the proxy locally. Requirements: macOS or Linux, Node 22+, and the `claude`
CLI (v2.1.x).

<Steps>
  <Step title="Authenticate Claude Code">
    With a Claude Pro/Max subscription, log in once so the proxy can use the subscription token:

    ```bash theme={null}
    claude login
    ```

    Skip this if your org routes through a company Anthropic API key instead (next step).
  </Step>

  <Step title="Run the one-liner">
    ```bash theme={null}
    # subscription upstream (uses the claude login token):
    curl -fsSL https://morphllm.com/router/install.sh | MORPH_API_KEY=sk-... bash

    # or org Anthropic key upstream instead of a personal subscription:
    curl -fsSL https://morphllm.com/router/install.sh | MORPH_API_KEY=sk-... ANTHROPIC_API_KEY=sk-ant-org-... bash
    ```

    The installer authenticates to morphllm.com with your Morph API key, downloads the latest
    routing runtime, verifies its sha256, installs it under `~/.morph/ccr-router`, runs its
    self-tests, and wires the router into `~/.claude-code-router/config.json` (your original
    config is backed up). Prefer to read before running? `curl -fsSLO
            https://morphllm.com/router/install.sh`, review, then `bash install.sh`.
  </Step>

  <Step title="Run Claude Code through it">
    ```bash theme={null}
    morph-claude
    ```

    This starts the local gateway and launches your real `claude` pointed at it, with all your
    arguments passing through (`morph-claude -p "fix the tests"` works). To see routing decisions
    live, run `bash ~/.morph/ccr-router/current/.morph-headless/watch-routing.sh` in a second
    terminal: one line per turn with the chosen model.
  </Step>
</Steps>

Check state any time:

```bash theme={null}
CCR=~/.morph/ccr-router/current/morph-routing
node $CCR/morph-ccr.mjs status    # upstream mode, policy source, routing on/off
node $CCR/morph-ccr.mjs disable   # pause routing (takes effect mid-session)
node $CCR/morph-ccr.mjs enable    # resume
```

`disable` is instant and reversible: Claude Code keeps working through the proxy on the default
model until you `enable` again.

## Upgrade

Re-run the one-liner. It reuses the stored key (no `MORPH_API_KEY` needed), downloads the newer
version if there is one, and flips over atomically; re-running on the current version just
refreshes the wiring. Pin a specific release with `MORPH_ROUTER_VERSION=x.y.z` in front of the
same command.

## Uninstall

One command undoes the install:

```bash theme={null}
morph-claude uninstall
```

It stops the local gateway, restores the exact `~/.claude-code-router/config.json` you had before
installing, and removes `~/.morph/ccr-router` and the `morph-claude` command. Claude Code goes
back to talking to Anthropic directly, as if the router was never there.

## Self-hosted policy

Orgs that want the routing policy on their own infrastructure can serve the matrix from a local
file (`MORPH_MATRIX_FILE`) or their own endpoint (`MORPH_MATRIX_URL`) instead of the hosted
dashboard, and point metrics at their own collector or disable them (`MORPH_METRICS_DISABLED=1`).
The repo's `MORPH.md` covers the self-hosted setup end to end.
