AI API
Every AI endpoint takes a plain English prompt alongside the parameters you already use on the standard API. Spider plans the work, cleans the page, and returns data shaped by that prompt. Six routes cover crawling, scraping, search, browser automation, link discovery, and unblocking, all on one request and response contract.
Routes
Six routes, all POST only. Any other method returns 400. Each one also answers on a /v1 alias, so /v1/ai/crawl is equivalent to /ai/crawl.
- POST/ai/crawl
Crawl a site from one starting URL and let the prompt decide what matters on each page. Returns an array of pages with structured data attached.
- POST/ai/scrape
Fetch a single URL and extract exactly what the prompt asks for. Pair it with an extraction_schema when you need a stable shape.
- POST/ai/search
Run a web search driven by the prompt and return ranked results. Pass `search` yourself to skip query generation, or leave it off and the prompt becomes the query.
- POST/ai/browser
Drive a real browser session with a natural language prompt, so clicks, toggles and form steps happen before extraction. Best for pages that only reveal data after interaction.
- POST/ai/links
Collect the links on a page that match the prompt. Link return is forced on for this route, so every page object carries a `links` array.
- POST/ai/unblocker
Fetch a page that is behind bot protection and hand the cleaned result to the model. Use it when a normal scrape returns a challenge page.
How AI endpoints differ
- A prompt, not a selector
Describe the data you want in plain language. There is no CSS path to maintain when the markup changes.
- Everything the standard route takes
Each AI route accepts the full parameter surface of its non-AI counterpart, plus the AI fields.
- Structured output
Results arrive on metadata.extracted_data, shaped by extraction_schema when you supply one.
- Always a real browser
AI routes cache, but they never skip the browser, so the model reads live page content.
- Separate billing
AI usage draws on an AI Studio subscription, or on credits when no subscription is active.
- Model cost passed through
ai_cost is the raw vendor token spend and is excluded from domain markup.
Authentication
Send your API key as a bearer token against https://api.spider.cloud. The same key works across every Spider endpoint. AI usage is billed against an AI Studio subscription, falling back to credits when no subscription is active, so a key that works on /crawl can still be refused here. See Errors for what that looks like.
Authorization header requiredBearer YOUR_API_KEY. Requests without it fail with an empty 400.
Content-Type header requiredapplication/json.
Common AI parameters
These apply across the AI routes. Each route additionally accepts everything its standard counterpart takes, so the Parameters reference covers proxies, geo-location, caching, headers and the rest.
prompt string requiredNatural language description of what to do and what to pull back. An empty prompt is rejected with a 400.
extraction_schema object optionalShape for the structured result. Takes `name` (required), `description` (optional) and `schema`, which may be a JSON object or a JSON encoded string.
cleaning_intent "extraction" | "action" | "general" optional, crawl / scrape / links / unblocker onlyHow aggressively the HTML is reduced before the model reads it. Use "extraction" for data pulls, "action" to keep interactive elements, "general" for a balanced clean. Not accepted on /ai/search or /ai/browser.
metadata boolean default falseReturn page metadata such as title and description. Note that `metadata.extracted_data` is attached to the response either way, so structured output never depends on this flag.
return_format string optionalContent shape for each page, for example "markdown", "raw", "text" or "commonmark".
limit number optionalMaximum pages to process. The value is lifted internally into a crawl budget of `{"*": limit}`.
An extraction_schema pins the output shape. Pass schema as an object, or as a JSON encoded string if that is easier to carry through your client.
Response
Every AI route returns a JSON array of page objects, even when you asked for a single URL. Two fields catch people out, so they are called out below.
url string alwaysThe URL this result came from.
status number alwaysHTTP status returned by the target page, not by the Spider API.
error string | null alwaysPer page error. Null on success. A page can fail while the request as a whole returns 200.
duration_elasped_ms number alwaysTime spent on this page. Note the spelling: "elasped" is part of the public contract, so reading duration_elapsed_ms returns undefined.
costs object | null alwaysCost breakdown in USD. It is null, not an object of zeros, whenever the request bills nothing, so check before reading total_cost.
metadata.extracted_data object alwaysThe structured result. It is attached whether or not you passed metadata: true.
content string conditionalPage content in the shape named by return_format. Omitted when no content was requested.
links string[] conditionalDiscovered links. Always present on /ai/links, which forces link return on.
AI Crawl
POST/ai/crawl
Crawl a site from one starting URL and let the prompt decide what matters on each page. Returns an array of pages with structured data attached.
depth number optionalHow many link levels below the starting URL to follow.
AI Scrape
POST/ai/scrape
Fetch a single URL and extract exactly what the prompt asks for. Pair it with an extraction_schema when you need a stable shape.
AI Search
POST/ai/search
Run a web search driven by the prompt and return ranked results. Pass `search` yourself to skip query generation, or leave it off and the prompt becomes the query.
search string optional, search onlyThe literal search query. When omitted, a query is generated from the prompt.
fetch_page_content boolean default false, search onlyFetch and return the content of each result page instead of the result listing alone.
num number optional, search onlyNumber of search results to return.
AI Browser
POST/ai/browser
Drive a real browser session with a natural language prompt, so clicks, toggles and form steps happen before extraction. Best for pages that only reveal data after interaction.
wait_for object optionalA WaitFor struct, not a number. Fields are `selector` and `dom` (each `{ timeout, selector }`), `idle_network`, `idle_network0` and `almost_idle_network0` (each `{ timeout }`), `delay` (`{ timeout }`) and the boolean `page_navigations`. Every timeout is a duration object of `{ secs, nanos }`.
AI Links
POST/ai/links
Collect the links on a page that match the prompt. Link return is forced on for this route, so every page object carries a `links` array.
return_page_links boolean forced onAlways enabled for this route. You do not need to send it, and sending false does not disable it.
AI Unblocker
POST/ai/unblocker
Fetch a page that is behind bot protection and hand the cleaned result to the model. Use it when a normal scrape returns a challenge page.
Errors
Returned with an empty body. There is no message to parse. It covers malformed JSON, a missing or empty prompt, an unrecognised field, a missing Authorization header, and an unresolvable API key. If a request fails with nothing in the body, check those first.
The account has neither an active AI Studio subscription nor credits to fall back on. Plans are on the AI Studio pricing page.
Carries a Retry-After header in seconds, and retry_after_ms in the body. Back off for that long rather than retrying immediately.
Rate limits
AI routes are limited by requests per second on the account's AI Studio tier, separately from the monthly credit allowance.
Starter1 request per second600 credits per month
Lite5 requests per second3,000 credits per month
Standard10 requests per second12,500 credits per month
Scale25 requests per second60,000 credits per month
Looking for the non-AI routes? Start at the API reference . For plans and included credits, see AI Studio pricing .