openai library, openai-node, LangChain, LlamaIndex — works with Ragen by pointing base_url at your instance. You get the full Ragen RAG pipeline (vector retrieval → reranking → generation) behind a familiar interface, plus multi-turn conversations, per-request model and temperature overrides, and opt-in usage tracking in streams.
Endpoint
Request parameters
string
required
The assistant (project) ID to query. Retrieve available IDs from
GET /v1/assistants or from Settings → Assistant settings in the dashboard.array
required
An array of 1–100 message objects in conversation order. Each message has a
role (user, assistant, or system) and a content string. See Message roles below.string
Override the organization’s default model for this request only. Must be a model available to your organization.
number
Sampling temperature between 0 and 2. Overrides the organization default for this request.
integer
Maximum number of tokens to generate, between 1 and 32,000.
string
One of
"low", "medium", or "high". Forwarded to the model; only reasoning-capable models act on it (they default to "medium").boolean
default:"false"
When
true, the response is delivered as a Server-Sent Events stream of chat.completion.chunk objects.object
Streaming options. Pass
{ "include_usage": true } to receive a trailing usage chunk after [DONE]. See Including usage in streams.Message roles
Rejected fields
Most additional OpenAI parameters are accepted and silently ignored (e.g.top_p, stop, seed). The following three fields are rejected with a 400 error because silently dropping them would return a response that violates what you asked for:
n greater than 1 is also rejected: Ragen returns one choice, so asking for several would silently under-deliver.
Response
Non-streaming
Returns a standardchat.completion object:
Streaming
Whenstream: true, returns text/event-stream with a sequence of chat.completion.chunk objects terminated by data: [DONE]:
- The first chunk carries
delta.role: "assistant"(OpenAI convention). - Content chunks carry
delta.content. - The final chunk before
[DONE]has an emptydeltaandfinish_reason: "stop".
Including usage in streams
Passstream_options: { include_usage: true } to receive a trailing usage chunk inserted between the final content chunk and data: [DONE]:
choices: [] signals that this chunk carries usage data only.
Examples
- TypeScript SDK
- Python (openai SDK)
- curl
Error codes
Errors use the OpenAI error envelope, so existing SDK error-handling continues to work:Rate limits
Chat Completions run a full RAG pipeline (vector search + rerank + LLM call):
Both streaming and non-streaming requests count equally. When the limit is hit, back off with jitter before retrying.
Differences vs. POST /v1/chat
The native POST /v1/chat endpoint predates this one and offers a simpler interface (single content string, optional context). Both are supported:
Use
/v1/chat/completions for any new integration. Keep /v1/chat for the Ragen embed widget and other existing Ragen-native consumers.