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

# Search

> POST /v1/search returns ranked web results for a query, with the text of the best passages of each page, the publish date and the licence where one applies. It is...

`POST /v1/search` returns ranked web results for a query, with the text of the best passages of each page, the publish date and the licence where one applies. It is built for an agent that reads the answer, so the default answer is compact: about half the tokens of the full object, with the same results, the same order and the same bill.

[//]: # "smoke: not executed, the search endpoints are served by the main API host and bill the account that calls them"

Base URL: `https://api.styne.ai`. Every request carries `Authorization: Bearer $STYNE_API_KEY`. The key is the one you use for sandboxes and browsers; see [API keys](https://docs.styne.ai/authentication.md).

## Quick start

```bash theme={"theme":"css-variables"}
curl -sS https://api.styne.ai/v1/search \
  -H "Authorization: Bearer $STYNE_API_KEY" \
  -H "content-type: application/json" \
  -d '{"query": "how does HTTP/3 connection migration work", "max_results": 5}'
```

```python theme={"theme":"css-variables"}
import os
import requests

r = requests.post(
    "https://api.styne.ai/v1/search",
    headers={"Authorization": f"Bearer {os.environ['STYNE_API_KEY']}"},
    json={"query": "how does HTTP/3 connection migration work", "max_results": 5},
    timeout=30,
)
for hit in r.json()["results"]:
    print(hit["title"], hit["url"])
```

```typescript theme={"theme":"css-variables"}
const res = await fetch("https://api.styne.ai/v1/search", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.STYNE_API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({ query: "how does HTTP/3 connection migration work", max_results: 5 }),
});
const { results } = await res.json();
for (const hit of results) console.log(hit.title, hit.url);
```

The answer:

```json theme={"theme":"css-variables"}
{
  "request_id": "req_lon_7Hq2Kd9a",
  "usage": { "billable_units": 1, "cost_usd": 0.002, "billed_from": "paid", "balance_usd": 4.998, "free_remaining_usd": 0 },
  "results": [
    {
      "title": "Connection migration in QUIC",
      "url": "https://example.com/quic-migration",
      "published": "2026-03-02",
      "text": "A QUIC connection is identified by a connection ID, not by the address pair, so a client can keep the connection when its address changes."
    }
  ]
}
```

The ids and numbers are an illustration; the field names are the service's.

## Request fields

Only `query` is required.

| Field | Type | What it does |
| - | - | - |
| `query` | string | The search text. |
| `max_results` | integer, 1 to 20 | Results to return. Default 10. |
| `mode` | `fast`, `auto` or `deep` | How much ranking work the search may spend. `auto` (default) picks per query; `deep` is for hard questions with several constraints. The mode served sets the price. |
| `sites` | object | `include` and `exclude`: hosts (their subdomains count) or host/path prefixes such as `example.com/docs`. A result outside `include`, or inside `exclude`, is never returned. Up to 1,000 each. |
| `site_list_id` | string | One of your saved site lists, combined with the list of the key. |
| `recency` | `hour`, `day`, `week`, `month` or `year` | Only pages published in that window. |
| `published_after`, `published_before` | string | A date (`2025-05-01`), an RFC 3339 time or an age such as `7d`, `24h`, `2w`, `3m`, `1y`. Pages with no date are left out. |
| `crawled_after`, `crawled_before` | string | The same, on the date Styne fetched the page. |
| `time_basis` | `published` or `crawled` | Which date `recency` counts. Default `published`. |
| `language` | string or list | Language code, for example `en`. |
| `format` | `compact` or `full` | `compact` (default) is what an agent reads. `full` returns every field of a result. |
| `objective` | string | The task the query serves. Used as ranking context, never as a filter, and never stored. |
| `max_chars_per_result` | integer, 100 to 20,000 | Cap on the text of one result. |
| `max_passages_per_result` | integer, 1 to 8 | Passages per result, best first. |
| `max_chars_total` | integer, 500 to 200,000 | One text budget for the whole answer, filled in rank order. Results past it keep title and URL only, and `warnings` has `max_chars_total_reached`. |
| `session_id` | string | Any id you choose, one per agent task. From the second search on, results already returned in the session come after the ones it has not seen. The header `Styne-Session` does the same. |
| `timezone`, `locale` | string | For relative dates such as "last week": an IANA zone like `Europe/Berlin`, a BCP 47 locale. |

A request can carry an `Idempotency-Key` header; a replay within 24 hours returns the same answer and is not billed again.

## Response fields

| Field | What it is |
| - | - |
| `request_id` | The id of the request. Quote it to support. |
| `results` | The hits, best first. |
| `results[].title`, `results[].url` | The page. |
| `results[].source` | Where the result comes from, for example `web:brave`; `wayback` when the page is gone and served from an Internet Archive capture. |
| `results[].published` | `YYYY-MM-DD`; left out when the page gives no date. |
| `results[].text` | The passages that best match the query, one per line. |
| `results[].license`, `results[].attribution` | Present where the licence of the page asks for attribution. Show them with the text. |
| `mode` | The mode served, which is the mode billed. Present when the request set a mode. |
| `usage` | `billable_units` (blocks billed), `cost_usd`, `billed_from` (`free`, `paid`, `mixed` or `none`), `balance_usd`, `free_remaining_usd`. |
| `warnings` | Short codes, left out when empty. |
| `degraded` | `true` when the index answered partly. Such an answer is not billed. |
| `returned_earlier` | With a session: results moved out of this answer because the session saw them already. |

With `"format": "full"` each result also carries `domain`, `language`, `score`, `passages`, `tokens`, `crawled_at`, `rights` and the date evidence. The full schema is in the [OpenAPI document](https://styne.ai/openapi.json).

## Limits

| Limit | Value |
| - | - |
| Results per search | 1 to 20 |
| Requests per minute, per account | 600; 1,200 once the account has added credit; plans have their own |
| Requests in flight, per account | 10; 20 once the account has added credit; plans have their own |
| `sites.include` and `sites.exclude` | 1,000 entries each |

An over-limit request answers `429` with `Retry-After`. See [Errors](https://docs.styne.ai/errors.md) and [Limits](https://docs.styne.ai/limits.md).

## Pricing

Search is billed per started block of 10 results, by the mode served:

| Mode | Per block of 10 results | Per 1,000 blocks |
| - | - | - |
| `fast` | \$0.001 | \$1 |
| `auto` | \$0.002 | \$2 |
| `deep` | \$0.005 | \$5 |

Eleven to twenty results are two blocks. An error, a timeout, an empty answer and a partial answer are never billed. It is billed from your prepaid credit, which never expires; an account with no credit gets `402`. See [Plans and billing](https://docs.styne.ai/billing.md).


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