orq.aiAdvent of RoutingDocs

Door 11 · still sealed

Hands off the wax, elf. This door opens on Dec 11.

-days--hours--min--sec

Rudolph is still polishing this one. Back to the calendar

Door 11 · Dec 11 Decisions API

Naughty or nice?

Ask yes-or-no, pick-one and scored questions about any text or JSON in one call, and get typed answers with probabilities instead of an essay.

Letter sacks are stacked to the mailroom ceiling. The naughty-or-nice list is due tonight, and the chatbot is answering every letter with a book report.

  1. Santa

    I asked one question: naughty or nice? It sent back four paragraphs on Tim's complicated relationship with broccoli!

  2. Mrs. Claus

    So an elf reads every essay hunting for one word. And the letters the model wasn't sure about: who sees those?

  3. Santa

    Nobody! I check my list twice, not a mountain of book reports. The list is due tonight.

  4. Tinsel

    Stop asking for an essay. /decisions returns one typed answer per question with probabilities, and the unsure letters go to Mrs. Claus.

stateTim's lettertext or JSONorq.ai/decisionsnoul · choice · scoremodelorq/decider-4bfallbackopenai/gpt-6-lunaanswersTyped answers"is_nice": 0.0 to 1.012questionson failtyped
  1. stateTim's lettertext or JSON
  2. orq.ai/decisionsnoul · choice · score
  3. modelorq/decider-4b
    fallbackopenai/gpt-6-luna
  4. answersTyped answers"is_nice": 0.0 to 1.0
Tim's letter goes in with its questions, one decision model answers them all in a single call, and typed answers come back, with a second model on the bench if the first fails.

How it works

Tinsel’s checklist is one request. You send content and named questions, and you get one typed answer per question.

  1. State. Put the content in state. It can be a string, an object or an array. Objects and ordinary arrays are serialised as JSON, so one call can judge a message, a tool payload or a whole record.
  2. Questions. questions maps your own keys to definitions. Each has a type and plain-language instructions. choice and score also need criteria that set the rubric; for noul it is optional.
  3. Answers. The response has answers under the same keys. Nothing is parsed out of free text. choice and score answers also carry probabilities and a confidence.

The call goes to POST https://my.orq.ai/v3/router/decisions. It is traced, priced and rate-limited like other router traffic.

Try it with curl

curl -X POST https://my.orq.ai/v3/router/decisions \
  -H "Authorization: Bearer $ORQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "orq/decider-4b",
    "state": "Dear Santa, I fed the cat every day. I want a sled.",
    "questions": {
      "is_nice": {
        "type": "noul",
        "instructions": "Was this child mostly nice this year?"
      },
      "workshop": {
        "type": "choice",
        "instructions": "Which workshop should build the gift?",
        "criteria": {
          "toys": "Toys and games",
          "outdoor": "Sleds, bikes and outdoor gear",
          "books": null
        }
      },
      "politeness": {
        "type": "score",
        "instructions": "How polite is the letter?",
        "criteria": ["Rude", "Plain", "Very polite"]
      }
    },
    "fallbacks": [{"model": "openai/gpt-6-luna"}],
    "timeout": {"call_timeout": 2000}
  }'

Or from the Python SDK

Install the Orq Python SDK. The same body works, and state can be a dict:

import os
from orq_ai_sdk import Orq

orq = Orq(api_key=os.environ["ORQ_API_KEY"])

result = orq.router.decisions.create(
    model="orq/decider-4b",
    state={"child": "Tim", "deeds": ["fed the cat"]},
    questions={
        "is_nice": {
            "type": "noul",
            "instructions": "Was this child mostly nice?",
        },
    },
)
print(result.answers)
print(result.usage)

Pick a question type

type Answer Use it when
noul Probability that instructions is true, 0 to 1 Yes or no, or a probability to threshold
choice One option from criteria, with probabilities The content belongs to one of a known set
score A position on an ordered scale The answer is a degree, like sentiment

For choice, set an option’s description to null when the name says enough. For score, list at least two levels from lowest to highest.

Only supported decision models answer, such as orq/decider-4b, openai/gpt-6-luna and google-ai/gemini-decision-1. Every model in fallbacks must support decisions too.

Beta limits

Decisions is in Beta and works through the API and SDK only. Your key needs the classify permission; the standard gateway key preset grants it. PII plugins, guardrails and evaluators do not run on these requests yet. Body fields the endpoint does not know, like plugins, are ignored without an error. The model must also be enabled for your workspace, or the request returns 403.

A refusal from OpenAI is a successful answer. Check type before you read noul, choice or score.

For a big pile of letters, run a batch with endpoint /v3/router/decisions. The key then needs both the batches and classify permissions.

Nice list

  • Ask several questions in one request. Each gets its own typed answer, and you pay one round trip instead of one call per question.
  • Send low-confidence answers to a person. The docs suggest escalating those rows and using probabilities to pick the ones worth human review.
  • Gate expensive work with a cheap noul pre-check and send only passing letters to a larger model. Native decision models charge nothing for output tokens.

Naughty list

  • Pointing model at a chat model such as anthropic/claude-sonnet-5-5. Only supported decision models work. An enabled model without decision support returns 400.
  • Reading .noul without checking type first. OpenAI can answer a question with refusal, which has no scored fields and does not trigger a fallback.
  • Counting on your PII redaction plugin. During the Beta, state and instructions reach the provider exactly as sent.
  • Sending a choice question without criteria, or a score with one level. Both fail with 422.

Elf's challenge

Grade Tim's manners: add a score question with "criteria": ["Rude", "Plain", "Very polite"]. Is the score that comes back safe to use as criteria[score]?

Stuck? Ask Tinsel for a hint

No. The docs call score a position on the scale, not an index, so it can be fractional (the docs example shows 1.41). Use legend to map each whole index back to your labels.

Christmas crackerWhy is Sprocket begging Santa for a 0.5 cut-off?Pull it for the punchline

His is_nice came back 0.51.