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

# Valar Auto-Router: Coding Balanced

> One model id that answers each request the way ValarCode's Balanced strategy answers Claude Code

`valar-auto-balanced` is the model id of Valar Auto-Router: Coding Balanced, listed on the [Models](https://docs.valarhq.ai/models.md) page like any other model. It answers each request the way ValarCode's **Balanced** strategy answers Claude Code: Valar grades the request and serves it with the model Balanced uses for that difficulty, Claude Opus or Sonnet or OpenAI's GPT on the harder turns, or an open model, so easy requests cost little and hard ones get a stronger model. It is recommended for coding workloads.

Its models are always Balanced's: when Balanced changes, so does `valar-auto-balanced`, and if your organization's Balanced line-up has been adjusted, it follows that too. The console's Models page shows, for your organization, the models that can serve each difficulty on any of the three APIs; the model id stays the same when that list changes.

## Call it

Send `model: "valar-auto-balanced"` to any of Valar's three APIs. The models that can answer depend on the API: the [Messages API](https://docs.valarhq.ai/anthropic-sdk.md) (`POST /v1/messages`) serves Balanced's full line-up, Claude Opus and Sonnet and OpenAI's GPT included, as for Claude Code; **Chat Completions** (`POST /v1/chat/completions`) and **Responses** (`POST /v1/responses`) serve the open models in Balanced's line-up for that API. With a standard API key, `valar-auto` (the model id ValarCode's tool integrations send) is answered as `valar-auto-balanced` on every API.

The examples below use the Messages API. Any Anthropic SDK works with a base URL and key change.

```python Python theme={"system"}
import os
from anthropic import Anthropic

client = Anthropic(
    auth_token=os.environ["VALAR_API_KEY"],
    base_url="https://api.valarhq.ai",  # no /v1: the SDK appends it
)

message = client.messages.create(
    model="valar-auto-balanced",
    max_tokens=4096,
    messages=[{"role": "user", "content": "Refactor this function to remove the global state."}],
)
print(message.model)  # the model that answered
print(next(block.text for block in message.content if block.type == "text"))
```

```ts TypeScript theme={"system"}
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  authToken: process.env.VALAR_API_KEY,
  baseURL: "https://api.valarhq.ai", // no /v1: the SDK appends it
});

const message = await client.messages.create({
  model: "valar-auto-balanced",
  max_tokens: 4096,
  messages: [{ role: "user", content: "Refactor this function to remove the global state." }],
});
console.log(message.model); // the model that answered
```

```bash cURL theme={"system"}
curl https://api.valarhq.ai/v1/messages \
  -H "Authorization: Bearer $VALAR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -d '{"model": "valar-auto-balanced", "max_tokens": 4096, "messages": [{"role": "user", "content": "Refactor this function to remove the global state."}]}'
```

Pick a [completion window](https://docs.valarhq.ai/inference-modes.md#completion-windows) the same way as for any model on the Messages API: `metadata.completion_window` in the body, or the `X-Valar-Completion-Window` header.

## What you get back

* The response's `model` field names the model that answered the request, in the response and in every stream.
* A conversation stays on one model while it runs, and only moves to a stronger one when a later turn needs it. Send the same opening messages on every turn of a conversation.
* Requests with images are answered by a model that reads images.
* Models may emit `thinking` blocks before the text: iterate `content` for the `text` block rather than indexing `content[0]`, and leave room for thinking in `max_tokens`.

## Pricing

Each request is billed at the rate of the model that answered it, on the [serving path](https://docs.valarhq.ai/inference-modes.md) you chose. The [Pricing](https://docs.valarhq.ai/pricing.md) page lists the lowest and highest rate `valar-auto-balanced` can bill per serving path, and your usage shows the model each request was billed as.

## Limits

* Claude and GPT models answer on the Messages API only; Chat Completions and Responses answer with open models.
* Not available on batch: send batch requests to a specific model.
* Context window and output limits (1M tokens in, 128K out) are the smallest of the models it can answer with, so a request that fits them fits every one.


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