tenkiOne
Decision API

Documentation_

Alt du trenger for å bruke Ramsey fra egen kode. API-et er kompatibelt med Jev, så klienter skrevet for /v1/systemone virker ved å bytte adresse og nøkkel.

Get started   Request   Response   Images and video   Error   Tips

Get started_

1. Create an account and confirm your email. You get $25 in credits.
2. Create an API key under Account. It is shown only once, so store it as a secret.
3. Send nøkkelen i Authorization: Bearer tk_… på hvert kall.

curl

curl https://one.tenki.no/v1/systemone \
  -H "Authorization: Bearer tk_..." \
  -H "Content-Type: application/json" \
  -d @request.json

Python

import requests

r = requests.post(
    "https://one.tenki.no/v1/systemone",
    headers={"Authorization": "Bearer tk_..."},
    json={
        "model": "ramsey-1",
        "state": "Kunden vil endre leveringsadresse på ordre 123.",
        "questions": {
            "intent": {"type": "choice", "instructions": "Hva vil kunden?",
                        "criteria": {"endre_adresse": "", "kansellere": "", "faktura": ""}},
            "urgent": {"type": "noul", "instructions": "Haster det?"},
        },
    },
    timeout=30,
)
r.raise_for_status()
a = r.json()["answers"]
if a["intent"]["probabilities"][a["intent"]["choice"]] >= 0.9:
    route_to(a["intent"]["choice"])      # sikker nok: avgjør automatisk
else:
    send_to_human()                      # usikker: send videre

JavaScript

const r = await fetch("https://one.tenki.no/v1/systemone", {
  method: "POST",
  headers: { "Authorization": "Bearer tk_...", "Content-Type": "application/json" },
  body: JSON.stringify({
    model: "ramsey-1",
    state: { ticket: 4711, text: "Appen krasjer når jeg logger inn" },
    questions: {
      team: { type: "choice", instructions: "Hvem tar saken?",
               criteria: { support: "", utvikling: "", salg: "" } },
      severity: { type: "score", instructions: "Hvor alvorlig?",
                   criteria: ["Lav", "Middels", "Høy", "Kritisk"] }
    }
  })
});
const { answers } = await r.json();

Request_

POST https://one.tenki.no/v1/systemone med Content-Type: application/json.

FieldTypeDescription
statestring, object or listWhat the model should assess: an email, a conversation, a JSON object. Objects are sent as formatted JSON.
questionsobjectNamed questions, up to 32. The name is the key the answer is returned under.
modelstringValgfritt. ramsey-1.1 (standard), ramsey-1 eller laplace-1.0. Ukjente navn, for eksempel fra Jev, gir standardmodellen.
assetsobjectOptional. Images or one video, see Images and video. Gir laplace-1.0 hvis du ikke oppgir modell.

Questions

Typeinstructionscriteria
noulThe yes/no questionValgfritt: {"true": "når ja", "false": "når nei"}
choiceWhat to choose between{"navn": "beskrivelse"}, 2–26 alternativer. Beskrivelsen kan være tom.
scoreWhat is measured["laveste nivå", …, "høyeste nivå"], 2–10 nivåer i stigende rekkefølge

Gode beskrivelser i criteria gir bedre svar enn korte navn. Skriv dem som du ville forklart det for en ny kollega.

Response_

{
  "model": "ramsey-1",
  "answers": {
    "team": {
      "type": "choice",
      "choice": "faktura",
      "probabilities": {
        "faktura": 0.986,
        "teknisk": 0.011,
        "salg": 0.003
      },
      "confidence": 0.9
    },
    "urgent": {
      "type": "noul",
      "noul": 0.93
    },
    "anger": {
      "type": "score",
      "score": 1.62,
      "median": 2,
      "interval": [
        1,
        2
      ],
      "probabilities": {
        "0": 0.04,
        "1": 0.3,
        "2": 0.66
      }
    }
  },
  "usage": {
    "input_tokens": 354,
    "output_tokens": 0
  }
}
FieldDescription
answers.<navn>.noulThe probability of yes, 0–1.
answers.<navn>.choiceThe option with the highest probability.
answers.<navn>.probabilitiesProbability for each option. Sums to 1.
answers.<navn>.confidenceHow concentrated the distribution is: 0 = evenly spread, 1 = everything on one option. Not the same as the probability of being right.
answers.<navn>.scoreExpected level (0 = lowest).
answers.<navn>.median, intervalMost likely level and an 80% interval. Not in Jev.
usage.input_tokensTokens charged. Output is free.

Images and video_

Laplace leser bilder og korte videoklipp. Legg dem i assets med et navn du velger, og still spørsmålene som vanlig. state kan være en kort tekst om hva bildet er.

assets.<name>Content
{"type": "image", "data_base64": "…"}PNG or JPEG. Several images are read in the order given.
{"type": "video", "data_base64": "…"}MP4. Laplace looks at 8 frames spread evenly over the clip.
{"type": "video", "frames": ["…", "…"]}Frames from a video in order, as base64 PNG or JPEG.

Send either images or one video, not both in the same request. The whole request can be up to 24 MB. Images are scaled down before the model sees them, so there is no gain in sending more than about 1000 pixels on the longest side.

Python

import base64, requests

bilde = base64.b64encode(open("pakke.jpg", "rb").read()).decode()
r = requests.post(
    "https://one.tenki.no/v1/systemone",
    headers={"Authorization": "Bearer tk_..."},
    json={
        "model": "laplace-1.0",
        "state": "Bilde fra mottakskontrollen.",
        "assets": {"pakke": {"type": "image", "data_base64": bilde}},
        "questions": {"skadet": {"type": "noul", "instructions": "Er pakken synlig skadet?"}},
    },
    timeout=60,
)
print(r.json()["answers"]["skadet"]["noul"])

Response

{
  "model": "laplace-1.0",
  "answers": {
    "skadet": {
      "type": "noul",
      "noul": 0.87
    },
    "type": {
      "type": "choice",
      "choice": "eske",
      "probabilities": {
        "eske": 0.962,
        "konvolutt": 0.031,
        "pall": 0.007
      },
      "confidence": 0.86
    }
  },
  "usage": {
    "input_tokens": 268,
    "output_tokens": 0
  }
}

Errors and limits_

Feil har alltid formen {"error": {"code": "…", "message": "…"}}.

StatuscodeMeans
400invalid_jsonThe request body is not valid UTF-8 JSON.
401unauthorizedMissing or invalid API key.
402out_of_creditsThe account is out of credits.
413too_largeThe request is larger than 256 KB, or 24 MB with images or video.
422invalid_requestMangler state eller questions, eller et spørsmål er ugyldig.
422too_many_questionsMore than 32 questions in one request.
429rate_limited / daily_limitFor mange kall. Vent så mange sekunder som Retry-After sier.
529overloadedAll machines are busy. Try again in a few seconds.
503no_backendNo machine is responding right now.

Grenser per nøkkel: 300 kall i minuttet og 200 000 i døgnet. Ved 429 og 529: vent og prøv igjen, gjerne med økende pause (1 s, 2 s, 4 s …).

Tips_

Use the probability, not just the answer. Let Ramsey decide automatically when the probability is high, for example above 0.9, and send the rest to a larger model or a person. Choose the threshold based on how costly an error is for you, and check it against a few hundred real examples.

Ask several things in the same call. Several questions about the same state in one request are faster than many separate calls.

Keep the state to what is needed. Ramsey reads up to about 6,000 tokens, but short states give faster answers.

Ramsey is strong at classification, routing, triage, checking answers against requirements, and decisions with clear rules. It is weaker at arithmetic, dates and long multi-step reasoning. There, uncertain answers should be passed on.

Jev compatibility_

Forespørsels- og svarformatet følger Jevs /v1/systemone. Har du kode for Jev, bytt adressen til https://one.tenki.no og nøkkelen til en Tenki One-nøkkel. Feltene median og interval på score-svar er tillegg som Jev-klienter bare ignorerer.