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

# Routers

> Send model "auto": a strong model when the request is hard, a cheap one when it isn't.

Create routers under [Routers](https://platform.levanto.ai/routing/configs) in the dashboard. Each has its own key and spending target.

## Spending target

A key without a router uses Balanced.

| Target | Spends |
| - | - |
| `economy` | Least |
| `balanced` | In between |
| `quality` | Most |

To change the target for one call, add `target` to the body:

```bash theme={"theme":"github-light"}
curl -s https://api.levanto.ai/v1/chat/completions \
  -H "Authorization: Bearer $LEVANTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "auto",
    "target": "quality",
    "messages": [{"role": "user", "content": "Prove that the sum of two even integers is even."}]
  }'
```

## Which model answered

Besides the response's `model` field, the `X-Routing-Model` header names it:

```text theme={"theme":"github-light"}
x-routing-model: deepseek-v4.1-flash-1017
```

## Who serves the model

You choose this when you create a router.

| Option | What happens |
| - | - |
| **Via Levanto** | Sage and open-weight models, paid from your Levanto balance. |
| **Your OpenRouter key** | We pick the model and forward your requests to OpenRouter, which bills you. |
| **Suggest model only** | We return the best model for your prompt. You call it. |

## Suggest model only

`POST /v1/routing/rank` takes the request you are about to make and the models you can call, with your prices in dollars per million tokens. It returns them ranked, best first.

```bash theme={"theme":"github-light"}
curl -s https://api.levanto.ai/v1/routing/rank \
  -H "Authorization: Bearer $LEVANTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request": {"messages": [{"role": "user", "content": "Summarize this ticket: the customer was charged twice and wants a refund."}]},
    "routing": {
      "cost_quality_tradeoff": 5,
      "candidates": [
        {"id": "opus@my-provider", "model": "anthropic/claude-opus-5.5",
         "pricing": {"input": 5, "cache_read": 0.5, "output": 25}},
        {"id": "flash@my-provider", "model": "deepseek/deepseek-v4-flash",
         "pricing": {"input": 0.1, "cache_read": 0.02, "output": 0.4}}
      ]
    }
  }'
```

Response, abridged:

```json theme={"theme":"github-light"}
{
  "object": "routing.ranking",
  "ranked": [
    {
      "candidate_id": "flash@my-provider",
      "expected_quality": 0.7765,
      "expected_cost_usd": 0.0025062,
      "expected_usage": {"input_tokens": 18, "cache_read_tokens": 0, "output_tokens": 6261}
    },
    {
      "candidate_id": "opus@my-provider",
      "expected_quality": 0.8758,
      "expected_cost_usd": 0.02254,
      "expected_usage": {"input_tokens": 18, "cache_read_tokens": 0, "output_tokens": 898}
    }
  ]
}
```

`cost_quality_tradeoff` goes from 0 (best quality) to 10 (cheapest). Call `ranked[0]` with your own provider client.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.