Skip to content

REST API Reference

All endpoints are prefixed with the configured base path:

{origin}/api

All endpoints require a valid Supabase JWT in the Authorization header:

Authorization: Bearer <supabase-access-token>

Returns all sessions for the authenticated user, including their chats and messages.

GET /api/sessions

Response 200 OK

[
{
"id": "uuid",
"user_id": "uuid",
"title": "My Session",
"master_chat_index": 0,
"created_at": "2026-03-23T10:00:00Z",
"updated_at": "2026-03-23T10:30:00Z",
"chats": [
{
"id": "uuid",
"session_id": "uuid",
"position": 0,
"model_name": "GPT-4",
"context_text": "",
"title": "GPT-4 Chat",
"created_at": "2026-03-23T10:00:00Z",
"messages": [
{
"id": "uuid",
"chat_id": "uuid",
"position": 0,
"role": "user",
"content": "Hello",
"created_at": "2026-03-23T10:01:00Z"
}
]
}
]
}
]
POST /api/sessions
Content-Type: application/json

Request body

{ "title": "Compare Models" }

The title field is optional; defaults to "New Session".

Response 200 OK

{
"id": "uuid",
"user_id": "uuid",
"title": "Compare Models",
"master_chat_index": 0,
"created_at": "2026-03-23T10:00:00Z",
"updated_at": "2026-03-23T10:00:00Z"
}

Deletes the session and all its chats and messages (cascade).

DELETE /api/sessions/{id}

Response 200 OK

{ "deleted": true }
PATCH /api/sessions/{id}/master
Content-Type: application/json

Request body

{ "master_chat_index": 1 }

Response 200 OK — Returns the updated session object.


POST /api/sessions/{session_id}/chats
Content-Type: application/json

Request body

{
"model_name": "GPT-4",
"title": "GPT-4 Chat",
"context_text": "You are a helpful assistant."
}
FieldTypeRequiredDescription
model_namestringYesMust match a registered model name
titlestringYesDisplay title for the chat tab
context_textstringNoSystem prompt injected as first message

Response 200 OK — Returns ChatWithMessages (chat object flattened with messages array).

DELETE /api/sessions/{session_id}/chats/{position}

Response 200 OK

{ "deleted": true }

Sends a user message and returns the complete assistant response.

POST /api/chats/{chat_id}/query
Content-Type: application/json

Request body

{ "content": "What is quantum computing?" }

Response 200 OK — Returns ChatWithMessages with all messages including the new user and assistant messages.

Truncates messages after a given position and re-queries from that point.

POST /api/chats/{chat_id}/sync
Content-Type: application/json

Request body

{
"msg_idx": 2,
"content": "Actually, explain it differently"
}
FieldTypeDescription
msg_idxintegerPosition after which to truncate messages
contentstringNew user message to insert after truncation

Response 200 OK — Returns ChatWithMessages with the updated message history.

Imports a chat with full message history into an existing session.

POST /api/sessions/{session_id}/chats/import
Content-Type: application/json

Request body

{
"model_name": "GPT-4",
"title": "Imported Chat",
"context_text": "Optional system prompt",
"messages": [
{ "role": "user", "content": "Hello" },
{ "role": "assistant", "content": "Hi there!" }
]
}

Response 200 OK — Returns ChatWithMessages with the imported chat and all messages.


Returns all models registered in the plugin registry.

GET /api/models

Response 200 OK

[
{ "name": "GPT-4", "provider": "openai", "model_id": "gpt-4" },
{ "name": "Mistral Large", "provider": "mistral", "model_id": "mistral-large-latest" },
{ "name": "llama3", "provider": "ollama", "model_id": "llama3:latest" }
]

GET /api/context-items?offset=0&limit=50
ParameterTypeDefaultDescription
offsetinteger0Pagination offset
limitinteger50Maximum items to return

Response 200 OK

[
{
"id": "uuid",
"title": "Medical Expert",
"category": "medical",
"tags": ["doctor", "expert"],
"owner": "all",
"content": "You are a medical expert...",
"created_at": "2026-03-23T10:00:00Z"
}
]
POST /api/context-items
Content-Type: application/json

Request body

{
"title": "Code Reviewer",
"category": "development",
"tags": ["code", "review"],
"content": "You are an expert code reviewer..."
}
FieldTypeRequiredDescription
titlestringYesDisplay title
categorystringYesCategory label
tagsstring[]NoTag array
contentstringYesContext content (used for embedding generation)

Response 200 OK — Returns the created ContextItem.

GET /api/context-items/search?q=heart+disease&limit=10
ParameterTypeDefaultDescription
qstring(required)Search query text
limitinteger10Maximum results

Response 200 OK

[
{
"id": "uuid",
"title": "Cardiology Expert",
"category": "medical",
"tags": ["cardiology"],
"owner": "all",
"content": "You are a cardiologist...",
"created_at": "2026-03-23T10:00:00Z",
"similarity": 0.89
}
]

GET /api/suggestions?q=transformers&limit=5
ParameterTypeDefaultDescription
qstring(required)Search query text
limitinteger5Maximum results

Response 200 OK

[
{ "id": "uuid", "query": "How do transformer models work?", "similarity": 0.92 },
{ "id": "uuid", "query": "Explain attention mechanisms", "similarity": 0.87 }
]

All endpoints return errors in a consistent format:

{ "error": "Description of what went wrong" }
StatusMeaning
401 UnauthorizedMissing or invalid JWT token
404 Not FoundResource not found or not owned by the user
400 Bad RequestInvalid request body or model not available
500 Internal Server ErrorDatabase or provider error