/api/chatApp API keyChat completion (Ollama)
Ollama-compatible chat with automatic memory injection, BYOK routing, and optional agentic loop. Prefer /v1/chat/completions for OpenAI SDK clients. The App is resolved from your API key — do not send X-App-Id.
Headers
- Authorization (required) — Bearer cmk_live_... (App API key)
- X-User-Id (required) — Opaque end-user id from your product (email hash, internal id, etc.)
- X-Session-Id — Conversation session id; auto-generated if omitted and returned in the response header
- Content-Type (required) — application/json
Request body
{
"model": "gpt-4o-mini",
"messages": [
{ "role": "user", "content": "My favourite colour is blue." }
]
}Example
curl -X POST https://api.kortexio.io/api/chat \
-H "Content-Type: application/json" \
-H "Authorization: Bearer cmk_live_YOUR_APP_API_KEY" \
-H "X-User-Id: user-42" \
-H "X-Session-Id: support-thread-9" \
-d '{
"model": "gpt-4o-mini",
"messages": [{ "role": "user", "content": "Hi!" }]
}'Response
{
"model": "gpt-4o-mini",
"message": { "role": "assistant", "content": "Got it — I'll remember that." },
"done": true,
"context_memory": {
"message_id": "..."
}
}- Memory is scoped by (App, X-User-Id, X-Session-Id). Reuse the same session id for multi-turn context.
- Omit X-Session-Id to start a fresh conversation for the same user — Turn 1 memory is not recalled (new session id in response headers).
- Set "stream": true for NDJSON streaming (application/x-ndjson).
- Errors (English JSON): 401 Missing API key. | 401 Invalid API key. | 401 Missing X-App-Id or X-User-Id header. | 400 Invalid appId or userId format. | 400 Configure an LLM provider for this App before using /api/chat. | 429 Rate limit exceeded for your tier.
- See https://kortexio.io/docs#errors for the full error table.