Stream an AI-generated answer to your legal question in real-time via Server-Sent Events (SSE). Provides thinking steps, source citations, and answer tokens as they are generated.
Authentication: API key via Authorization: Bearer vq_key_...
Content-Type: Response is text/event-stream. Set Accept: text/event-stream.
| Event | Description |
|---|---|
stream_init | Stream opened — contains streamId |
thinking | Pipeline progress step (analyzing, searching, generating) |
sources | Retrieved source citations (same fields as sync /ask) |
thinking_complete | Thinking done, answer streaming begins |
chunk | Answer text token (concatenate all chunks for full answer) |
heartbeat | Keep-alive signal (every 15s) |
done | Stream complete — contains meta with credits and timing |
error | Error occurred — contains message and code |
const response = await fetch('/api/v1/ask/stream', {
method: 'POST',
headers: {
'Authorization': 'Bearer vq_key_...',
'Content-Type': 'application/json',
'Accept': 'text/event-stream',
},
body: JSON.stringify({ question: 'What is negligence?', mode: 'standard' }),
});
const reader = response.body.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
const text = decoder.decode(value);
// Parse SSE events from text
for (const line of text.split('\n')) {
if (line.startsWith('data: ')) {
const event = JSON.parse(line.slice(6));
console.log(event.type, event);
}
}
}
Same modes, credit costs, source fields, and chatHistory support as POST /ask.
data: {"type":"stream_init","streamId":"abc-123"}
data: {"type":"thinking","step":{"id":"step_1","message":"Analyzing your question...","status":"active"}}
data: {"type":"sources","sources":[{"sourceIndex":1,"citation":"[2005] 6 S.C.R. 1","caseName":"Jacob Mathew v. State of Punjab","relevanceScore":0.94,...}]}
data: {"type":"thinking_complete"}
data: {"type":"chunk","content":"The test for"}
data: {"type":"chunk","content":" negligence requires"}
data: {"type":"chunk","content":" three essential elements..."}
data: {"type":"done","data":{"mode":"standard","meta":{"processingTimeMs":2340.5,"creditsConsumed":0.5,"creditsRemaining":4.5}}}
For more details, see the API Reference.
Documentation Index
Fetch the complete documentation index at: https://vaquill.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
API key issued from the Vaquill developer dashboard. Pass as Authorization: Bearer vq_key_...
Request body for the AI-powered legal Q&A endpoint.
Your legal question in plain language.
1 - 5000"What is the test for negligence under tort law?"
Research depth. standard uses a fast model for quick answers. deep uses an advanced model for complex legal analysis.
standard, deep "standard"
Whether to include source citations in the response.
Maximum number of source citations to return (1-30).
1 <= x <= 305
Jurisdiction. US for United States federal and state law, IN for Indian law. Defaults to US if omitted.
IN, US "US"
Filter which sources to search. US only.
all (default): Search both case law and statutesstatutes_only: Search only USC/CFR statutes. Ideal for regulatory questions, compliance checks, and statutory interpretation. Faster and cheaper since it skips case law search.cases_only: Search only case law opinions. Useful for precedent research.all, statutes_only, cases_only "statutes_only"
Optional US state code (2-letter ISO, e.g. tx, ca). When set and countryCode is US, retrieval is scoped to that state:
statutes_us corpus (federal USC/CFR excluded).Ignored when countryCode is not US.
"tx"
Previous conversation messages for multi-turn context. The system uses this to resolve references like 'that case' or 'compare it with Section 302'. Most recent messages last. Max 20 messages.
20SSE event stream with thinking steps, sources, answer chunks, and metadata