Endpoint
Request parameters
The API key decides which assistant, and this field has to agree with it.
A key created for one assistant answers for that one whether or not you send
assistant_id; a key scoped to the knowledge base answers from the documents
that belong to no assistant, and rejects a request naming any assistant with
403. Omitting the field is the normal case. See
Authentication.string
The assistant (project) ID to search against. Optional — the API key already carries a scope, and this field must agree with it. A knowledge-base key searches the documents that belong to no assistant. Use
GET /v1/assistants to find available IDs, or check Organization → Assistant settings in the dashboard.string
required
The search query. Between 1 and 2,000 characters. Write it as a natural language question or phrase — the same way you’d phrase it to the chat endpoint.
integer
Maximum number of document chunks to return. Between 1 and 20. Defaults to the organization’s configured retrieval count.
Response
string
The context block containing the most relevant document chunks concatenated together. This is exactly what Ragen’s chat endpoints pass to the language model as retrieved context.
string[]
The IDs of the source files that contributed chunks to the context block. Use these with
GET /v1/files/{id} to trace results back to specific documents.Use cases
Build your own generation
Feed the
context string into your own prompt template and language model call, giving you full control over how the answer is generated.Inspect retrieval quality
Check which document chunks Ragen retrieves for a given query before investigating answer quality — isolates retrieval bugs from generation bugs.
Downstream processing
Extract relevant passages for summarization, translation, classification, or any other pipeline that needs grounded content without a chat-style response.
MCP integration
The
ragen_search_knowledge_base MCP tool calls this endpoint, letting external AI assistants ground themselves in your Ragen knowledge base without going through Ragen’s chat model.Examples
- TypeScript SDK
- curl
Error codes
Example error body: