The Answer API searches across web, academic, and financial sources, then uses AI to generate a readable response with citations. You get a finished answer instead of raw search results.
A JSON schema for a consistent, parseable response
included_sources
Restrict to datasets, domains, or paths
start_date / end_date
Limit results to a date range (YYYY-MM-DD)
country_code
Bias results toward a region (e.g. "US")
fast_mode
Lower latency, finance and web sources prioritised
data_max_price
Cap search data cost (USD, default $1.0)
data = valyu.answer( query="climate change research", system_instructions="Focus on commercial impact. Summarise key findings as bullet points.", included_sources=["valyu/valyu-arxiv", "valyu/valyu-pubmed"], start_date="2024-01-01", data_max_price=2.0, # cap search data cost at $2.00 (default is $1.0))print(data.contents)
Search and AI are billed separately - the cost field breaks down both. Use data_max_price to cap search cost and fast_mode for lower latency.
{ "success": true, "tx_id": "tx_12345678-1234-1234-1234-123456789abc", "original_query": "latest developments in quantum computing", "contents": "Based on the latest research, quantum computing made significant progress in 2024...", "search_results": [ { "title": "IBM Unveils 1000-Qubit Quantum Processor", "url": "https://example.com/ibm-quantum", "snippet": "IBM announced a breakthrough in quantum computing...", "source": "web", "date": "2024-03-15" } ], "search_metadata": { "number_of_results": 8, "total_characters": 45000 }, "ai_usage": { "input_tokens": 1250, "output_tokens": 420 }, "cost": { "total_deduction_dollars": 0.027, "search_deduction_dollars": 0.015, "ai_deduction_dollars": 0.012 }}
Without structured_output, contents is a string. When you pass a structured_output schema, contents is instead a structured object matching that schema - in Python, check with isinstance(response.contents, dict).
Response fields
Field
Description
contents
The AI-generated answer (string, or a structured object when structured_output is set)