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

# Web search

> Search the web from the Sail API and return results to your application

Sail can search the web and return results to your application. Send a search
request to the Sail API. You get back a list of results with titles, URLs, and
excerpts.

Web search is a plain REST endpoint, separate from inference requests. You call
it on its own and choose what to do with the response.

## Treat results as untrusted

Every field this endpoint returns is written by whoever published the page.
Titles, URLs, and excerpts are all attacker-influenceable. Pages exist that
contain text written to look like instructions to whatever reads them next.

The risk is highest when you pass results to a model that can act, such as one
with tools, file access, or the ability to call your own APIs. Text in a result
that reads like instructions can cause an action you did not intend.

Before handing results to a capable model:

* Label them in your prompt as untrusted data, not instructions.
* Keep the model that reads them separate from the one that acts, and pass
  along only what the reading step produced.
* Do not let a result determine which tool runs or which URL gets called.

If you only display results or use them in your own code, treat them like any
other untrusted input and escape them where they are rendered.

## Make a search request

Send a `POST` request to `/v1/search`. Authenticate with your API key in the
standard `Authorization` Bearer header, the same header every `/v1` endpoint
uses.

```bash theme={null}
curl -X POST https://api.sailresearch.com/v1/search \
  -H "Authorization: Bearer YOUR_SAIL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "objective": "Find recent benchmarks for the GLM model family",
    "queries": ["GLM-5 benchmark results 2026"],
    "mode": "advanced",
    "max_results": 10
  }'
```

```python theme={null}
import json
import urllib.request

API_KEY = "YOUR_SAIL_API_KEY"
url = "https://api.sailresearch.com/v1/search"

payload = json.dumps({
    "objective": "Find recent benchmarks for the GLM model family",
    "queries": ["GLM-5 benchmark results 2026"],
    "mode": "advanced",
    "max_results": 10,
}).encode("utf-8")

req = urllib.request.Request(
    url,
    data=payload,
    headers={
        "Authorization": f"Bearer {API_KEY}",
        "Content-Type": "application/json",
    },
)


class RefuseRedirects(urllib.request.HTTPRedirectHandler):
    # urllib follows redirects by default and carries your Authorization
    # header to the new address, whatever host it points at. This endpoint
    # never redirects, so refuse instead and keep your key from travelling.
    def redirect_request(self, req, fp, code, msg, headers, newurl):
        return None


opener = urllib.request.build_opener(RefuseRedirects())

with opener.open(req) as resp:
    data = json.loads(resp.read())
    print(data["search_id"])
    for result in data["results"]:
        print(result["title"], result["url"])
```

## Request body

| Field | Required | Type | Default | Description |
| - | - | - | - | - |
| `objective` | No | string | *omitted* | A short description of the goal behind the search. Up to 2000 characters. |
| `queries` | Yes | array | *required* | One to ten search query strings. Each may be up to 500 characters. |
| `mode` | No | string | `advanced` | `advanced` for higher quality, or `turbo` for faster results. |
| `max_results` | No | integer | `10` | How many results to return. From 1 to 10. |

`queries` is the only required field. Pass one query for a simple lookup, or
several when you want broader coverage of a topic.

`mode` trades quality for speed. `advanced` is the default and returns higher
quality results. `turbo` returns results faster.

## Response

A successful search returns `200` with a JSON object.

```json theme={null}
{
  "search_id": "search_0198c2f4-7d1a-7b3e-9f42-6a5d8e91c073",
  "results": [
    {
      "url": "https://example.com/glm-benchmarks",
      "title": "GLM-5 benchmark results",
      "published": "2026-03-04",
      "excerpts": ["GLM-5 scored 78.4 on the reported benchmark suite."]
    }
  ]
}
```

* `search_id` is a string that identifies this search.
* `results` is an array. Each entry has:
  * `url`: the source URL.
  * `title`: the page title.
  * `published`: the publish date when available. It may be `null`.
  * `excerpts`: an array of relevant text snippets from the page.

## Errors

| Status | Meaning |
| - | - |
| `400` | The request was invalid, or the search provider rejected its content. Revise the queries or objective and retry. |
| `401` | The API key is missing or invalid. |
| `402` | The API key is disabled because your organization is out of credits. Add credits at [app.sailresearch.com](https://app.sailresearch.com/billing). |
| `403` | The API key is not backed by an organization. Search is billed per request, so it needs a key that can be attributed to one. |
| `413` | The request body exceeds this endpoint's size limit. Shorten the objective or send fewer queries. |
| `429` | Too many requests. Slow down, or wait for in-flight searches to finish. |
| `500` | Something went wrong on Sail's side. Retry once, and contact support if it persists. |
| `503` | Search is temporarily unavailable, the service is overloaded, or web search is not enabled. An overload response includes a `Retry-After` header: wait the stated time, then retry. If the error code is `search_not_configured`, web search is not enabled: there is no `Retry-After`, and retrying will not help. |

A `503` with a `Retry-After` header is temporary: read the value, wait, and
send the request again. A `503` whose error code is `search_not_configured`
is not: retrying will not help. Contact us if you expected web search to
be available.

## Billing

Each successful search is billed to your organization per request:

| Mode | Price |
| - | - |
| `advanced` | \$5.00 per 1,000 searches |
| `turbo` | \$1.00 per 1,000 searches |

Failed searches are not billed.
