> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mibyanai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Chat Completions

> Create a chat completion with optional SSE streaming

This endpoint follows the OpenAI Chat Completions shape. Streaming returns data-framed completion chunks followed by `data: [DONE]`.

```bash theme={null}
curl https://api.mibyanai.com/v1/chat/completions \
  -H "Authorization: Bearer $MIBYAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"mibyan-4.1","messages":[{"role":"user","content":"Hello"}],"stream":true}'

The request must contain at least one message. Supported roles are `system`, `developer`, `user`, `assistant`, and `tool`. The gateway validates message size, generation limits, sampling values, tools, and structured-output settings before sending the request.

For field-by-field behavior, see [compatibility](/api-reference/compatibility) and [streaming](/api-reference/streaming).
```
