opendunes
Management
Copy page ▾

Saved settings

POST /v1/presets/{slug}/chat/completions saves a request's settings under a name; seven routes save, list and read your presets and their versions.

Request

Send them with an API keyAPI keyThe key you create and send with every request that calls a model.More on API keys →. A request uses a preset by sending @preset/<slug> as its model: the preset's settings apply, and any field the request sends itself wins. The Presets guide saves one and calls it.

RouteDoes
POST /v1/presets/{slug}/chat/completionssaves a preset from a Chat request body
POST /v1/presets/{slug}/messagessaves one from a Messages request body
POST /v1/presets/{slug}/responsessaves one from a Responses request body
GET /v1/presetslists your presets
GET /v1/presets/{slug}answers one preset, with the version a request runs
GET /v1/presets/{slug}/versionslists its versions, oldest first
GET /v1/presets/{slug}/versions/{version}answers one version

Save

The body is a request in the route's own shape, as you would send it to Chat or Messages. The first save of a slug makes the preset; every save after it adds a version, and the newest is the one a request runs. Every version is kept.

FieldNeededYou send
slugyesin the address: the preset's name, letters, digits, ., _ and -, up to 120 characters, starting with a letter or a digit
modelyesthe model, lab/model, and with it any of the request's settings: models, provider, the Sampling fields, max_tokens, reasoning, response_format or text, tools, tool_choice, plugins, cache_control and the rest of the fields its reference page lists
messagesnokept for one thing only: the system prompt, from a system or developer turn. On /messages it is system, on /responses instructions. The conversation itself is never kept

Send X-OpenDunes-Cache: true with the save, and X-OpenDunes-Cache-TTL, to keep the response cache in the preset too.

Yacine saves Souk Bot's settings as souk-bot; his app then sends "model": "@preset/souk-bot".

import json
import os
import urllib.request

API_KEY = os.environ["OPENDUNES_API_KEY"]
ADDRESS = "https://opendunes.com/v1/presets/souk-bot/chat/completions"
MODEL = "anthropic/claude-sonnet-4.5"
SYSTEM = "You answer customers of an Algerian marketplace, in their language."

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

print(preset["slug"], preset["designated_version"]["version"])

List

GET /v1/presets and GET /v1/presets/{slug}/versions take their fields in the address, after ?.

FieldNeededYou send
limitnohow many one page holds, 1 to 100; absent, 50
offsetnohow many to skip, for the next page

Response

A save and GET /v1/presets/{slug} answer 200 OK with data, the preset and its designated_version. The two lists answer data, a list, and total_count.

FieldHolds
datathe preset, the version, or the list
total_counton a list: how many there are in all
idthe preset's id
slugits name: send @preset/<slug> as model
nameits name, the slug
descriptionnull
statusactive
status_updated_atnull
creator_user_idyour account's id
designated_version_idthe version a request runs
designated_versionthat version, whole, on a save and on one preset
created_at · updated_atwhen it was made and last saved, in UTC

A version holds:

FieldHolds
preset_idits preset
versionits number, from 1
configthe settings it keeps: the model and every setting the body sent, and cache when the save sent the cache headers
system_promptthe system prompt it adds to a request that has none, or null
creator_idyour account's id
id · created_at · updated_atthe version's own id, and when it was saved, in UTC

What it cost

Free. Saving and reading a preset is never charged. A request that names @preset/<slug> is charged as that request, at the rates of the model the preset sets.

Errors

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

StatusWhen
400model is missing from a save, or the slug is not a name the route takes
401the key is missing, wrong, disabled or expired
403the key is kept to other addresses
404no preset of yours has that slug, or it has no such version

Last modified on