Send messages to any model and receive a completion or a streamed response.
Chat completions are the core of the OpenDunes API. Pass an ordered array of messages, choose a model, and get a reply — optionally streamed token by token.
Model slugs follow the provider/model format. Find available models at /models or via the Models API.
Set stream: true to receive tokens as they arrive over server-sent events. The openai SDK handles SSE framing automatically — you iterate over delta chunks.
The stream ends with a [DONE] sentinel. If an error occurs mid-stream, a final error event arrives before [DONE] — inspect chunk.error or catch the thrown OpenAIError.
| Field | Type | Required | Notes |
|---|---|---|---|
model | string | Yes | provider/model slug |
messages | array | Yes | system · user · assistant · tool roles |
stream | boolean | No | Default false |
max_tokens | integer | No | Cap on output tokens |
temperature | number | No | 0–2, default 1 |
top_p | number | No | 0–1, default 1 |
For models with vision capability, pass image content as a parts array:
Every response includes:
X-Balance-Available — remaining balance in micro-DA after this request.X-Request-Id — a UUID-v7 trace ID; include it when contacting support.X-RateLimit-Remaining-RPM — requests remaining in the current window.See the full error reference in API Errors.