> ## 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.

# Advanced options

> Per-call routing controls.

Everything else in a request, such as tools, `stream` or `max_tokens`, works as in the OpenAI and Anthropic APIs.

## Cost and quality per call

For a finer dial than [`target`](https://docs.levanto.ai/llms/routers#spending-target), send `routing.cost_quality_tradeoff`, from 0 (best quality) to 10 (cheapest). It applies to that call only:

```json theme={"theme":"github-light"}
{
  "model": "auto",
  "routing": {"cost_quality_tradeoff": 0},
  "messages": [{"role": "user", "content": "Prove that the sum of two even integers is even."}]
}
```

## Conversations

A request that continues an earlier conversation stays on that conversation's model, so the model's prompt cache keeps working. To group requests yourself, send the same `X-Routing-Conversation-Id` header (up to 256 characters) on each of them.

## Fallbacks

With `"auto"`, a request that fails before the model starts answering is retried on the router's next choice. The `X-Routing-Rank` response header is `1` for the first choice and `2` for the fallback.

## Images

Requests that contain images go only to models that accept images. A named model that doesn't accept them returns `400` with `code: "unsupported_modality"`.

## Long prompts

`"auto"` leaves out models whose context can't hold the request. When no model can, the answer is `400` with `code: "context_length_exceeded"`.

## Count tokens

`POST /v1/messages/count_tokens` takes an Anthropic Messages body and returns an estimate of its input tokens:

```bash theme={"theme":"github-light"}
curl -s https://api.levanto.ai/v1/messages/count_tokens \
  -H "Authorization: Bearer $LEVANTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "auto",
    "messages": [{"role": "user", "content": "Reply with the word ok."}]
  }'
```

```json theme={"theme":"github-light"}
{"input_tokens": 6}
```

Error bodies are in [Errors](https://docs.levanto.ai/reference/errors.md#llms).


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