Send chat messages and stream responses using the OpenDunes API from Go.
Chat completions are the core of the OpenDunes API. Send a messages array, get a response — or stream tokens as they arrive.
The endpoint follows the OpenAI chat-completions schema, so an OpenAI-compatible Go client pointed at https://opendunes.com/api/v1 drives it through its chat service — check your installed SDK version's own documentation for the exact call shape, since the Go client's parameter helpers change between releases. The wire surface below is the contract any Go HTTP client can target directly.
POST /chat/completions with a model and a messages array:
The response carries the reply in choices[0].message.content and token counts in usage:
Set "stream": true and the server emits SSE data: chunks, each carrying a choices[0].delta.content fragment, terminated by a data: [DONE] sentinel. The final chunk carries token usage in usage.
An OpenAI-compatible Go client exposes this through its streaming call (the equivalent of Chat.Completions.NewStreaming), iterating chunks until the stream closes.
| Parameter | Type | Notes |
|---|---|---|
model | string | Required. provider/model slug — see Models. |
messages | array | Required. Roles: system, user, assistant. |
stream | bool | Stream SSE delta chunks. |
max_tokens | int | Cap output length. |
temperature | float (0–2) | Sampling temperature. |
top_p | float (0–1) | Nucleus sampling. |
Each response includes:
X-Request-Id — UUID-v7 trace ID (quote this in support requests).X-Balance-Available — remaining balance in micro-DA.X-RateLimit-Remaining-RPM — requests left in the current minute window.On failure the API returns a JSON body { "error": "<code>", "message": "<text>" }. Common codes: insufficient_credits (HTTP 402 — top up your DA balance), rate_limited (429 — respect the Retry-After header), model_not_found (404).