Skip to main content
The Search endpoint returns the RAG context block — the ranked document chunks and source file IDs that Ragen would feed to the language model — without invoking the language model at all. Use it when you want to build your own generation pipeline, plug retrieved passages into a different model, or inspect what Ragen is actually finding before troubleshooting answer quality.
Run a search query before investigating a bad answer. If the right documents appear in context, the problem is in generation. If they don’t, the problem is in your knowledge base — the document may not be uploaded, still processing, or not yet indexed.

Endpoint

Authentication:

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

Error codes

Example error body:

Rate limits