Answer

Get AI-powered answers with real-time search

Searches across web, academic, and financial sources, then uses AI to generate a readable, cited response. Returns results as a Server-Sent Events (SSE) stream.

The AI agent performs multi-round search with up to 2 tool call rounds (3 in fast_mode), can decompose queries into sub-queries, and synthesizes findings into a coherent answer.

SSE Event Types

Events are sent as data: {json}\n\n with the following types:

EventDescription
search_resultsSearch sources found (may occur multiple times)
contentPartial answer text chunk (OpenAI-compatible delta format)
metadataFinal metadata with costs, token usage, and all search results
[DONE]Stream complete

Cost Structure

Each request costs a base of ~$0.10 plus variable search and AI token costs. The cost object in the metadata event provides a full breakdown.

post/v1/answer

Request

  • Base URL: https://api.valyu.ai
  • URL: https://api.valyu.ai/v1/answer
  • Auth: API key in header X-API-Key

Request body

querystring required

The question or research query to answer.

search_type'all' | 'web' | 'proprietary' | 'news'

Controls which data sources are searched.

  • all - Web and proprietary sources (default)
  • web - Web search only
  • proprietary - Academic, financial, and premium sources only
  • news - News articles only
included_sourcesstring[]

Sources to include. Accepts domains, URLs, dataset identifiers, or presets ("finance", "medical").

excluded_sourcesstring[]

Sources to exclude. Same format as included_sources except presets are not supported.

data_max_pricenumber

Maximum budget in USD for the search data component. Converted to CPM internally.

start_datestring date

Filter results published on or after this date. Format: YYYY-MM-DD.

end_datestring date

Filter results published on or before this date. Format: YYYY-MM-DD.

country_code'ALL' | 'AR' | 'AU' | 'AT' | 'BE' | 'BR' | 'CA' | 'CL' | 'DK' | 'FI' | 'FR' | 'DE' | 'HK' | 'IN' | 'ID' | 'IT' | 'JP' | 'KR' | 'MY' | 'MX' | 'NL' | 'NZ' | 'NO' | 'CN' | 'PL' | 'PT' | 'PH' | 'RU' | 'SA' | 'ZA' | 'ES' | 'SE' | 'CH' | 'TW' | 'TR' | 'GB' | 'US'

ISO 3166-1 alpha-2 country code for geo-targeted search.

fast_modeboolean

Enable fast mode for lower latency. Uses 3 tool call rounds instead of 2 and higher result counts per query.

structured_outputobject nullable

JSON Schema defining the desired output structure. When set, the AI returns a JSON object matching this schema instead of free-form text. Max depth 10, max 50 properties, max 5000 characters.

system_instructionsstring nullable

Custom system instructions for the AI. Replaces the default research agent prompt. Max 2000 characters.

Example request

{
  "query": "What are the latest FDA-approved treatments for type 2 diabetes?",
  "included_sources": [
    "pubmed.ncbi.nlm.nih.gov"
  ],
  "data_max_price": 1,
  "start_date": "2024-01-01",
  "end_date": "2024-12-31",
  "structured_output": {
    "type": "object",
    "properties": {
      "treatments": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string"
            },
            "approval_date": {
              "type": "string"
            },
            "mechanism": {
              "type": "string"
            }
          }
        }
      }
    }
  },
  "system_instructions": "You are a medical research assistant. Cite all sources."
}

Response

SSE stream of search results, answer chunks, and metadata.

Changes

No recorded changes to this operation across all 1 revision of this API.