Querying a Graph
Retrieve multi-hop context from a graph in one call
graph.query is experimental and available to every Zep account. The request, the response, the events, and the modes of the operation can change.
Some agent tasks need multi-hop retrieval. The agent does not know in advance what to search for. It must retrieve a record, learn from it, and then plan the next retrieval. Smart Query (graph.query) is the agentic retrieval API of Zep. In one call, Zep explores one graph with searches and graph traversals. It uses the records from each retrieval round to plan the next round. The operation is read-only.
The response contains at most 300 records in results. When the query returns more than 300 records, the server keeps cited records first in citation order. The server then keeps other records in the order that retrieval calls first returned them. The response sets truncated to true when the server omits records.
By default, the response has the records and no answer. When the request sets generate_answer to true, the response also includes an answer that a model writes from the records and citations to the graph items.
Select a mode
The mode field selects the retrieval mode. The default is fast.
A value other than fast or deep returns 400 invalid_request with param set to mode.
Check the answer status
When the request sets generate_answer to true, the response also has answer_status. Use this field to find a refusal. Do not compare the text of answer, because the model writes the answer in the language of the query or in the language that the guidance requests.
A response without an answer has no answer_status. When the status is partial or refused, results still contains the retrieved records. You can send the query again with mode set to deep, which can read more records.
BYOM and BYOC
fast mode needs a decision model. A Zep-hosted project uses a Zep decision model. A BYOM project or a BYOC deployment must configure a decision model to use fast mode.
- When a BYOM project has a decision model,
fastmode uses that decision model. A BYOC deployment can usefastmode only when it has a BYOM configuration with a decision model, such as SystemOne or Gemini Decisions. - When a BYOM project or a BYOC deployment has no decision model, set
modetodeep. All model calls of adeepquery go to your BYOM provider. Afastrequest returns400 invalid_requestwithparamset tomodeand the message “Fast mode requires a decision model when the project uses its own LLM provider. Add a decision model in LLM providers, or set mode to deep.” - When the BYOM configuration has no compatible model, a
deeprequest returns400 invalid_request.