Skip to main content
POST
The Answer API is deprecated as of November 17, 2026. It sunsets on December 17, 2026: from that date POST /v1/answer returns HTTP 410 Gone. Until then it keeps working. Move to DeepResearch instant mode or to Search with your own model.
Ask a question and receive a synthesized answer with supporting sources. Use Answer when you want Valyu to retrieve and write the response; use Search when your own application should do that work.

Consume the stream

The HTTP endpoint returns server-sent events, not one JSON response. Handle search_results, content and metadata events, followed by [DONE]. If the answer fails mid-stream, you receive {"error": "Streaming failed"} and the stream ends, even though the HTTP status was 200. Keep the returned sources with the answer. The metadata event also carries any warnings from the searches the answer ran. There is no per-request fee. Each answer is charged for the search, content extraction and AI processing it uses, and cost.total_deduction_dollars in the final metadata event is the amount billed. Source and date controls narrow retrieval. They do not guarantee that every claim is supported or that all relevant evidence was found. For a longer asynchronous investigation with a report and optional files, use DeepResearch.

Migrate from Answer

Answer calls that you do not move by December 17, 2026 fail with HTTP 410. Responses from POST /v1/answer before that date carry these headers: The Link header points to this section. Valyu SDK answer() methods log a deprecation warning from valyu-py 2.13.8 and valyu-js 2.11.8. Pick the replacement that fits how you use Answer.

DeepResearch instant mode

instant mode returns a short cited answer in under 30 seconds and uses 8 credits per task. You create a task, then read its status until it completes. It is not a server-sent event stream. The result has the answer in output (markdown with numbered citations) and the sources in sources.
Check status before you read output. For longer research, pick another mode.

Search plus your own LLM

Use Search to get ranked results with title, url and content, then pass them to your own model. Keep the url with each passage so the answer can cite it.

Authorizations

X-API-Key
string
header
required

API key for authentication. Get yours at platform.valyu.ai.

Body

application/json

Answer API request parameters.

query
string
required

The question or research query to answer.

Example:

"What are the latest FDA-approved treatments for type 2 diabetes?"

search_type
enum<string>
default:all

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
Available options:
all,
web,
proprietary,
news
included_sources
string[]

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

Example:
excluded_sources
string[]

Sources to exclude. Accepts domains, URLs and dataset identifiers. Presets are not supported.

data_max_price
number
default:1

Maximum budget for the search component of the answer. It does not cap content extraction or AI processing.

Required range: x > 0
Example:

1

start_date
string<date>

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

Example:

"2024-01-01"

end_date
string<date>

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

Example:

"2024-12-31"

country_code
enum<string>

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

Available options:
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
fast_mode
boolean
default:false

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

structured_output
object | null

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.

Example:
system_instructions
string | null

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

Maximum string length: 2000
Example:

"You are a medical research assistant. Cite all sources."

Response

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

Server-Sent Events stream. Each event has format: data: {json}\n\n

search_results event:

content event (OpenAI-compatible):

metadata event:

contents is the full answer (JSON text when structured_output is set). total_deduction_dollars is the amount billed. When the searches behind the answer skipped or adjusted something, the metadata event also carries warnings: the warnings of those searches, deduplicated, in the same {type, message, detail} shape as Search. See Warnings.

error event:

done signal: