POST /query searches your context: knowledge, memories, or both. It returns ranked passages, called chunks, with their source details and the context graph around them. Your application puts them in the model’s prompt; the model writes the answer.
The defaults work without tuning.
1. Run a query
This request searches theacme_corp database for knowledge about rotating API keys. Every query starts from this request; later sections add fields. The body is JSON; ingestion is multipart.
Run a query: Python, TypeScript, or cURL
Run a query: Python, TypeScript, or cURL
Set up your SDK client before running the Python or TypeScript example.The response is wrapped in the standard envelope, so read the result from The full response schema is on the Query API reference.
data. Trimmed to the fields you use most, it looks like this:What each property means
What comes back
data.llm_prompt: the question, the matching chunks, and citation instructions as one Markdown string, ready for a model.data.chunks: the matching chunks, ranked by relevance, each with its sourceid,chunk_content,source_title,relevancy_score, andmetadata. Keep the order.data.graph_contextanddata.additional_context: relationships and linked chunks, covered in section 5.
graph_creation; wait for completed when you query straight after ingesting.
2. Pick a recipe
Start from the row that matches your goal. Leave everything else at its default.query_by picks how the text is matched: "hybrid" (the default) matches by meaning and by keyword together, and "text" matches keywords only. mode picks how much work the query does. Section 3 explains mode.
3. Tune the ranking
When the defaults are not right, start here:mode:"fast"is one retrieval pass, for chat and autocomplete."thinking"expands the query, reranks, and pulls in forceful relations, for answers where quality matters more than latency."auto", the default, scores each query and routes it to one of the two, choosing thinking when unsure; the response does not say which it chose. Applies toquery_by: "hybrid"only.alpha: the balance between meaning (1.0) and keywords (0.0) in a hybrid query. Default0.8, which"auto"also resolves to. Lower it toward0.3to0.5for error codes, SKUs, and product names; raise it toward0.9for conceptual questions.recency_bias: how much newer context is favored, from0.0to1.0. Default0.4, a mild tilt that only reorders close results. Send0for policies and other context that rarely changes, and0.6to0.8for changelogs and status updates.max_results: drop to5for tight context windows; raise to20when you rerank downstream.additional_context: a short factual hint, such as"user is on the billing page", that sharpens retrieval. It is not a filter.
- Timeouts: 3 to 5 s for thinking, 500 ms or less for fast. Budget
"auto"like thinking. - Literal token plus intent: run
query_by: "hybrid"andquery_by: "text"in parallel, dedupe bychunk_uuid, and keep the text hits. - Recall, then rerank: ask for
max_results: 20and apply your own rules before picking the final set. - Caching: key on the database, the collections, the caller’s
acl, and every query parameter, and expire entries when context or permissions change.
4. Choose what to search
To search beyond one collection:- Several collections: send
collectionsinstead, as a list, or as an object of weights to rank one collection over another. Up to 100; every listed collection must exist, or the call returns400.max_resultscaps the merged list. - Knowledge and memories together:
type: "all"reads both from the same collections and ranks them together. When shared documents and memories live in different collections, list both. - A slice you already know:
metadata_filtersnarrows results before ranking, such as only runbooks or only one team’s documents. Metadata covers the operators.
5. Add relationships
Three fields bring in context beyond the chunks that matched. All three are on by default.graph_context: the relationships HydraDB extracted from your context, such as “Payments team owns billing service”, indata.graph_context.falsedrops it, but only in fast mode; thinking always includes it. The Query API reference describes its fields.query_forceful_relations: forceful relations (links you declare between sources at ingest withrelations.ids), such as a contract and its addendum, returned indata.additional_context. Thinking mode only; fast mode skips it without an error. Context shows how to declare the links.query_apps: for app sources, an extra lane that rebuilds Slack threads, follows ticket and parent links, and matches exact ids and people. It still searches everything else, and has no effect on memories.
6. Query on behalf of a user
Which identity a query runs as depends on where the content came from:- Directly ingested knowledge, and connectors without ACL enforcement: send the caller’s email in
acl, such as"acl": ["[email protected]"], to filter results to documents that person may retrieve, plus public and unrestricted ones. Withoutacl, this content is not filtered by caller identity. - Connectors with
enforce_aclenabled: HydraDB uses the authenticated caller and ignores a requestaclfor that connector’s content. API keys use the key creator’s email; MCP OAuth and dashboard requests use the signed-in user. If you sendaclanyway, a successful response includes onemeta.warningsentry with codeacl_ignored_by_connector_enforcement.
acl entry on a source or a query is a principal:
A source with no
acl is unrestricted. On a query, omitting acl, sending [], or sending ["*"] all mean no caller filtering. See ACL on synced content for connectors.
7. Use the results
HydraDB returns context, not answers: your application passes the result to a model.build_string(result) in Python and buildString(result) in TypeScript return data.llm_prompt, which numbers the ranked results [1], [2], and so on, so ask the model to cite by those numbers. Tell the model to answer only from the context, and keep the chunks in the order returned. To format the prompt yourself, read data.chunks; set response_format to "structured" to leave llm_prompt out, or to "markdown" to get only the prompt text as data.
Common mistakes
Related
- Context: the knowledge and memories a query searches
- Metadata Filters: designing filterable fields
- Query: API Reference: the full parameter and response schema
