Endpoint
Prefer POST /v1/chat/completions for new integrations. It supports multi-turn conversations, model override, temperature, and usage tracking via the standard OpenAI wire format.
Request parameters
string
required
The assistant (project) ID to query. Find it in the dashboard URL when viewing a project (
…/projects/<assistant_id>), via GET /v1/assistants, or under Settings → Assistant settings.string
required
The user’s message. Must be between 1 and 10,000 characters.
string
Additional page or document context passed directly to the model alongside the retrieved chunks. Maximum 20,000 characters. Useful when building embedded chatbots — pass the current page’s content here so the model can answer questions about it even if it isn’t in the knowledge base.
boolean
default:"false"
When
true, the response is returned as a Server-Sent Events stream instead of a single JSON object.string
OpenAI-style reasoning effort:
"low", "medium", or "high". Forwarded to the underlying model; only honored by reasoning-capable models (e.g. GPT-o series). When set, streaming responses additionally emit {"reasoning": "..."} events with the model’s intermediate thinking.Response
Non-streaming (default)
A JSON object with a singletext field:
string
The AI-generated answer grounded in your knowledge base.
Streaming (stream: true)
Returns a text/event-stream response. Two event shapes may appear, followed by a [DONE] sentinel:
The stream always ends with
data: [DONE]. Display reasoning chunks separately from the answer or ignore them — most users don’t need to show them.
Examples
- TypeScript SDK
- curl
- TypeScript (fetch)
Use the official
@webamigos/ragen-sdk-ts package for typed responses, streaming iterators, and automatic retries.Error codes
Example error body:
Rate limits
When rate-limited, use exponential backoff with jitter. Each streaming and non-streaming request counts equally against this budget.
How the endpoint works
When you callPOST /v1/chat, Ragen runs a five-step pipeline:
1
Authentication
Your API key is validated and the organization is resolved from it.
2
Assistant resolution
The
assistant_id is matched to a project within your organization.3
RAG retrieval
Relevant document chunks are retrieved from the assistant’s knowledge base via vector search.
4
Reranking
Retrieved chunks are reranked for relevance before being included in the prompt.
5
Generation and response
The language model generates an answer using the retrieved context and your message. The response is returned as JSON or streamed as SSE.