Create a chat completion — the core inference endpoint.
POST https://opendunes.com/v1/chat/completionsBilled, with an API key: Authorization: Bearer $OPENDUNES_API_KEY. The request and the answer are the OpenAI library's Chat Completions shape. The full guide is Chat Completions; every parameter is on Parameters.
curl https://opendunes.com/v1/chat/completions \
-H "Authorization: Bearer $OPENDUNES_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-5",
"messages": [
{ "role": "system", "content": "You answer Souk customers in French." },
{ "role": "user", "content": "Quels sont vos horaires le vendredi ?" }
],
"max_tokens": 300
}'Every parameter travels to the model as you sent it. The answer is the model's, with usage.cost — the charge in DA. A non-streamed answer carries X-Generation-Id and X-Balance-Available; a streamed one carries X-Generation-Id — see Streaming.
| the model | any text, audio-chat or music model; a preset (@preset/<slug>); a router (opendunes/auto); suffixes such as :nitro, :floor, :exacto |
| helpers | opendunes:web_search, opendunes:web_fetch, opendunes:image_generation, opendunes:datetime and the others in tools, beside your own functions. Shell, bash, apply patch and tool search work on Messages and Responses, not here |
| the response cache | X-OpenDunes-Cache: true — see Response caching |
provider.max_price | in DA |
A model that is not on sale is a 404, and nothing is charged. Errors are on Errors and Debugging.