Reference for the Valyu Answer endpoint that blends search results into AI-generated answers via POST /v1/answer.
API key for authentication. Get yours at platform.valyu.ai.
Answer API request parameters.
The question or research query to answer.
"What are the latest FDA-approved treatments for type 2 diabetes?"
Controls which data sources are searched.
all - Web and proprietary sources (default)web - Web search onlyproprietary - Academic, financial, and premium sources onlynews - News articles onlyall, web, proprietary, news Sources to include. Accepts domains, URLs, dataset identifiers, or presets ("finance", "medical").
["pubmed.ncbi.nlm.nih.gov"]Sources to exclude. Same format as included_sources except presets are not supported.
Maximum budget in USD for the search data component. Converted to CPM internally.
x > 01
Filter results published on or after this date. Format: YYYY-MM-DD.
"2024-01-01"
Filter results published on or before this date. Format: YYYY-MM-DD.
"2024-12-31"
ISO 3166-1 alpha-2 country code for geo-targeted search.
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 Enable fast mode for lower latency. Uses 3 tool call rounds instead of 2 and higher result counts per query.
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.
{
"type": "object",
"properties": {
"treatments": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"approval_date": { "type": "string" },
"mechanism": { "type": "string" }
}
}
}
}
}Custom system instructions for the AI. Replaces the default research agent prompt. Max 2000 characters.
2000"You are a medical research assistant. Cite all sources."
SSE stream of search results, answer chunks, and metadata.
Server-Sent Events stream. Each event has format: data: {json}\n\n
search_results event:
{"search_results": [{"title": "...", "url": "...", "content": "...", ...}]}content event (OpenAI-compatible):
{"choices": [{"delta": {"role": "assistant", "content": "text chunk"}, "index": 0}]}metadata event:
{"success": true, "tx_id": "ai_tx_...", "data_type": "unstructured", "search_results": [...], "search_metadata": {"tx_ids": [...], "number_of_results": 10, "total_characters": 50000}, "ai_usage": {"input_tokens": 15000, "output_tokens": 2000}, "cost": {"total_deduction_dollars": 0.15, "search_deduction_dollars": 0.03, "ai_deduction_dollars": 0.10, "contents_deduction_dollars": 0.02}}done signal:
data: [DONE]