Plugins
Add a step to a request without writing the step yourself.
1. Name a plugin in the request
Put a plugins list in the request body. Each entry is an object with an id, and the options that plugin takes. The plugin runs once on that request, before the answer reaches you.
This sample asks for a JSON order and names response-healing, so a reply that comes back with a stray comma or a cut-off bracket is repaired before you parse it.
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 = (
"Return a JSON object with the keys item and quantity for this "
"order: two sfenj and one mint tea for table 4 at the Oran cafe."
)
body = {
"model": MODEL,
"messages": [{"role": "user", "content": PROMPT}],
"response_format": {"type": "json_object"},
"plugins": [{"id": "response-healing"}],
}
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:
reply = json.load(response)
order = json.loads(reply["choices"][0]["message"]["content"])
print(order)A plugin works on the request that names it and on no other. Name it again on the next request, or switch it on for the key: section 3.
2. Pick the plugin
id | Does | Options |
|---|---|---|
file-parser | reads a PDF sent with the request, so a model that cannot open PDFs can still answer about one | pdf.engine: native, cloudflare-ai or mistral-ocr. How to send the file and which engine suits it: PDFs in |
response-healing | repairs a JSON answer that is broken: a missing bracket, a trailing comma, text around the object | none |
context-compression | cuts the middle of a prompt that is too long for the model, and keeps its start and its end | none |
web | attaches search results to the prompt. RetiredRetiredA model withdrawn from sale. A call to its ID returns 404.More on Models →: use the web search 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 →, Helpers | none |
Response healing repairs the shape of the JSON, never its meaning. A reply that is valid JSON with the wrong values stays wrong: check the fields you rely on.
Context compression drops the middle of the prompt. When the middle holds the answer, send a model with a longer context instead, or shorten the prompt yourself.
An id the door does not know is refused with a 400, and so is an option that points the plugin at an engine billed to your own account somewhere else. The router has a plugin of its own, auto-router, which is described on Auto router.
3. Switch a plugin on for a key
To run a plugin on every request of one key without changing the code that sends them, switch it on in the key's settings in your dashboard. Every request of that key then runs it, as if each had named it.
| Where | Runs the plugin on |
|---|---|
the request's plugins list | that request |
| the key's settings in the dashboard | every request of that key |
Switch a plugin on for a key when the whole app needs it, such as response healing on a key that only returns JSON. Name it in the request when only one call does.
4. Read what it cost
response-healing and context-compression are free. file-parser is charged only when the model cannot read the PDF itself; a model that reads PDFs natively is charged for the request alone. Whatever a plugin cost is counted in usage.cost of the answer, like the rest of the request: Balance and charges.
Don't name file-parser for a model that reads PDFs by itself, to be safe. It adds nothing there. Name it when the model you picked cannot open the file.
Errors
The body says why. What to do on every status: Errors and retries.
| Status | Means |
|---|---|
| 400 | the id is not a plugin the door knows, or an option is refused; the message names which |
| 401 | the key is missing or wrong |
| 402 | the balanceBalanceWhat you can spend, in DA.More on Balance and charges → cannot cover the request |