Skip to main content
Query turns stored context into the right context for a specific query. One endpoint - POST /query - queries Knowledge (documents and app sources), Memories (user preferences, conversation history, inferred content), or both. Three signals drive relevance: dense-vector similarity, BM25 keyword matching, and context-graph traversal. The parameters below control all of it. For the full request and response schema, see Query - API Reference.

1. Use-case recipes

Pick the row that matches your goal and use the parameters as a starting point:

2. Parameter reference

Follow this for when to use database and collection The database field was formerly tenant_id and collection was formerly sub_tenant_id; the old names remain accepted as deprecated aliases.

Scope

Graph

Shaping results


3. Tuning heuristics

Most of the time the defaults are right. When they aren’t, here’s where to start:
  • mode - If omitted, defaults to "auto": it scores the query before retrieval and routes to "fast" or "thinking" (defaulting to "thinking" when the signal is inconclusive), and overrides graph_context to match whichever it picks. Pick "fast" or "thinking" explicitly instead when you know your traffic shape and want a deterministic pipeline.
  • alpha - Start at 0.8. Lower toward 0.3–0.5 when the query contains literal tokens (error codes, SKUs, product names). Raise toward 0.9 for conceptual questions. Use "auto" when query shape varies across calls.
  • max_results - Start at 10. Drop to 5 for tight context windows; raise to 20 if you rerank downstream.
  • additional_context - Use it when the query alone is ambiguous. Keep it short and factual.
  • graph_context - Set to true when answers benefit from entity relationships (multi-hop questions, “how does X relate to Y”). Pair with mode: "thinking" - in "fast" mode the graph slice is shallow.
  • query_apps - Set to true when querying ingested app data (Slack, Gmail, Confluence, Jira, Salesforce) to activate exact ID and actor lookups, same-thread expansion, and parent/child hierarchy traversal. This adds better app-aware retrieval on top of the normal knowledge query; it does not filter out non-app knowledge. Pair with mode: "thinking".

4. Minimal working example

The canonical personalized-answer flow takes a single call: POST /query with type: "all" returns merged knowledge and per-user memory in one ranked result set.

Setup

One call - Knowledge and Memories together

Merge into the LLM prompt

The response is a single RetrievalResult containing chunks[], sources[], and - when applicable - graph_context and additional_context. Chunks from Knowledge and Memories are already interleaved and ranked by relevance, so no manual merging is required. Pass the result through the helper in How to Use API Results to turn it into a context string for your prompt:
If you need to query several users, teams, or workspaces at once, pass collections. A list gives every scope equal normalized weight; an object applies relative ranking weights with at most one decimal place before the final merged ranking. When max_results is set, it caps the final merged response across all selected collections:
If you need to keep Knowledge and Memories formatted differently in the prompt, call /query twice in parallel with type: "knowledge" and type: "memory", then merge client-side.

Production checklist

  • Default to type: "all" for personalized answers - one call instead of two, scoped with collections.
  • Set per-call timeouts. Generous for thinking (3–5 s), tight for fast (≤500 ms). For mode: "auto", size the timeout for the thinking case - it can resolve to either pipeline and defaults toward thinking when the routing signal is inconclusive.
  • Enable query_apps: true when querying app sources to activate app-aware retrieval and thread/relation traversal.
  • Pass additional_context with known session state (page, feature, role). It sharpens retrieval without extra calls.

5. Common mistakes


6. Advanced patterns

Hybrid + text in two parallel calls. When a query mixes a literal token (error code, SKU, function name) with natural-language intent, run query_by: "hybrid" and query_by: "text" in parallel, dedupe by chunk ID, and treat text hits as a “must include” floor. Recall-then-rerank. Ask for more chunks than you actually need (max_results: 20) and apply your own reranker - recency windows, compliance filters, business rules - before picking the final top-k for the prompt. Cache the prompt context. If the same query repeats inside a session, cache the RetrievalResult keyed by (database, collection, query, type, query_by). Recall is fast, but skipping it entirely is faster.