opendunes
Overview
Copy page ▾

Parameters

The fields that shape how a text model writes its reply, with the range each takes.

Request

Send them with an API keyAPI keyThe key you create and send with every request that calls a model.More on API keys →, in the body of POST /v1/chat/completions, beside model and messages. Chat lists the route's other fields, and the Text guide walks through a first call. Every field here is optional.

A field you leave out is not filled in: the provider that serves the model applies its own default. You send names the usual one. A field the provider does not take is ignored, unless provider.require_parameters is true: then only a provider that takes every field you sent serves the request. tools, response_format and verbosity already steer the request to the providers that take them, where some do. Each model's catalogue entry lists the fields its providers take, in supported_parameters (GET /v1/models).

Souk Bot answers customers of a clothing shop in Oran. Yacine keeps its replies short and steady:

import json
import os
import urllib.request

API_KEY = os.environ["OPENDUNES_API_KEY"]
ADDRESS = "https://opendunes.com/v1/chat/completions"
MODEL = "anthropic/claude-sonnet-4.5"
PROMPT = "Do you have this jacket in size M?"

request = urllib.request.Request(
    ADDRESS,
    data=json.dumps(
        {
            "model": MODEL,
            "messages": [{"role": "user", "content": PROMPT}],
            "temperature": 0.3,
            "max_tokens": 300,
        }
    ).encode(),
    headers={
        "Authorization": "Bearer " + API_KEY,
        "Content-Type": "application/json",
    },
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)

print(answer["choices"][0]["message"]["content"])
print(answer["choices"][0]["finish_reason"])
print(answer["usage"]["cost"])

Sampling

FieldNeededYou send
temperatureno0 to 2, usually 1: lower is more predictable, higher more varied; at 0 the same prompt gives the same reply
top_pno0 to 1, usually 1: sample only from the likeliest tokens that together reach this share
top_kno0 or more, usually 0, which is off: sample only from this many likeliest tokens; 1 always takes the likeliest
min_pno0 to 1, usually 0: drop tokens below this share of the likeliest token's probability
top_ano0 to 1, usually 0: drop tokens far less likely than the likeliest one
frequency_penaltyno-2 to 2, usually 0: above 0, a token is less likely the more often it has appeared; below 0, more likely
presence_penaltyno-2 to 2, usually 0: above 0, a token is less likely once it has appeared at all, however often
repetition_penaltyno0 to 2, usually 1: above 1, repeated tokens are less likely; too high and the reply loses its small words
seednoa whole number that makes a repeat likelier to come out the same; never guaranteed
logit_biasnotoken ids mapped to a bias from -100 to 100: -1 to 1 nudges a token, -100 bans it, 100 forces it
stopnoa list of strings: the reply ends before any of them

Tools

FieldNeededYou send
toolsnothe tools the model may call, in the OpenAI shape; the model's provider receives them in its own. Tools and function calling walks through a call
tool_choicenonone, auto, required, or {"type": "function", "function": {"name": ...}} to force one tool
parallel_tool_callsnotrue or false, usually true: false has the model call one tool at a time
web_search_optionsnothe settings of a model's own web search, where its provider has one

Output shape

FieldNeededYou send
max_tokensno1 or more: the most tokens the reply may hold, at most the model's context less the prompt. A model that reasons spends it on the reasoning too, and a small ceiling can end with finish_reason: "length" and no text
max_completion_tokensnothe same ceiling, under its newer name
reasoningnohow the model reasons, where it does: whether it reasons, how hard (effort), up to how many tokens (max_tokens), and whether its reasoning is left out of the reply (exclude)
reasoning_effortnonone, minimal, low, medium, high or xhigh: the same level, as a single word
include_reasoningnotrue to return the reasoning in the reply; the older spelling of reasoning.exclude: false
response_formatno{"type": "json_object"} for a reply that is always valid JSON; say so in the prompt too. {"type": "json_schema", ...} for JSON in your shape: Structured outputs
structured_outputsnowhether the model may answer to a json_schema in response_format
logprobsnotrue to receive each token's log probability
top_logprobsno0 to 20: the likeliest alternatives to list for each token, with logprobs: true
verbositynolow, medium, high, xhigh or max, usually medium: how long and detailed the reply is

On POST /v1/responses the ceiling is max_output_tokens, the reply's shape is text.format, and verbosity is text.verbosity. On POST /v1/messages the ceiling is max_tokens, stop is stop_sequences, and reasoning is thinking.

Response

200 OK, in the route's own shape. On Chat the fields read:

FieldHolds
contentin choices[0].message: the reply, shaped by the fields above
finish_reasonin choices[0]: stop when the reply ended or met a stop string, length when it reached max_tokens, tool_calls when it calls a tool
logprobsin choices[0]: each token's log probability, and its top_logprobs alternatives, when logprobs asked for them
reasoningin choices[0].message: the reasoning, where the model reasons and does not leave it out
reasoning_tokensin usage.completion_tokens_details: the part of the reply's tokens spent reasoning
costin usage: the charge, in DADAThe Algerian dinar, the one currency the docs show.More on Balance and charges →

What it cost

Charged in DA from your balanceBalanceWhat you can spend, in DA.More on Balance and charges → once the reply is delivered: the tokens the model reports, at the model's rates, which its model page shows. usage.cost carries the charge.

  • Moves the count: max_tokens and max_completion_tokens, the ceiling on what comes back; reasoning and reasoning_effort, whose tokens count as output, left out of the reply or not; tools, whose definitions are sent on every turn.
  • Changes the answer, never the bill: the Sampling fields, logprobs, top_logprobs, response_format, structured_outputs and tool_choice.

A field changes no rate: the model, and the provider that serves it, set the rate.

Errors

error.code carries the status, and error.message says why.

StatusWhen
400a field has the wrong type or is out of range, or the provider refused a field
401the key is missing, wrong, disabled or expired
402your balance is at zero or below, cannot pay the request's hold, or the key's cap is spent; error.metadata.limit_source names which, and deposit_url or key_url says where to lift it. After up to 60 seconds of waiting for money your running requests hold, the 402 carries Retry-After: 60
404model is not a model on sale
503no provider meets the routing you asked for: with require_parameters, none takes every field you sent

What to do on each: Errors and retries.

Last modified on