Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Chat completions

Use POST /v1/chat/completions with a model already loaded into the shared runtime.

curl http://127.0.0.1:8080/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $MIRMIR_HTTP_API_KEY" \
  -d '{
    "model": "qwen",
    "messages": [{"role": "user", "content": "Hello"}],
    "temperature": 0.2,
    "max_tokens": 256
  }'

Parameters

FieldTypeNotes
modelstringRequired loaded model selector.
messagesarrayRequired non-empty chat history.
streambooleanReturns server-sent events when true.
max_tokensintegerMaximum new tokens.
max_completion_tokensintegerAlias; must agree with max_tokens if both appear.
temperaturenumberSampling temperature.
top_pnumberNucleus cutoff from 0 to 1.
top_kintegerCandidate count; zero leaves it unbounded.
repetition_penaltynumber1 disables the penalty.
seedintegerReproducible sampler seed.
nintegerOnly 1 is supported in 0.2.0.
stream_options.include_usagebooleanAdds usage to the final SSE chunk.

Streaming

curl -N http://127.0.0.1:8080/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "qwen",
    "messages": [{"role": "user", "content": "Hello"}],
    "stream": true,
    "stream_options": {"include_usage": true}
  }'

Each event contains a chat.completion.chunk. The stream ends with data: [DONE]. Reasoning-capable models emit delta.reasoning_content separately from delta.content.

One image

The OpenAI-style image_url content part accepts a data URL. Version 0.2.0 supports one PNG, JPEG, WebP, or GIF per request.

IMAGE_DATA=$(base64 < image.jpg | tr -d '\n')
curl http://127.0.0.1:8080/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d "{\"model\":\"vision-model\",\"messages\":[{\"role\":\"user\",\"content\":[{\"type\":\"image_url\",\"image_url\":{\"url\":\"data:image/jpeg;base64,$IMAGE_DATA\"}},{\"type\":\"text\",\"text\":\"Describe this image\"}]}]}"

The application limit is 20 MiB per decoded image. The server body limit must also accommodate the larger base64 request.