POST /query searches your knowledge, your memories, or both, and 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. In this guide:
- Run a query and read what comes back.
- Pick a recipe: starting parameters for the common cases.
- Tune the ranking:
mode,alpha,recency_bias, andmax_results. - Choose what to search: several collections, knowledge and memories together, and metadata filters.
- Add relationships: the context graph, linked sources, and app-aware search.
- Query on behalf of a user: the
aclfield. - Common mistakes.
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.chunks: the matching passages, ranked by relevance, each with itschunk_content,source_title,relevancy_score, andmetadata. Keep the order.data.sources: one entry per source, with itsid,title, andurlfor citations.data.graph_contextanddata.additional_context: relationships and linked passages, covered in section 5.
build_string (Python) or buildString (TypeScript) for a prompt-ready string. See How to Use API Results for more. New context is searchable once its indexing status reaches graph_creation.
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; Semantic Search covers query_by.
3. Tune the ranking
Most of the time the defaults are right. When they are not, start here:mode:"fast"is one retrieval pass, for chat and autocomplete."thinking"expands the query, reranks, and pulls in linked sources, 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. Semantic Search has the full table.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 passages 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. Context Graphs explains how to read it.query_forceful_relations: sources linked 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. Knowledge 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
Send the caller’s email inacl, such as "acl": ["[email protected]"], and results are limited to documents that person may retrieve, plus public and unrestricted ones. Without acl the query is not filtered, so derive it from your signed-in session, never from the client. Access Control covers setting ACLs on documents and the principal forms.
Common mistakes
Related
- Knowledge: the documents and app records a query searches
- Memories: preferences, decisions, and past conversations
- How to Use API Results: turning the response into a model prompt
- Semantic Search: how meaning and keyword matching combine, and the
alphatable - Context Graphs: reading and using
graph_context - Metadata: designing filterable fields
- Access Control: giving documents ACLs and querying as a caller
- Query: API Reference: the full parameter and response schema
