Quick start
Get a key, run a first search, read a page and handle errors.
1. Get a key
websearch.fast uses relay.fast accounts. Sign in to the console with your relay.fast account and create a key there, or create one on the relay.fast keys page. The same key calls the models and the Web API, and both are paid from the same balance.
export WEBSEARCH_API_KEY="sk-..."2. Search
curl https://api.websearch.fast/v1/web/search \
-H "Authorization: Bearer $WEBSEARCH_API_KEY" \
-H "Content-Type: application/json" \
-d '{"q": "postgres 18 release notes", "num": 5}'import os
import httpx
response = httpx.post(
"https://api.websearch.fast/v1/web/search",
headers={"Authorization": f"Bearer {os.environ['WEBSEARCH_API_KEY']}"},
json={
"q": "postgres 18 release notes",
"num": 5,
},
timeout=60,
)
response.raise_for_status()
print(response.json())const response = await fetch("https://api.websearch.fast/v1/web/search", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.WEBSEARCH_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
q: "postgres 18 release notes",
num: 5,
}),
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.json());Each result has position, title, url, domain, snippet and origin, and published_at when the page states a date. url is the address of the page itself. See search for every field.
3. Get the page text with the results
Add content to receive the cleaned text of the top pages in the same response, so the model does not need a second call to read them.
curl https://api.websearch.fast/v1/web/search \
-H "Authorization: Bearer $WEBSEARCH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"q": "postgres 18 release notes",
"num": 5,
"content": {"pages": 3, "max_chars_per_page": 4000}
}'import os
import httpx
response = httpx.post(
"https://api.websearch.fast/v1/web/search",
headers={"Authorization": f"Bearer {os.environ['WEBSEARCH_API_KEY']}"},
json={
"q": "postgres 18 release notes",
"num": 5,
"content": {"pages": 3, "max_chars_per_page": 4000},
},
timeout=60,
)
response.raise_for_status()
print(response.json())const response = await fetch("https://api.websearch.fast/v1/web/search", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.WEBSEARCH_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
q: "postgres 18 release notes",
num: 5,
content: { pages: 3, max_chars_per_page: 4000 },
}),
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.json());4. Read a page
curl https://api.websearch.fast/v1/web/fetch \
-H "Authorization: Bearer $WEBSEARCH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://docs.example.org/guide/install",
"max_chars": 4000
}'import os
import httpx
response = httpx.post(
"https://api.websearch.fast/v1/web/fetch",
headers={"Authorization": f"Bearer {os.environ['WEBSEARCH_API_KEY']}"},
json={
"url": "https://docs.example.org/guide/install",
"max_chars": 4000,
},
timeout=60,
)
response.raise_for_status()
print(response.json())const response = await fetch("https://api.websearch.fast/v1/web/fetch", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.WEBSEARCH_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
url: "https://docs.example.org/guide/install",
max_chars: 4000,
}),
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.json());5. Handle errors
Errors have the same shape on every native path. Branch on the HTTP status first and on error.code second. The message is for people and can change. Quote request_id when you report a failure.
{
"error": {
"code": "fetch_failed",
"message": "The page could not be read. (request id: 20261128120008123456789a1b2c3d4Kx7Qm2Ph)",
"type": "invalid_request_error",
"param": "url"
},
"request_id": "20261128120008123456789a1b2c3d4Kx7Qm2Ph"
}Retry 429 after Retry-After, and 500, 503 and 504 with backoff and a cap. Do not retry other 4xx unchanged. The errors page lists every code.
Base URLs
| Host | Base URL |
|---|---|
| websearch.fast | https://api.websearch.fast/v1/web |
| relay.fast | https://relay.fast/v1/web |
| relay.fast reserve host | https://direct.relay-fast.com/v1/web |
All hosts take the same relay.fast keys and serve the same paths. API paths never redirect, because a redirect can drop the Authorization header. A wrong path returns 404 invalid_endpoint.
For AI agents
- Read the key from an environment variable or a secret store. Do not print it or put it in a URL.
- Branch on the HTTP status and
error.code, not on the message. - Web calls cost money. One
searchwithcontentcosts less than a search plus severalfetchcalls. Do not loop over large URL sets unless the operator asked for it. - On
429wait forRetry-After. On5xxretry with backoff and a cap. Do not retrysite_refused. - Quote the
request_idwhen you report a failure.
What we do not promise
- Availability. Uptime, response times and the presence of an endpoint, type or result field are not promised. Status reports measured numbers.
- Results. Rankings, coverage and the results for a query can change at any time. We do not promise that results match any other service or that a given page is in the index.
- Prices. Prices and unit weights can change.
- Notice. Changes to prices, endpoints, fields or this API can happen without advance notice.
- Compatibility. The compatibility paths answer in the shape of the format they accept, but not every field is filled. The migration guide lists which.