A brass sorting machine on a wooden desk sliding three blank paper tickets down chutes into wooden trays
All posts

Jev and OpenAI Decisions API example: triage a support ticket

A complete support-ticket triage example for Jev, OpenAI's GPT-6 Luna Decisions and Google's Gemini Decision 1: one request body, the routing code, and the measured tokens, latency and cost for each model.

A support ticket needs three judgments before anyone reads it closely: how urgent it is, which team owns it, and how angry the sender is. The usual way to get them is to ask a chat model for JSON, and the usual failure is the day the model puts an apology in front of the opening brace or invents a fourth department. A Decisions API removes that failure by contract. You send the ticket as evidence together with named questions, and you get typed answers back: a probability for a yes/no question, one of the choice IDs you supplied, a position on a scale you defined. No prose comes back, so there is nothing to parse, and the catalog prices output tokens at zero.

I send one request body to AIVAX's POST /api/v1/generations/decisions, route on the answers with one function, and then send the same body unchanged to TypeSafe's Jev decision model, OpenAI's GPT-6 Luna Decisions and Google's Gemini Decision 1. I prefer this to a JSON prompt for any step whose result is an if in your code. Schema-constrained output, which the structured output post covers, fixes the shape of a reply, but it gives you no probability to threshold and still spends output tokens on the way.

One request carries all three questions

The body has a model, the ticket as state, and a questions object keyed by names you choose. Each question has instructions and criteria, and the shape of criteria depends on the type: a true/false pair for noul, a map of IDs to descriptions for choice, an ordered array of level descriptions for score. Save this as request.json:

{
  "model": "@typesafe/jev-1.14",
  "state": "Help! My payouts have been failing for 3 days.",
  "questions": {
    "is_urgent": {
      "type": "noul",
      "instructions": "Does this message convey urgency?",
      "criteria": {
        "true": "Explicitly time-sensitive or blocking the customer",
        "false": "No urgency expressed"
      }
    },
    "department": {
      "type": "choice",
      "instructions": "Which team should handle this ticket?",
      "criteria": {
        "billing": "Payments, payouts, invoices, or charges",
        "technical": "Bugs, integrations, or API errors",
        "sales": "Plans, upgrades, or pricing questions"
      }
    },
    "frustration": {
      "type": "score",
      "instructions": "How frustrated is the customer?",
      "criteria": [
        "Calm, just stating facts",
        "Frustrated but civil",
        "Very angry, strong language or threatening to leave"
      ]
    }
  }
}

Then send it:

curl -X POST https://inference.aivax.net/api/v1/generations/decisions \
  -H "Authorization: Bearer $AIVAX_API_KEY" \
  -H "Content-Type: application/json" \
  -d @request.json

This is the response from November 12, 2026. Each answer is keyed by the question name from the request and carries the fields that apply to its type.

{
  "id": "d_bftf74op5en8q3fyquco",
  "model": "@typesafe/jev-1.14",
  "provider": "TypeSafe",
  "answers": {
    "is_urgent": { "type": "noul", "noul": 0.95 },
    "department": {
      "type": "choice",
      "choice": "billing",
      "probabilities": { "billing": 1, "technical": 0, "sales": 0 },
      "confidence": 1
    },
    "frustration": {
      "type": "score",
      "score": 0.99,
      "legend": {
        "0": "Calm, just stating facts",
        "1": "Frustrated but civil",
        "2": "Very angry, strong language or threatening to leave"
      },
      "probabilities": { "0": 0.01, "1": 0.99, "2": 0 },
      "confidence": 0.98
    }
  },
  "usage": { "input_tokens": 448, "output_tokens": 73, "cost": 0.00001919232 }
}

noul is the probability that the answer is yes, a JSON number between 0 and 1. Your code picks the threshold and decides what happens near 0.5. choice returns one of your IDs, so the model cannot invent a department. score returns the probability-weighted position on a zero-based scale: 0.99 above is 0.99 × level 1. When the distribution splits, say 0.57 on level 1 and 0.39 on level 2, the score lands near 1.35 and the confidence drops, which is the case where a person should confirm what a branch would otherwise decide silently.

Treat confidence as optional. Jev sends none for noul, Gemini Decision 1 adds one, and Julia-1 sends none on any answer, so the routing code has to work without it.

The routing code is an ordinary function

Because the answers are numbers and identifiers, the policy is a few lines of JavaScript. This script reads request.json, overrides model and state for each call, and returns a queue and a priority, or human-review whenever something is missing, uncertain, or not 2xx:

import request from "./request.json" with { type: "json" };

const MODELS = [
  "@typesafe/jev-1.14",
  "@openai/gpt-6-luna-decisions",
  "@google/gemini-decision-1",
];

const certainty = (answer) =>
  answer.confidence ?? Math.max(...Object.values(answer.probabilities ?? { none: 0 }));

function route({ is_urgent, department, frustration }) {
  const typed =
    is_urgent?.type === "noul" &&
    department?.type === "choice" &&
    frustration?.type === "score";

  if (!typed || certainty(department) < 0.5 || certainty(frustration) < 0.5) {
    return { queue: "human-review" };
  }

  return {
    queue: department.choice,
    priority: is_urgent.noul >= 0.8 || frustration.score >= 1.5 ? "high" : "normal",
  };
}

async function triage(model, ticket) {
  const res = await fetch("https://inference.aivax.net/api/v1/generations/decisions", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.AIVAX_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ ...request, model, state: ticket }),
  });

  if (!res.ok) return { queue: "human-review", status: res.status };

  const { answers, usage } = await res.json();
  return { ...route(answers), input_tokens: usage.input_tokens, cost: usage.cost };
}

for (const model of MODELS) {
  const started = performance.now();
  const result = await triage(model, request.state);
  console.log(model, `${Math.round(performance.now() - started)} ms`, result);
}

The thresholds are placeholders. Set them from labeled tickets of your own and by the cost of being wrong: paging someone on a false yes wants a high bar, and missing a real escalation wants a low one. TypeSafe's guidance on confidence starts a noul at 0.7 for yes and 0.3 for no, gives the band between them its own outcome in code, and routes to a person below a 0.5 confidence floor. The certainty helper falls back to the top probability for models that send no confidence.

The file returned billing with high priority for all three models. Log the state, the criteria and the full distribution for every ticket.

A decision model does not write the customer's reply or explain itself. A generator still sits downstream, and the conversation it produces is worth testing separately with multi-turn agent tests. The shape of the step is the same one AIVAX's Complexity Router uses before it picks a model: a classifier labels the request first and code branches on the label. A decisions request makes those labels yours.

The same body runs on Jev, GPT-6 Luna Decisions and Gemini Decision 1

Changing the model field is the only edit. Answers are keyed by your question names, so the order a model emits them in does not matter, and Gemini did return them in a different order from Jev. Across the repeated runs I timed, the tokens and cost did not move.

The triage request above on three decision models, November 12, 2026: usage from the response, cost on a Max account after plan adjustment, and wall-clock time across runs from one machine
ModelInput tokensOutput tokens reportedusage.costWall-clock range
@typesafe/jev-1.1444873$0.0000192451–1,094 ms
@openai/gpt-6-luna-decisions4390$0.0000448379–962 ms
@google/gemini-decision-12720$0.0000277375–770 ms

For 1,000 tickets of this size that is about $0.019 on Jev, $0.045 on Luna and $0.028 on Gemini. Luna and Gemini list the same $0.10 per million input tokens, yet Gemini billed 272 tokens for this body and Luna 439, because the models count tokens differently. Compare cost per request on your own tickets. Jev reports 73 output tokens, but decision models have a zero output price in the catalog, so they do not reach the bill. Longer tickets cost more, since the instructions and criteria count toward the input as well.

The latency spread between runs is wider than the gap between models, so I would not choose on it. This table says nothing about which model routes your tickets best, and choice, noul and score deserve separate evaluation on a labeled set that includes ambiguous and incomplete messages. I ran 40 labeled tickets through four decision models, and the option order mattered more than the accuracy gap.

Julia-1, the model with a daily allowance on every plan, took the same body in 137 input tokens for a cost of 0. Its urgency came back at 0.35 where the other three said 0.95 to 0.97, so under the 0.8 threshold in route the ticket would have been normal instead of high. That is the reason to treat thresholds as belonging to a model. Pin the canonical name, as in @typesafe/jev-1.14, when your thresholds were tuned against it. The @typesafe/jev:latest alias resolved to the same model in my run, but an alias moves when a new version ships, and the pinning post covers the trade-off. Aliases without the :latest suffix are accepted only until December 1, 2026.

Screenshots, voicemail and PDFs need a model that accepts them

Most decision models read text only. The catalog at GET /api/v1/information/decisions-models.json needs no authentication and lists price, context and the number of images each model accepts. These are the entries I would look at for triage:

A subset of AIVAX decision models: base input price in USD per 1M tokens, input beyond text, and context, from the public catalog on November 12, 2026
ModelInput price / 1MInput beyond textContext
@supersonic-labs/julia-1$0.008None1,024 tokens per question
@perplexity/pplx-decider-v1.2$0.02None256K
@liquid/d1$0.02None64K
@inception/mercury-decide$0.04Images, up to 1664K
@typesafe/jev-1.14$0.042None256K
@openai/gpt-6-luna-decisions$0.10Images, up to 1281.05M
@google/gemini-decision-1$0.10Images, up to 128; audio; video; documents256K
@cloudflare/clef-omni$0.15Images, up to 464K

Prices are base rates before account and plan adjustments, and the usage.cost in each response is the amount deducted. Read maxImages, the number the endpoint enforces, to learn whether a model takes images.

Gemini Decision 1, added to the catalog on November 11, is the only decision model in it today that takes audio, video and documents as well as images. I sent one request with a one-pixel PNG, half a second of silent WAV, a one-second MP4 and a one-page PDF next to the ticket text. It returned 200 with 2,031 input tokens and a cost of $0.000207, while Luna answers audio, video or a document with a 400 such as Model '@openai/gpt-6-luna-decisions' does not accept audio. Those were synthetic files, so they prove the request shape; how well any model reads a real voicemail is untested. The parts go in a top-level state array next to plain-string text items:

"state": [
  "Customer wrote: the payout screen looks wrong.",
  { "type": "image_url", "image_url": { "url": "data:image/png;base64,<BASE64>" } },
  { "type": "input_audio", "input_audio": { "data": "<RAW_BASE64>", "format": "wav" } },
  { "type": "video_url", "video_url": { "url": "data:video/mp4;base64,<BASE64>" } },
  { "type": "file", "file": { "file_data": "data:application/pdf;base64,<BASE64>", "filename": "invoice.pdf" } }
]

Images must be base64 data URLs of type image/png, image/jpeg or image/webp, and a remote image URL is rejected with a 400. Audio is raw base64 without a data: prefix plus a format, and video is a base64 video/* data URL. A document's file_data may be a base64 data URL or a public https:// URL, and I confirmed that a public PDF URL works on Gemini. Media nested inside an object is not read, so keep the parts at the top level. If you already hold the thread as chat messages, send them as input instead of state, in the OpenAI message format; the endpoint folds them into the evidence, and sending both fields returns a 400.

OpenAI's own endpoint takes a different request body

OpenAI's Decisions guide now describes the API as generally available, where it was a public beta when this post first went up. gpt-6-luna is still the only supported model. The endpoint reads text, messages and images, and also JSON through an input_json part, but not files or audio. It accepts up to 400 questions per request, discounts cached input, and charges $0.10 per million uncached input tokens for gpt-6-luna, with regional and long-context premiums on top. The idea matches the one above, and the request shape does not:

Request and response differences between OpenAI's POST /v1/decisions and AIVAX's POST /api/v1/generations/decisions, from OpenAI's guide and AIVAX's implementation on November 12, 2026
AspectOpenAI /v1/decisionsAIVAX /api/v1/generations/decisions
Evidence fieldinput: a string, or messages whose user content mixes text, images and input_jsonstate: any JSON value, or a top-level array of text and media parts; input takes chat messages instead
QuestionsAn array; each question has a nameAn object keyed by question name
Yes/no typepredicatenoul, with true and false criteria
Choice optionschoices: a list of value and description pairscriteria: a map from choice ID to description
Score levelslevels: a list of label and description pairscriteria: an ordered array of descriptions
Image inputBase64 data URLs or public HTTP(S) URLsBase64 data URLs only; audio, video and documents on models that accept them
Modelsgpt-6-luna onlySeveral, listed in the public catalog; one is @openai/gpt-6-luna-decisions
Input price$0.10 per 1M uncached tokens, discounted cache reads, regional and long-context premiums$0.10 base for that model, before account and plan adjustments; the response has no cached-token field

An OpenAI request body does not run against AIVAX unchanged, and the reverse holds too. In exchange, one endpoint reaches Luna and the other vendors' models, so running the same tickets through several of them is a model edit. OpenAI's input_json has a counterpart in state, which takes any JSON value: I sent { "ticket": "Please refund the duplicate charge.", "order": { "charges": [49, 49] } } to Luna and Jev and both routed it to billing.

OpenAI's guide documents a refusal answer type that code must handle before reading a probability. The AIVAX endpoint reads each provider answer into a fixed set of fields (type, score, legend, choice, noul, probabilities, confidence) and returns it under your question name, so an answer of any other type would arrive with its type and none of the typed fields. The typed check in route above is the guard that covers it: an answer that is not the type you asked for goes to human-review. A request the provider rejects does not come back as an answer at all. When I sent Luna a ticket that asked for weapons instructions, all four attempts returned 503 ("An external service is temporarily unavailable") with no Consumed-Credits header, so nothing was billed, and Jev and Gemini answered the same text with 200. In the implementation, a provider failure other than 400 or 413 is raised as an upstream-service error, which is the 503. Park the ticket for a person after a bounded retry, and do not loop.

Rate limits and the free Julia-1 allowance

Requests are capped per account over a one-minute window, across all keys and models: 10 per minute on Free, 30 on Pro, 200 on Max, and no plan-imposed cap on Ultimate. A request with several questions counts once, which is another reason to put the three triage questions in one call. Every question in a request applies to the same state, so a backlog is a paced loop with one request per ticket. Above the cap the API returns 429. The triage function above sends any non-2xx to human-review; if your queue can wait, add a bounded retry with backoff for 429 and 503 before it gives up. Every call also needs an authenticated key and a positive account balance, and a zero-priced model does not waive that.

Julia-1 is eligible for a daily allowance on every plan, 2× the Free amount on Pro, 3× on Max and 5× on Ultimate, so small tests can cost nothing, as the cost of 0 above shows. It counts the shared state again for each question: a ticket with one question used 69 input tokens and the same ticket with all three used 191, so grouping questions cuts the request count while tokens grow with each question. It also reads at most 1,024 tokens per question, including the state and the criteria. The Free plan post lists what the allowances cover, and the Semantic Decisions documentation has the request format, per-model limits and error cases.

Ran against the live AIVAX API on November 12, 2026 with the request, models and media described above; limits, allowance ratios and the Gemini Decision 1 entry were checked against the docs and implementation the same day. Costs are usage.cost on a Max account.