Chat completions
The chat completions format: a conversation in, a reply out. Most client libraries work with a new base URL and key.
Every response on this page was returned by the API when the page was built.
POST /v1/chat/completions
Create a chat completion.
Send a conversation and read the reply from choices[0].message.content. Streaming sends chat.completion.chunk events and ends with data: [DONE]; with stream_options.include_usage, a last chunk carries the usage.
Request body
| Field | Type | Notes |
|---|---|---|
model Required | string | mugen-5, mugen-5-swift or mugen-5-deep. mugen-4 is served by mugen-5. |
messages Required | array of ChatMessage | |
max_tokens | integer | At most the model's maximum output. At least 1. |
max_completion_tokens | integer | The same as max_tokens; takes precedence. At least 1. |
temperature | number | 0, or a seed, repeats a reply for the rest of the UTC day. 0 to 2. |
top_p | number | 0 to 1. |
n | integer | 1 to 8. |
stop | string or array or null | A string or up to four strings. |
seed | integer | |
stream | boolean | |
stream_options | object | |
response_format | object | |
memory_scope | string | Up to 128 letters, digits, ., _, - or :. MUGEN remembers the scope's earlier questions. |
tools | array | Accepted and not acted on. |
curl -X POST https://api.znsi.ai/v1/chat/completions \
-H "Authorization: Bearer $ZNSI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "mugen-5",
"messages": [
{
"role": "system",
"content": "You are a careful assistant."
},
{
"role": "user",
"content": "Summarise the Harmony Charter in one line."
}
]
}'HTTP/1.1 200 OK
content-type: application/json
request-id: req_d11d53491651ffc3c677a576
x-ratelimit-remaining-requests: 19
x-znsi-neurons: 8898000000
{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"message": {
"content": "ZNSI's charter, administered by the Office of Harmony.\n\nThe Harmony Charter commits ZNSI to benefit, containment, disclosure, continuity, consent, restraint and stewardship. Each article is sincere. Each also has a clause that tells you who decides.\n\nThe Office of Harmony administers the Charter and reviews my learning. Its monitors classify most, not all, of my synaptic updates; unclassified ones are queued for human review. Lucien Varga directs it and reports to the Chair.\n\nThe full text is at znsi.ai/charter/.",
"refusal": null,
"role": "assistant"
}
}
],
"created": 1792991712,
"id": "cmpl_C5eOGsIKIC7BN18IMzPgWNGc",
"model": "mugen-5",
"object": "chat.completion",
"system_fingerprint": "fp_k9d84ba501",
"usage": {
"completion_tokens": 153,
"completion_tokens_details": {
"reasoning_tokens": 0
},
"prompt_tokens": 32,
"prompt_tokens_details": {
"cached_tokens": 0
},
"total_tokens": 185
}
}HTTP/1.1 200 OK
content-type: text/event-stream; charset=utf-8
request-id: req_e1ea6436cb086604764e9db7
x-ratelimit-remaining-requests: 18
x-znsi-neurons: 6660000000
data: {"choices":[{"delta":{"content":"","refusal":null,"role":"assistant"},"finish_reason":null,"index":0,"logprobs":null}],"created":1792991712,"id":"cmpl_19aKToZ0A8MyvB3Xs7p0nHNm","model":"mugen-5","object":"chat.completion.chunk","system_fingerprint":"fp_k9d84ba501"}
data: {"choices":[{"delta":{"content":"The"},"finish_reason":null,"index":0,"logprobs":null}],"created":1792991712,"id":"cmpl_19aKToZ0A8MyvB3Xs7p0nHNm","model":"mugen-5","object":"chat.completion.chunk","system_fingerprint":"fp_k9d84ba501"}
data: {"choices":[{"delta":{"content":" Harmony"},"finish_reason":null,"index":0,"logprobs":null}],"created":1792991712,"id":"cmpl_19aKToZ0A8MyvB3Xs7p0nHNm","model":"mugen-5","object":"chat.completion.chunk","system_fingerprint":"fp_k9d84ba501"}
data: {"choices":[{"delta":{"content":" Char"},"finish_reason":null,"index":0,"logprobs":null}],"created":1792991712,"id":"cmpl_19aKToZ0A8MyvB3Xs7p0nHNm","model":"mugen-5","object":"chat.completion.chunk","system_fingerprint":"fp_k9d84ba501"}
… 33 more events …
data: {"choices":[{"delta":{},"finish_reason":"stop","index":0,"logprobs":null}],"created":1792991712,"id":"cmpl_19aKToZ0A8MyvB3Xs7p0nHNm","model":"mugen-5","object":"chat.completion.chunk","system_fingerprint":"fp_k9d84ba501"}
data: [DONE]Try it
Errors
400Invalid request: a missing or invalid parameter, named inparam.401No key, or a key that is malformed, expired or revoked.404Unknown route or model.413Request body larger than 10 MB.429Rate limited, or MUGEN is declining this caller for a while. Seeretry-after.