POST /query retrieves context for your question. By default, data.llm_prompt contains the question, matching passages, source references, and citation instructions in one Markdown string. Pass this string to your model and ask it to answer using the supplied context.
Choose a response format
Setresponse_format on the query request. The result is under data in the response envelope.
Send context to your model
In SDK 2.1.7 or later,build_string(result) in Python and buildString(result) in TypeScript read data.llm_prompt into the context variable below. The model call then includes context and the original question in the same message.
Use HTTP without the SDK
Use HTTP without the SDK
Read
data.llm_prompt from the JSON response. Use that string as context in the model call above.Request Markdown only
Setresponse_format: "markdown" to return the same context text directly as data, instead of inside data.llm_prompt. The SDK helpers above handle both formats.
Read citations and content labels
The prompt numbers ranked results as[1], [2], and so on. Explicitly linked results use [R1], [R2], and so on. Ask your model to keep these labels when citing the context.
A result can contain Original content, the source text, Enriched content, context HydraDB added, or both. Sections for related facts, dated facts, and sources appear when relevant. A query with no matches returns a no-results message rather than an empty prompt, including any filters that constrained the search.
Work with structured results
Useresponse_format: "structured" to omit llm_prompt when your application formats the results itself. Individual passages, scores, and source details are available in both the default and structured responses.
Response fields and graph data
Response fields and graph data
chunkscontains matching passages, scores, source IDs, and titles. Preserve the returned order.graph_context.query_pathscontains relationships relevant to the query. See Context Graphs.graph_context.chunk_relationsgroups relationships bygroup_id. Usechunk_id_to_group_idsto connect them to chunks.additional_contextmapsextra_context_idsto related chunks.
Combine knowledge and memories
Use onePOST /query with type: "all". HydraDB queries both stores in parallel and returns one merged, ranked result set.
This example searches shared documents in company_docs and the user’s memories in user_123. Use the collections you ingested into; both must exist. For restricted documents, also send the caller’s identity as acl. Use the printed context in the model call shown above.
POST /query requests with type: "knowledge" and type: "memory".
Common mistakes
Related
- Query: request parameters and response shape
- Memories: what
POST /querywithtype: "memory"queries - Knowledge: what
POST /querywithtype: "knowledge"queries - Context Graphs: what
graph_contextfields contain
