Skip to main content

API Reference

Chat Completions

POST /api/chat — SSE streaming chat endpoint.

Request

Bash
POST /api/chat
Authorization: Bearer slm_YOUR_KEY
Content-Type: application/json

{
  "messages": [
    {"role": "user", "content": "Write an Anchor counter program"}
  ],
  "max_tokens": 4096,
  "temperature": 0.0,
  "stream": true
}

Streaming response

Server-sent events, each data: line is a JSON chunk:

Text
data: {"choices":[{"delta":{"content":"Here"}}]}
data: {"choices":[{"delta":{"content":"'s"}}]}
...
data: {"usage":{"prompt_tokens":42,"completion_tokens":128,"total_tokens":170}}
data: [DONE]

Non-streaming

Omit stream or set false. Response follows the OpenAI schema with choices[0].message.content.