Skip to content

Production server API

When you run klisk start, Klisk starts a production server with a REST API, WebSocket, and chat UI.

bash
klisk start my-agent --port 8080 --host 0.0.0.0

Endpoints

MethodPathAuthDescription
GET/NoChat UI (SPA with markdown, tool calls, themes)
GET/api/infoNoAgent info + auth status
GET/healthNoHealth check
POST/api/chatYes*Chat (SSE streaming or JSON)
WS/ws/chatYes*WebSocket chat

*Auth only required if API keys are configured. See authentication.

REST API

GET /api/info

Returns basic information about the agent.

json
{"name": "MyAgent", "agent": "Assistant", "auth_required": true}

POST /api/chat

Send a message to the agent.

Request:

json
{"message": "Hello", "stream": true, "state": {}}
FieldTypeDescription
messagestringThe user message
streambooleantrue for SSE streaming, false for JSON response
stateobjectPass back between requests for conversation continuity
attachmentsarrayOptional file attachments (see below)

Auth header: Authorization: Bearer <key>

Non-streaming response (stream: false):

json
{"response": "Hello! How can I help?", "state": {...}, "done": true}

Streaming response (stream: true): Returns Server-Sent Events (SSE).

Attachments format

json
{
  "type": "image",
  "name": "photo.jpg",
  "mime_type": "image/jpeg",
  "data": "<base64 encoded, no data URL prefix>"
}
  • type: "image" or "file" (for PDFs)
  • data: Raw base64 string (not a data:... URL)

Supported formats: JPEG, PNG, GIF, WebP (images), PDF (files). Max 20MB per file.

WebSocket

WS /ws/chat

Auth: ?key=<key> query parameter.

Send a message:

json
{"message": "Hello", "previous_response_id": "resp_xxx"}

Send a message with attachments:

json
{
  "message": "Describe this image",
  "attachments": [
    {"type": "image", "name": "photo.jpg", "mime_type": "image/jpeg", "data": "<base64>"}
  ]
}

Clear conversation:

json
{"type": "clear"}

Streaming events

Both SSE and WebSocket emit the same event types:

EventDataDescription
tokenstringText delta from the LLM
thinkingstringReasoning/thinking delta
tool_call{"tool": "name", "arguments": "...", "status": "running"}Tool invocation started
tool_result{"output": "..."}Tool execution result
donestring (final output)Run completed
errorstringError message

Conversation state

State is handled differently depending on the provider:

ProviderState format
OpenAI{"previous_response_id": "resp_xxx"}
LiteLLM{"conversation_history": [...]}

The state is returned in the done event and should be passed back in subsequent requests.

Usage examples

bash
# Non-streaming
curl -X POST https://your-url/api/chat \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_KEY" \
  -d '{"message": "Hello", "stream": false}'

# Streaming (SSE)
curl -X POST https://your-url/api/chat \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_KEY" \
  -d '{"message": "Hello", "stream": true}'

# With conversation state
curl -X POST https://your-url/api/chat \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_KEY" \
  -d '{"message": "Follow up", "stream": false, "state": {"previous_response_id": "resp_xxx"}}'

# With image attachment
curl -X POST https://your-url/api/chat \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_KEY" \
  -d '{
    "message": "What is in this image?",
    "stream": false,
    "attachments": [
      {"type": "image", "name": "photo.jpg", "mime_type": "image/jpeg", "data": "<base64>"}
    ]
  }'

Chat UI features

The built-in chat UI at / includes:

  • Markdown rendering (bold, italic, code, lists, headings, links, tables)
  • Tool call display (collapsible, spinner while running)
  • Thinking traces (collapsible)
  • File attachments with drag-and-drop
  • Dark/light theme toggle
  • Reset button
  • Embed mode: /?embed=1 (full viewport, no borders)

Provider support for attachments

FormatSupported providers
ImagesOpenAI, Anthropic Claude 3+, Google Gemini, AWS Bedrock, Vertex AI, Ollama (LLaVA)
PDFsOpenAI (gpt-4o+), Anthropic, Google Gemini, Bedrock, Vertex AI

Klisk Documentation