opendunes
Helpers · 3 min
Copy page ▾

Advisor

Let a model consult a stronger one while it works, and pay for the stronger model only at those moments.

  1. What it does.
  2. Name it in tools.
  3. Shape the advisor.
  4. Read what it bills on.

This page is one helperHelperA tool run for you when a model reaches for it mid-answer: a web search, a page read, a sandbox. Named opendunes:‹name›.More on Helpers →. The list of helpers, and how the charge adds up, sit in Helpers.

1. What it does

Your model asks the advisor before it commits to an approach, when it is stuck, or before it calls a task done. The advisor's answer comes back to your model as the helper's result, and your model still writes the final answer. A cheaper model does the work, and the dearer model is called only when a question is hard.

Typeopendunes:advisor
Routes/v1/chat/completions, /v1/responses and /v1/messages
A stepone consultation
Stepsat most 30 a request
Bills onthe advisor model's tokens, in DADAThe Algerian dinar, the one currency the docs show.More on Balance and charges →, beside your model's

2. Name it in tools

Souk Bot plans the tables of a pharmacy's stock app. Sonnet does the work and asks Opus for advice at most twice. The sample prints the answer and the charge.

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"
ADVISOR = "anthropic/claude-opus-4.5"
PROMPT = "Plan the tables of a stock app for a pharmacy in Setif."

body = {
    "model": MODEL,
    "messages": [{"role": "user", "content": PROMPT}],
    "tools": [
        {
            "type": "opendunes:advisor",
            "parameters": {"model": ADVISOR},
        }
    ],
    "max_tool_calls": 2,
}
request = urllib.request.Request(
    ADDRESS,
    data=json.dumps(body).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["usage"]["cost"])

The answer is a 200. Name the helper by its type, opendunes:advisor; any other spelling of the type is a 400.

3. Shape the advisor

Put these in the helper's parameters.

ParameterDoes
modelthe advisor; left out, your model names one when it calls, and failing that the request's own model
namenames this advisor; several opendunes:advisor entries, each named, offer the model a choice, and at most one may go unnamed
instructionsthe advisor's own system instructions
forward_transcripttrue sends the advisor the whole conversation; false, the default, sends only your model's question
streamtrue streams the advice as it is written, on /v1/responses
max_completion_tokens · reasoning · temperaturepassed to the advisor's call

An advisor remembers what it was asked before when you send the conversation back with its earlier exchanges in it. Each advisor recalls only its own.

4. Read what it bills on

One charge, in DA, from your balanceBalanceWhat you can spend, in DA.More on Balance and charges →, the moment the answer ends: your model's tokens and the advisor's tokens, at the advisor model's own price. usage.cost carries the whole of it. The advisor model's page in Models gives its token rates.

The helper runs another model, so it has a spend cap. Before the model starts, OpenDunes holds money from your wallet for the words and the answer, and writes the cap into the request.

Your requestThe hold
names no stop_server_tools_whenwrites two conditions: the step count, 30 or your max_tool_calls, and a max_cost equal to half of what the wallet has left after the answer's hold; the helper stops at whichever comes first
names stop_server_tools_when with a max_costholds that cap whole; when the wallet cannot pay it, the answer is a 402 that says what the request needs
names stop_server_tools_when without a max_costkeeps your conditions and adds the cap

A cap is a condition on the request:

JSON
{
  "stop_server_tools_when": [
    { "type": "step_count_is", "step_count": 2 },
    { "type": "max_cost", "max_cost_in_dollars": 0.1 }
  ]
}

When the steps or the cap run out, the model answers with what it has gathered.

Don't

Don't send the whole conversation to the advisor on every call. With forward_transcript on, each consultation reads all of it as input.

Do

Keep forward_transcript off and let your model write the question, so the advisor reads only what it needs.