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

# Pareto Router

> Pick a coding model by minimum coding score without choosing a specific model

The [Pareto Router](https://openrouter.ai/openrouter/pareto-code) (`openrouter/pareto-code`) selects a coding model based on benchmark scores. You set a single `min_coding_score` preference between `0` and `1`, which selects one of three tiers of coding models, and the router sends your request to one model from that tier. The value picks a tier; it is not a score a model has to reach (see [The `min_coding_score` parameter](#the-min_coding_score-parameter)). The router picks one model per request by score and price and doesn't adapt its choice to each turn the way the [Auto Router](https://openrouter.ai/docs/guides/routing/routers/auto-router.md) does. [Session stickiness](#session-stickiness) keeps a session on the same model when it can.

## Overview

The Pareto Router is tuned for coding use cases. It builds a shortlist from the models currently available on OpenRouter that have the highest [coding score](#coding-score). The router groups the shortlist into three tiers by score, and your `min_coding_score` picks the tier of models you want to route to. Within the chosen tier the router selects the cheapest model that is currently available (or the fastest, when you request the `:nitro` variant).

The name comes from [Pareto efficiency](https://en.wikipedia.org/wiki/Pareto_efficiency): the goal is to give you a strong coder without overspending. The exact shortlist evolves over time as new models land and benchmarks shift.

## Coding score

A model's coding score is its FrontierCode-AA 2.0 result, as measured by [Artificial Analysis](https://artificialanalysis.ai/). FrontierCode-AA 2.0 is Artificial Analysis's run of Cognition's FrontierCode 2.0: 132 tasks that each ask an agent to make a change to a real open-source repository, graded with held-out tests and a rubric on whether the change is good enough for a maintainer to merge. An attempt that fails a blocking check scores zero, and a model's score is the average across the tasks, between `0` and `1`. Artificial Analysis describes the benchmark in its [methodology](https://artificialanalysis.ai/methodology/intelligence-benchmarking). The rest of this page calls it the coding score.

A model that Artificial Analysis hasn't scored isn't on the shortlist, and no other benchmark stands in for a missing score. A score of `0` is a score: the model is ranked, last. When two models have the same coding score, the cheaper one ranks first.

## Usage

Set your model to `openrouter/pareto-code` and optionally pass the `pareto-router` plugin to choose a tier with `min_coding_score`. The examples on this page pass `0.4`, which selects the medium tier, as any value from `0.33` up to `0.66` does; leave it out to get the high tier:

```typescript title="TypeScript SDK" expandable lines theme={null}
import { OpenRouter } from '@openrouter/sdk';

const openRouter = new OpenRouter({
  apiKey: '<OPENROUTER_API_KEY>',
});

const response = await openRouter.responses.send({
  responsesRequest: {
    model: 'openrouter/pareto-code',
    plugins: [
      {
        id: 'pareto-router',
        minCodingScore: 0.4,
      },
    ],
    input: 'Write a Python function that merges two sorted lists.',
  },
});

if (!('output' in response)) {
  throw new Error('Expected a non-streaming response');
}

const message = [...response.output].reverse().find((item) => item.type === 'message');
console.log(message?.content.find((part) => part.type === 'output_text')?.text);
console.log('Model used:', response.model);
```

```bash title="cURL" lines theme={null}
curl https://openrouter.ai/api/v1/responses \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openrouter/pareto-code",
    "plugins": [
      {
        "id": "pareto-router",
        "min_coding_score": 0.4
      }
    ],
    "input": "Write a Python function that merges two sorted lists."
  }'
```

## Default Settings

Instead of passing the `pareto-router` plugin on every API request, you can configure a default `min_coding_score` in the dashboard:

1. Navigate to [Settings > Plugins](https://openrouter.ai/settings/plugins)
2. Find the **Pareto Router** row and click the configure (gear) icon
3. Select a quality tier — **High**, **Medium**, or **Low** — or choose **Custom score** to enter a specific value between `0` and `1`
4. Click **Save**
5. Toggle the plugin **on** to apply it to all requests using `openrouter/pareto-code`

Once enabled, the configured `min_coding_score` is automatically applied to every request that uses `openrouter/pareto-code`, without needing to include the `plugins` array in your API calls.

> [!NOTE]
>
> You can still override the default on a per-request basis by passing the `pareto-router` plugin in your request's `plugins` array. To prevent per-request overrides, enable "Prevent overrides" in the plugin configuration.

## The `min_coding_score` parameter

`min_coding_score` is an optional number between `0` and `1`, where `1` is best. The router maps it to one of three quality tiers. The tiers come from the shortlist's [coding scores](#coding-score): the router clusters the shortlist into three groups of similar scores, and each tier includes every model in the tiers above it.

| `min_coding_score` | Tier | Models in the tier |
| - | - | - |
| `>= 0.66` | high | the highest-scoring group |
| `>= 0.33`, `< 0.66` | medium | the two highest-scoring groups |
| `< 0.33` | low | the whole shortlist |
| omitted | high (default) | the highest-scoring group |

If you omit `min_coding_score`, the router defaults to the strongest available coders. Within a tier, the router picks the cheapest available model, or the fastest by p50 throughput when you request the `:nitro` variant.

> [!NOTE]
>
> The router resolves a primary coding model plus up to two same-tier fallbacks. The primary is what serves your request. The fallbacks only fire on transient provider errors or rate limits, they do not load-balance traffic. If the entire tier has no models currently published on OpenRouter, the router steps into a neighboring tier instead. The response `model` field always reports the concrete model that handled the request.

> [!NOTE]
>
> `min_coding_score` selects a tier. It isn't a threshold on the [coding score](#coding-score), so `min_coding_score=0.66` doesn't mean "models with a coding score of at least 0.66". Tiers are relative to the current shortlist, and the capability bar implied by a given value shifts as the frontier moves: a new strong release can move existing models into a lower tier, so `min_coding_score=0.66` always means "the top group of the current shortlist" rather than "above an absolute capability score".

## Response

The response includes the `model` field showing which coding model was actually used:

```json lines theme={null}
{
  "id": "gen-...",
  "object": "response",
  "model": "anthropic/claude-opus-4.8",
  "status": "completed",
  "output": [
    {
      "type": "message",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "..."
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 42,
    "output_tokens": 128,
    "total_tokens": 170
  }
}
```

## How It Works

1. **Tier resolution**: Your `min_coding_score` value is mapped to one of three tiers (`high`, `medium`, `low`) using the thresholds in the table above.
2. **Candidate filtering**: The router takes the tier's shortlist and filters it to models that are currently published on OpenRouter. If coding scores are unavailable, the router uses a fixed fallback shortlist for each tier instead.
3. **Selection**: The filtered shortlist is sorted by price ascending, or by p50 throughput descending when you request the `:nitro` variant. The top entry becomes the primary model and the next two are kept as same-tier fallbacks.
4. **Runtime fallback**: If the primary's endpoints are unavailable due to transient provider errors or rate limits, the request cascades through the same-tier fallbacks. Only when the entire tier is missing from the catalog does the router step into a neighboring tier.
5. **Request forwarding**: Your request is forwarded to the selected model.

## Session Stickiness

The Pareto Router reuses the selected **model** and **provider** on a best-effort basis so that subsequent requests in the same conversation route to the same place. This keeps behavior consistent within a conversation and maximizes [prompt cache](https://openrouter.ai/docs/guides/best-practices/prompt-caching.md) hits. The cached model is promoted only while it remains in the current candidate shortlist; if it drops out (for example after a `min_coding_score` change or a shortlist update), the router selects a different model.

Stickiness applies at two levels:

* **Implicit (automatic)**: OpenRouter derives a conversation fingerprint from your request (hashing the first system message and first user message). Once the provider reports prompt cache usage, the model and provider are reused for that conversation while the model remains in the candidate shortlist. No configuration needed.
* **Explicit (`session_id`)**: When you include a `session_id`, stickiness kicks in on the first successful response — even before cache usage is observed. The same best-effort rule applies: the model is reused only while it stays in the shortlist. This is recommended for multi-turn coding sessions and agent workflows where you want consistent routing from the start.

In both cases, the cache expires after **5 minutes** of inactivity. Each successful request resets the timer. If the cached provider returns an error, the cache is not updated, allowing the next request to be re-routed.

For full details on how sticky routing works, cache key granularity, and the `x-session-id` header, see [Provider Sticky Routing](https://openrouter.ai/docs/guides/best-practices/prompt-caching.md#provider-sticky-routing).

### Example with `session_id`

```typescript title="TypeScript SDK" expandable lines theme={null}
const response = await openRouter.responses.send({
  responsesRequest: {
    model: 'openrouter/pareto-code',
    sessionId: 'my-coding-session-123',
    plugins: [
      {
        id: 'pareto-router',
        minCodingScore: 0.4,
      },
    ],
    input: 'Write a Python function that merges two sorted lists.',
  },
});

if (!('output' in response)) {
  throw new Error('Expected a non-streaming response');
}
if (response.status !== 'completed') {
  throw new Error(response.error?.message ?? `Response ended as ${response.status}`);
}
const previousOutput = response.output.map((item) => {
  if (item.type === 'reasoning') return item;
  if (item.type !== 'message') throw new Error(`Unexpected output item: ${item.type}`);

  const content = item.content.filter(
    (part) => part.type === 'output_text' || part.type === 'refusal',
  );
  if (content.length !== item.content.length) {
    throw new Error('Received an unsupported message content type');
  }
  return { ...item, content };
});

// Subsequent requests with the same session_id may reuse the same model and provider
const followUp = await openRouter.responses.send({
  responsesRequest: {
    model: 'openrouter/pareto-code',
    sessionId: 'my-coding-session-123',
    plugins: [
      {
        id: 'pareto-router',
        minCodingScore: 0.4,
      },
    ],
    input: [
      { role: 'user', content: 'Write a Python function that merges two sorted lists.' },
      ...previousOutput,
      { role: 'user', content: 'Now add type hints and docstrings.' },
    ],
  },
});
```

```bash title="cURL" lines theme={null}
curl https://openrouter.ai/api/v1/responses \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openrouter/pareto-code",
    "session_id": "my-coding-session-123",
    "plugins": [
      {
        "id": "pareto-router",
        "min_coding_score": 0.4
      }
    ],
    "input": "Write a Python function that merges two sorted lists."
  }'
```

### Why It Matters for the Pareto Router

The Pareto Router selects a model based on coding score and cost — different requests could resolve to different models as the shortlist evolves. Session stickiness prefers the previously selected **model** — not just the provider — so a multi-turn coding session stays on the same model while that model remains eligible. This avoids unnecessary mid-conversation model switches that could lead to inconsistent code style or lost prompt cache.

## Pricing

The Pareto Router itself adds no fee. You pay only for the underlying model that handles the request. Because model selection varies across the shortlist, per-request cost will vary too. Use a lower `min_coding_score` when cost is the primary concern.

## Limitations

* **Coding only**: `openrouter/pareto-code` is tuned for coding tasks. For other use cases, use a different router or choose a specific model.
* **Model selection may change over time**: For a given `min_coding_score`, the same model is selected deterministically (sorted by price). However, the selected model may change when the underlying shortlist is updated (e.g. new models are added, Artificial Analysis publishes new coding scores, or the tiers regroup as scores change). Within a conversation, [session stickiness](#session-stickiness) keeps your requests on the same model and provider to maximize cache hits.
* **Coding score only**: `min_coding_score` is the only router parameter. You can't directly cap cost or latency per request.

## Related

* [Auto Router](https://openrouter.ai/docs/guides/routing/routers/auto-router.md) - Intelligent model selection across all task types
* [Free Models Router](https://openrouter.ai/docs/guides/routing/routers/free-router.md) - Zero-cost model selection
* [Body Builder](https://openrouter.ai/docs/guides/features/body-builder.md) - Generate multiple parallel API requests
* [Model Fallbacks](https://openrouter.ai/docs/guides/routing/model-fallbacks.md) - Configure fallback models
