Skip to Content

Knowledge

Stream an answer

Ask an engine a question and receive the answer as server-sent events while it's written.

POST/v1/engine/query/stream

Takes the same body as Query an engine and returns the answer as it's written, ending with the complete, checked answer. lynk.query with stream calls it for you.

Body

engine_idstring<uuid>required

The engine to ask.

querystringrequired

The question, in plain words.

top_kintegerdefault: 8

How many chunks to search for, from 1 to 50.

model_idstring | null

A generation model your plan includes.

A stream always uses the engine's Answer Mode from its settings. Any query_mode you send is ignored here.

Events

tokeneventrequired

delta: the next piece of the answer.

finaleventrequired

answer, citations, and confidence: the complete, checked answer. Sent once.

doneeventrequired

ok: the stream is finished.

errorevent

detail: the answer couldn't be finished. No final follows.

Some answers arrive whole in final with no token events, such as a Precision Mode answer. Always read final for the complete answer.

Status codes

StatusMeaning
200The stream started. Errors after this point arrive as an error event.
400The query is empty.
401The key is missing, malformed, or revoked.
402Your plan's monthly allowance is used up.
403The key's capability or scope doesn't allow reading this engine.
404The engine doesn't exist in the key's workspace.
429A rate limit was hit.