Documentation

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.

Python
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)
Example return
{
  "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

  • predicate returns the probability that the condition is true.
  • choice returns the chosen value, the probability of each choice in the order given, and a confidence. Values are strings or booleans.
  • score returns the probability-weighted average of the level indices, the probability of each level, and a confidence.
  • Questions in one request are answered together, from the same input. See Confidence for how confidence is worked out.

Input

  • input is a string, or user messages of input_text and input_image parts. Images are base64 data URLs.
  • gpt-6-luna, or no model, runs typellm-latest.
  • safety_identifier and an image's detail are 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.