The OpenAI Runs API (
POST /v1/threads/{id}/runs), which automates the generate-and-save loop, is not yet implemented in Ragen. Use the manual loop described below in Generating AI responses.Threads endpoints
Create a thread
POST /v1/threads
array
Optional array of messages to seed the thread with on creation. Each message has a
role (user or assistant) and a content string.object
Arbitrary key-value metadata. Accepted and returned as-is.
string
Ragen extension. Thread title displayed in the dashboard sidebar.
string
Ragen extension. Bind the thread to a specific assistant using its
asst-<projectId> ID. Defaults to the API key’s bound project.List threads
GET /v1/threads — returns threads across your organization.
integer
default:"20"
Between 1 and 100.
string
default:"desc"
Sort order by
created_at. Either asc or desc.string
Thread ID cursor — returns threads created after the given ID.
Modify a thread
BothPOST /v1/threads/{id} and PATCH /v1/threads/{id} accept title (Ragen extension) and metadata.
Delete a thread
DELETE /v1/threads/{id} — deletes the thread and all its messages. Returns:
Messages endpoints
Create a message
POST /v1/threads/{id}/messages — persists one turn on the thread. Does not run the model. Use Chat Completions when you need an AI-generated reply.
string
required
Either
user (human turn) or assistant (AI turn, useful for backfilling history or importing transcripts).string
required
The message text.
List and retrieve messages
GET /v1/threads/{id}/messages returns OpenAI thread.message objects with a typed content array. Each item is currently always a single text block — Ragen doesn’t store multimodal messages on threads today.
GET /v1/threads/{id}/messages/{message_id} retrieves a single message.
Encrypted threads
Threads created through the Ragen dashboard with encryption enabled store message content as ciphertext. The API cannot decrypt this content — read endpoints return a placeholder:Generating AI responses
Threads are storage only. To generate a response and persist it, follow this manual loop:1
Persist the user's message
2
Call Chat Completions to run RAG
Pass the conversation history inline. Ragen retrieves relevant chunks and generates the reply.
3
Persist the assistant's reply
Save the generated reply back to the thread.
Examples
- TypeScript SDK
- Python (openai SDK)