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

# Ninja Router

> Automatically select models and providers for cost, speed and quality.

<div className="ndoc-feature ndoc-feature-router">
  <div><h2>Route with <code>ninja/auto</code></h2><p>Set your budget and routing strategy. NinjaChat selects an eligible model and provider.</p><a className="ndoc-button" href="/smart-routing">Start routing <span aria-hidden="true">→</span></a></div>
  <div className="ndoc-route-stack" aria-label="Routing flow"><span>Your app</span><i aria-hidden="true">↓</i><strong>ninja/auto</strong><i aria-hidden="true">↓</i><span>Eligible model & provider</span></div>
</div>

## Routing strategies

<CardGroup cols={2}>
  <Card title="Cost" icon="coins" href="/smart-routing#routing-strategies">Prefer lower-cost models that meet the task requirements.</Card>
  <Card title="Quality" icon="circle-check" href="/smart-routing#routing-strategies">Prioritize more capable models for demanding requests.</Card>
  <Card title="Latency" icon="gauge-high" href="/smart-routing#routing-strategies">Prefer faster responses based on measured traffic.</Card>
  <Card title="Balanced" icon="scale-balanced" href="/smart-routing#routing-strategies">Use the router's curated model order for each task.</Card>
</CardGroup>

## Send a routed request

Set your model to `ninja/auto`. Add a routing strategy when you want to override the default.

```typescript theme={null}
const response = await client.responses.create({
  model: "ninja/auto",
  input: "Review this repository migration plan.",
  routing: { strategy: "balanced" },
});

console.log(response.routing.resolved_model);
console.log(response.cost_usd);
```

Create `client` with your NinjaChat API key using the [API quickstart](/quickstart). Each response identifies the model and provider used, the cost, and the request ID.

## Control each request

<CardGroup cols={2}>
  <Card title="Budgets & data policies" icon="sliders" href="/budget-routing">Limit request costs and choose eligible provider policies.</Card>
  <Card title="Fallbacks" icon="arrow-right-arrow-left" href="/fallback-chains">Try another eligible model or provider when a request fails.</Card>
  <Card title="Compare responses" icon="columns-3" href="/compare">Run the same request across models to compare the results.</Card>
  <Card title="Request traces" icon="chart-line" href="/observability">Inspect cost, latency, selected models and request traces.</Card>
</CardGroup>

You pay the selected model and provider's published rate for actual usage. See [pricing](/pricing) for current rates.
