Skip to main content
POST
Direct Web Search API

Overview

Use POST /api/web when you want direct control over search requests and output formatting. You can also call this tool through the unified Data API at POST /api/v1/data/web/search. The Data API preserves this endpoint’s request body, response body, billing, and provider behavior while adding discovery and dispatch metadata. For chat-first workflows, use POST /api/v1/chat/completions with model suffixes like :online, :online/linkup, or :online/sofya, including provider-specific suffixes such as :online/exa-instant, :online/exa-deep-reasoning, :online/brave, and :online/valyu-web-deep. See Model Suffixes. Sofya can do more than search on this endpoint. Set provider: "sofya" and choose the search, fetch, extract, or research operation.

When to use which endpoint

Authentication

Either auth header is supported:
string
Bearer YOUR_API_KEY
string
YOUR_API_KEY

Accountless x402 Payment

For accountless payment, prefer the public Data API path:
To request an accountless x402 quote, send the API request without Authorization or x-api-key, and include x-x402: true. NanoGPT will return 402 Payment Required with available payment options. This endpoint supports accountless x402 payments where listed by GET /api/v1/x402/endpoints, including Lightning L402 when advertised. See Accountless x402 API Payments for the full flow. If you receive 401 missing_api_key immediately, check that the initial quote request includes x-x402: true. Without that header, NanoGPT does not enter the x402 quote flow.

Request body

string
Search or research query. Required for every provider’s search operation and for Sofya research. Not used by Sofya fetch or extract.
string
default:"linkup"
Search provider: linkup, tavily, exa, kagi, perplexity, valyu, brave, sofya, or firecrawl. openai-native is not allowed on /api/web.
string
default:"search"
Sofya operation: search, fetch, extract, or research. Other providers support search only.
string
default:"standard"
Search depth. For Linkup: standard or deep.
For Linkup, depth: "standard" is executed as Linkup fast under the hood.
string
default:"searchResults"
Output mode. Allowed values: searchResults, sourcedAnswer, structured.
string
Required when outputType is structured. Pass a JSON schema string.
boolean
default:false
Include image results.
string
Earliest result date (YYYY-MM-DD).
string
Latest result date (YYYY-MM-DD).
string[]
Restrict results to these domains.
string[]
Exclude these domains.
Linkup supports outputType: "searchResults", "sourcedAnswer", and "structured". Non-Linkup providers currently support only outputType: "searchResults".

Sofya operations

Sofya Search returns extracted page content instead of snippets alone. The other operations let you fetch known URLs, extract requested information from one page, or produce a cited multi-source research report. Use operation: "search" or omit operation.
  • query (string, required)
  • maxResults (integer, 1-20; default 10)
  • topic (general or news)
  • freshness (day, week, month, year, or YYYY-MM-DD:YYYY-MM-DD)
  • includeDomains / excludeDomains (up to 10 strings each)

Fetch

Use operation: "fetch" with:
  • urls (array of 1-10 URL strings, required)
  • includeRawHtml or include_raw_html (boolean)

Extract

Use operation: "extract" with:
  • url (string, required)
  • prompt (string, required), describing what to extract

Research

Use operation: "research" with:
  • query (string, required)
  • topic (general or news)
  • freshness (day, week, month, year, or YYYY-MM-DD:YYYY-MM-DD)
  • maxSources or max_sources (integer, 5-30)

Response shape

array|object
Provider-formatted payload.
object
For searchResults, data is normally an array of normalized results. Sofya extract and research return an object, while Sofya fetch returns an array. For sourcedAnswer and structured, data is the provider response object.

Example response

Pricing (hosted key)

Error codes

Examples

Sofya examples