v5

OpenAPI 3.1.02026-08-043621,4011.8 MB
Agents Platform

Query Agent Knowledge Base Rag

Run the agent's exact RAG retrieval for an ad-hoc query and return the ranked chunks the agent would retrieve. Read-only: no conversation is created. The response reflects current retrieval internals and may evolve.

post/v1/convai/agents/{agent_id}/knowledge-base/rag-query

Path parameters

agent_idstring required

The id of an agent. This is returned on agent creation.

Example:agent_3701k3ttaq12ewp8b7qv5rfyszkz

The id of an agent. This is returned on agent creation.

Query parameters

branch_idstring nullable

The ID of the branch to use

Example:agtbranch_0901k4aafjxxfxt93gd841r7tv5t

The ID of the branch to use

Headers

xi-api-keystring nullable

Your API key. This is required by most endpoints to access our API programmatically. You can view your xi-api-key using the 'Profile' tab on the website.

Your API key. This is required by most endpoints to access our API programmatically. You can view your xi-api-key using the 'Profile' tab on the website.

Request body

querystring required

Query to run against the agent's knowledge base RAG index.

use_agent_defaultsboolean

When true (the default), retrieval uses the agent's own RAG settings, reproducing exactly what the agent would retrieve. Set to false to retrieve with neutral default RAG settings instead (the agent's embedding model is always kept, since it determines which vector index exists). Useful for auditing the knowledge base independently of how a particular agent is tuned.

Example request

{
  "query": "How do I reset my password?"
}

Response

Successful Response

retrieval_querystring required

Raw query used for retrieval (echoes the request query).

Example response

{
  "chunks": [
    {
      "chunk_id": "chunk_498cjVigY5qzO86Huf0OWal",
      "document_id": "doc_J3Pbu5gP6NNKBscdCdwB",
      "document_name": "Account FAQ",
      "text": "To reset your password, open Settings and choose Security...",
      "vector_distance": 0.21
    }
  ],
  "retrieval_query": "How do I reset my password?"
}