OpenAI Decisions API
TypeLLM answers OpenAI's Decisions API at POST /v1/decisions. Code written for it runs on TypeLLM with two changes: your TypeLLM API key and the base URL https://api.typellm.ai/v1.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["TYPELLM_API_KEY"],
base_url="https://api.typellm.ai/v1",
)
decision = client.decisions.create(
model="gpt-6-luna",
input="I was charged twice for my order.",
questions=[{
"type": "choice",
"name": "department",
"instructions": "Which department should handle this complaint?",
"choices": [
{"value": "billing", "description": "Payments, invoices, and refunds."},
{"value": "technical", "description": "Problems using the product."},
{"value": "shipping", "description": "Delivery and tracking."},
{"value": "other", "description": "Requests outside these categories."},
],
}],
)
print(decision.answers[0].choice){
"id": "dec_...",
"model": "gpt-6-luna",
"answers": [{
"type": "choice",
"name": "department",
"choice": "billing",
"probabilities": [
{"value": "billing", "probability": 0.95},
{"value": "technical", "probability": 0.02},
{"value": "shipping", "probability": 0.01},
{"value": "other", "probability": 0.02}
],
"confidence": 0.93
}],
"usage": {"input_tokens": 120, ...}
}Questions
predicatereturns theprobabilitythat the condition is true.choicereturns the chosen value, the probability of each choice in the order given, and aconfidence. Values are strings or booleans.scorereturns the probability-weighted average of the level indices, the probability of each level, and aconfidence.- Questions in one request are answered together, from the same input. See Confidence for how
confidenceis worked out.
Input
inputis a string, or user messages ofinput_textandinput_imageparts. Images are base64 data URLs.gpt-6-luna, or no model, runstypellm-latest.safety_identifierand an image'sdetailare accepted and not used. Answers are never refusals.
Billing
A request is billed as a /v1/generate call: its input tokens, counted once, at TypeLLM's prices. usage.output_tokens is 0.
To ask for other types, such as numbers, text, objects and arrays, or to use thinking and dependencies, use /v1/generate.