Skip to main content
POST
/
v1
/
retrieval
Get context
curl --request POST \
  --url https://api.qontext.ai/v1/retrieval \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '
{
  "knowledgeGraphId": "kg_681c0068-b589-4923-ac4a-73040fab7a45",
  "prompt": "Give me the following information regarding Harry Potter. 1) Who is he?, 2) What is his relationship with Gryffindor Inc., Weasleys Wizard Wheezes, and Ollivanders?",
  "limit": 5,
  "depth": 1
}
'
[
"*Harry Potter*: Harry Potter is a contact with email [email protected]...",
"*Harry Potter -> Gryffindor Inc. (works_at)*: Harry Potter works at Gryffindor Inc. as Project Lead."
]
This endpoint retrieves relevant context from your knowledge graph based on a textual prompt. Understanding how the system processes your prompt is critical to achieving best-in-class results.
  1. Similarity search: The knowledge graph is first searched to find nodes that are most similar to the prompt. This ensures that only the most relevant information is considered for retrieval.
  2. Optional reranking: If rerank is enabled, the system also analyzes the prompt for example for bullet points or enumerated instructions (e.g., “1) Look at this, 2) Include this as well, 3) This is also important”). These bullets are used to rerank the retrieved nodes so that the final context better reflects the user’s priorities and instructions.

Authorizations

X-API-Key
string
header
required

API key for the Qontext API

Body

application/json
knowledgeGraphId
string
required

The id of the vault from which to retrieve context.

Example:

"kg_681c0068-b589-4923-ac4a-73040fab7a45"

prompt
string
required

The prompt to retrieve context for.

Example:

"Give me the following information regarding Harry Potter. 1) Who is he?, 2) What is his relationship with Gryffindor Inc., Weasleys Wizard Wheezes, and Ollivanders?"

limit
number
required

Number of nodes to consider at the first level of the knowledge vault.

Example:

5

depth
number
required

Depth of nodes to retrieve from the graph.

Example:

1

includeSources
boolean
default:false

Include source information in response. When false (default), returns simple text strings. When true, returns objects with text and sources.

Response

Context successfully retrieved