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

# Tune results and cost

> Tune Valyu Search: control context size with max_num_results and response_length, track cost per request, target datasets and diagnose missing results.

Practical tips for getting better results and controlling cost on the Valyu Search API.

Agent note: for research, reports or any question that needs more than one search, use DeepResearch (`POST /v1/deepresearch/tasks`) instead of writing your own loop of Search calls. Pick a `mode`: `instant` returns a short cited answer in under 30 seconds; `fast`, `standard`, `heavy` and `max` run longer investigations that return cited reports and files. Use Search when your own model needs raw results to reason over. Docs index: [/llms.txt](https://docs.valyu.ai/llms.txt). Append `.md` to any page URL for Markdown. Docs MCP server: `https://docs.valyu.ai/mcp`. Integration guide for coding agents: [/AGENTS.md](https://docs.valyu.ai/AGENTS.md).

## Manage context size

Control how much data lands in your LLM's context window with `max_num_results` and `response_length`:

```python Python theme={null}
# Lightweight: small context
valyu.search(
    "transformer architecture innovations",
    max_num_results=3,
    response_length="short",
)

# Comprehensive: large context
valyu.search(
    "transformer architecture innovations",
    max_num_results=15,
    response_length="large",
)
```

```javascript JavaScript theme={null}
// Lightweight: small context
await valyu.search("transformer architecture innovations", {
  maxNumResults: 3,
  responseLength: "short",
});

// Comprehensive: large context
await valyu.search("transformer architecture innovations", {
  maxNumResults: 15,
  responseLength: "large",
});
```

**Maximum content sizes** (token counts below are rough estimates, not guaranteed sizes):

* `short` - \~6k tokens / result (25k chars)
* `medium` - \~12k tokens / result (50k chars)
* `large` - \~24k tokens / result (100k chars)

> [!TIP]
>
> Start with `max_num_results=5` and `response_length="short"`, then scale up only if you need more.

## Remove image links to save tokens

Image URLs add many tokens to your context. They add little value for an LLM. The alt text keeps product names, specifications and captions.

Set `include_image_links` to `false` to remove image URLs from the content. Each image becomes `[Image: alt text]`. The API removes an image with no alt text. A linked image `[![alt](src)](href)` becomes `[[Image: alt]](href)`. Other links do not change. The default is `true`, which keeps image markdown such as `![Product photo](https://example.com/p.jpg)`.

```python Python theme={null}
response = valyu.search(
    "best budget mechanical keyboards",
    include_image_links=False,
)
```

```javascript JavaScript theme={null}
const response = await valyu.search("best budget mechanical keyboards", {
  includeImageLinks: false,
});
```

```bash cURL theme={null}
curl -X POST https://api.valyu.ai/v1/search \
  -H "x-api-key: $VALYU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "best budget mechanical keyboards",
    "include_image_links": false
  }'
```

A result changes from this text:

```markdown theme={null}
![Product photo](https://example.com/p.jpg)
```

to this text:

```markdown theme={null}
[Image: Product photo]
```

The parameter also works on [Contents](https://docs.valyu.ai/guides/content-extraction.md#remove-image-links).

## Track cost separately from context size

Record `total_deduction_dollars` for each request. `response_length` controls the maximum content returned per result; it is not a cost budget. Source choice and result count also affect the request.

Each result uses credits from your balance, and each result's charge is in `results[].price`:

| Results from | Credits per result |
| - | - |
| Web and news | 0.1 |
| arXiv, PubMed, bioRxiv, medRxiv | 0.05 |
| Other datasets | Listed in the [data sources catalogue](https://platform.valyu.ai/data-sources) |

`max_price` caps the cost of the whole request, not each result. Result selection can return fewer items to fit the cap, and a cap too low for the requested result count fails with `400`. Dataset prices (`pricing.cpm`) are each source's price per 1,000 returned results. See [pricing](https://docs.valyu.ai/pricing.md) and the [request reference](https://docs.valyu.ai/api-reference/endpoint/search.md). Confirm source-specific behavior for licensed collections, and enforce a separate total budget across all calls in your application.

## Target specific datasets

Choose [source filters](https://docs.valyu.ai/search/filtering/sources.md) for datasets, domains or presets. Save recurring selections as [collections](https://docs.valyu.ai/search/filtering/collections.md). The [source discovery guide](https://docs.valyu.ai/guides/datasources) explains how to find current IDs and supported APIs.

## AI vs human searches

Valyu is optimised for AI agents by default (`is_tool_call=true`). Set it to `false` for human-facing UIs to get more readable results.

```python theme={null}
# AI agent (default) - optimised for LLM consumption
valyu.search("quantum error correction surface codes benchmarks", is_tool_call=True)

# Human-facing - optimised for readability
valyu.search("quantum computing error correction methods", is_tool_call=False)
```

## Diagnose missing results

Check the response's success and error fields first. Then test one variable at a time: broaden the date range, remove an unnecessary source filter or `site:` term, or reduce the relevance threshold. A `site:` term in the query filters every result, including dataset results, so it can leave nothing to return. Confirm the dataset supports Search and your organization has access in the [source catalogue](https://docs.valyu.ai/guides/datasources).

Do not silently replace a failed specialist search with general web results when the user explicitly requested that dataset. Make the change visible in your application.

## Next steps

> [card] [Prompting guide](https://docs.valyu.ai/search/prompting.md)
>
> Write queries that get better results

> [card] [Source filtering](https://docs.valyu.ai/search/filtering/sources.md)
>
> Include, exclude, and soft-rank sources


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