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:
| Event | Description |
|---|---|
| search_results | Search sources found (may occur multiple times) |
| content | Partial answer text chunk (OpenAI-compatible delta format) |
| metadata | Final 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
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.