🔌 API Documentation

Local REST API for integration with your tools and workflows

⚡ Quick Start

  1. Open KaiROS AI and load a model
  2. Go to Settings → API Server and enable the API
  3. Send requests to http://localhost:5000/
GET /

Returns a beautiful HTML documentation page with API status.

Response

200 OK
HTML page with API documentation and status
GET /health

Check API status and currently loaded model.

Response

200 OK
{
  "status": "ok",
  "model": "phi-3-mini-4k-instruct.Q4_K_M.gguf",
  "version": "1.0.0"
}
GET /models

List all downloaded models available for use.

Response

200 OK
{
  "object": "list",
  "data": [
    {
      "id": "phi-3-mini-4k-instruct.Q4_K_M.gguf",
      "object": "model",
      "owned_by": "kairos-local"
    }
  ]
}
POST /chat

Send a message and receive a complete response (non-streaming).

Request Body

Field Type Description
messages array Array of message objects with role and content

Example Request

curl -X POST http://localhost:5000/chat \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      { "role": "user", "content": "Hello!" }
    ]
  }'

Response

200 OK
{
  "model": "phi-3-mini-4k-instruct.Q4_K_M.gguf",
  "content": "Hello! How can I help you today?",
  "token_count": 8
}
POST /chat/stream

Send a message and receive a streaming response (Server-Sent Events).

Request Body

Same as /chat

Example Request

curl -X POST http://localhost:5000/chat/stream \
  -H "Content-Type: application/json" \
  -d '{"messages":[{"role":"user","content":"Hello!"}]}'

Response (SSE Stream)

200 OK
data: {"content": "Hello"}

data: {"content": "!"}

data: {"content": " How"}

data: {"content": " can"}

data: [DONE]
Error Responses

503 - No Model Loaded

503
{
  "error": {
    "message": "No model loaded. Please load a model first.",
    "type": "invalid_request_error"
  }
}

400 - Invalid Request

400
{
  "error": {
    "message": "Messages array is required",
    "type": "invalid_request_error"
  }
}