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
| Field | Type | Notes |
|---|---|---|
model | string | Required loaded model selector. |
messages | array | Required non-empty chat history. |
stream | boolean | Returns server-sent events when true. |
max_tokens | integer | Maximum new tokens. |
max_completion_tokens | integer | Alias; must agree with max_tokens if both appear. |
temperature | number | Sampling temperature. |
top_p | number | Nucleus cutoff from 0 to 1. |
top_k | integer | Candidate count; zero leaves it unbounded. |
repetition_penalty | number | 1 disables the penalty. |
seed | integer | Reproducible sampler seed. |
n | integer | Only 1 is supported in 0.2.0. |
stream_options.include_usage | boolean | Adds 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.