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

FieldTypeNotes
model Requiredstringmugen-5, mugen-5-swift or mugen-5-deep. mugen-4 is served by mugen-5.
messages Requiredarray of ChatMessage
max_tokensintegerAt most the model's maximum output. At least 1.
max_completion_tokensintegerThe same as max_tokens; takes precedence. At least 1.
temperaturenumber0, or a seed, repeats a reply for the rest of the UTC day. 0 to 2.
top_pnumber 0 to 1.
ninteger 1 to 8.
stopstring or array or nullA string or up to four strings.
seedinteger
streamboolean
stream_optionsobject
response_formatobject
memory_scopestringUp to 128 letters, digits, ., _, - or :. MUGEN remembers the scope's earlier questions.
toolsarrayAccepted and not acted on.
POST /v1/chat/completionscurl
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."
      }
    ]
  }'
ResponseJSON
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
  }
}
Response with "stream": trueSSE
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]

Errors

  • 400 Invalid request: a missing or invalid parameter, named in param.
  • 401 No key, or a key that is malformed, expired or revoked.
  • 404 Unknown route or model.
  • 413 Request body larger than 10 MB.
  • 429 Rate limited, or MUGEN is declining this caller for a while. See retry-after.