opendunes
Model types · 4 min
Copy page ▾

System One

Ask typed questions of a case on the /v1 address; get each answer with a score.

  1. Pick a System One model.
  2. Send your questions.
  3. Read each answer.

1. Pick a System One model

A System One model judges one case against your questions and answers each one under the name you gave it. It takes the same case, questions and answers as Classification, on the same meter, at /v1/systemone instead of /alpha/decisions.

Copy its model IDModel IDThe name a request calls a model by, lab/model, copied from Models.More on Models → from its page in Models. The ID is lab/model, such as typesafe/jev-1.14; the bare name, jev-1.14, reaches the same model.

2. Send your questions

Yacine runs Souk Bot, which answers the customers of a clothing shop in Oran. Before a message reaches a person, Souk Bot asks System One two questions about it: is it a defect, and which team owns it. Each question goes under a name Yacine picks: is_bug and team.

Send the case in state and the questions in questions to POST /v1/systemone.

Watch out

A chat library cannot call this route. Send it with any HTTP client, as the samples do.

import json
import os
import urllib.request

API_KEY = os.environ["OPENDUNES_API_KEY"]
ADDRESS = "https://opendunes.com/v1/systemone"
MODEL = "typesafe/jev-1.14"
TICKET = "Edahabia payment went through. Order still pending since yesterday."

request_body = {
    "model": MODEL,
    "state": {"ticket": TICKET},
    "questions": {
        "is_bug": {
            "type": "noul",
            "instructions": "Is the customer reporting a defect?",
            "criteria": {
                "true": "The customer describes broken behaviour.",
                "false": "The customer is asking a question.",
            },
        },
        "team": {
            "type": "choice",
            "instructions": "Which team owns this ticket?",
            "criteria": {
                "payments": "Checkout, billing or payment processing.",
                "delivery": "Pickup, transit or hand-over.",
            },
        },
    },
}

request = urllib.request.Request(
    ADDRESS,
    data=json.dumps(request_body).encode(),
    headers={
        "Authorization": "Bearer " + API_KEY,
        "Content-Type": "application/json",
    },
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)

print(answer["answers"]["team"]["choice"], answer["usage"]["cost"])
You sendHolds
modela System One model: lab/model, or its bare name
statethe case to judge: a string, an object or a list
questionsone or more questions, each under a name you choose
provideroptional: which providers may serve it, and the most the router may pay, in DADAThe Algerian dinar, the one currency the docs show.More on Balance and charges →
In each questionHolds
typenoul for yes or no, choice for one of your options, score for a place on your scale
instructionsthe question, in words
criteriawhat each answer means, in the shape its type needs

Every field: Typed answers.

3. Read each answer

200, with one answer per question, under the name it carried: the samples print the team picked for the message.

FieldHolds
answersone answer per question, keyed by your names
noulon a noul answer: the probability of yes, from 0 to 1
choiceon a choice answer: the option with the most weight
scoreon a score answer: your scale's weighted place
probabilitieson a choice or a score answer: one entry per option or level; they add up to 1
confidenceon a choice or a score answer: how sure the model is of its pick or its place, its own reading and not the odds
usageinput_tokens: the tokens sent. cost: the charge, in DA

A choice answer never carries a score, and a score answer never carries a choice.

What it cost

Charged in DA from your balanceBalanceWhat you can spend, in DA.More on Balance and charges → the moment the answer ends: the tokens you sent, the case and every question counted together, at the model's input rate. The answer's tokens are reported and never charged. usage.cost carries the charge; the model's page in Models gives the rate.

A provider that fails before it answers, or a question refused, charges nothing.

Errors

The body says why.

StatusWhen
400model, state or questions is missing, or a question has no type, or no criteria where its type needs them
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 System One or classification model on sale
429the API keyAPI keyThe key you create and send with every request that calls a model.More on API keys →'s own rate limit is reached (metadata.limit_source is key), or the provider is limiting its rate; Retry-After says how many seconds to wait
502the model is down, or answered with nothing usable

What to do on each: Errors and retries.