Endpoint
Request parameters
string
required
The assistant (project) ID to search against. Use
GET /v1/assistants to find available IDs, or check Settings → 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: