Skip to main content
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

Set response_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.
Read data.llm_prompt from the JSON response. Use that string as context in the model call above.

Request Markdown only

Set response_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

Use response_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.
  • chunks contains matching passages, scores, source IDs, and titles. Preserve the returned order.
  • graph_context.query_paths contains relationships relevant to the query. See Context Graphs.
  • graph_context.chunk_relations groups relationships by group_id. Use chunk_id_to_group_ids to connect them to chunks.
  • additional_context maps extra_context_ids to related chunks.
See Query for the full response schema and examples.

Combine knowledge and memories

Use one POST /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.
If knowledge and memories need different search terms, make separate POST /query requests with type: "knowledge" and type: "memory".

Common mistakes


  • Query: request parameters and response shape
  • Memories: what POST /query with type: "memory" queries
  • Knowledge: what POST /query with type: "knowledge" queries
  • Context Graphs: what graph_context fields contain