Retrieval

Retrieval

Search your knowledge base and return the most relevant chunks for a query, with no LLM generation, for use as context by LLMs and agents. The mode parameter selects the retrieval mode.

The same retrieval is available as a tool on Kapa's hosted MCP servers.

post/query/v1/projects/{project_id}/retrieval/

Request

  • Base URL: https://api.kapa.ai
  • URL: https://api.kapa.ai/query/v1/projects/{project_id}/retrieval/
  • Auth: one of:
    • API key in cookie sessionid
    • HTTP bearer
    • API key in header X-API-KEY

Path parameters

project_idstring required

The ID of the project.

Request body

source_group_ids_includestring[]

Optional list of source group IDs for filtering retrieval data.

querystring required

The query to perform retrieval on.

mode'default' | 'deep'
use_pruningboolean

Deprecated: switch to mode: deep instead. Prunes low relevance chunks in the default mode at added latency.

top_kinteger

The maximum number of chunks to return. Fewer may be returned if max_chars or the deep mode are used.

max_charsinteger

Maximum number of characters across all returned chunks. Chunks are included in order of relevance, but only up to the point where the total character count stays within this limit. Chunks are never truncated. This is an upper bound, not a target. Especially with the deep mode, the returned total may be well below this limit.

integration_idstring uuid nullable

The integration these queries belong to, from create_api_integration. Analytics groups by it, so a query sent without one cannot be told apart from the project's other traffic.

redact_queryboolean

Optionally redact the query in analytics.

Response

source_urlstring required

The URL of the source.

contentstring required

The content of the source in Markdown format, as ingested by kapa.ai.

Changes

No recorded changes to this operation across all 1 revision of this API.