Member Junction
    Preparing search index...

    A BaseDecision driver for OpenAI's Decisions API (POST https://api.openai.com/v1/decisions), which answers typed questions with GPT-6 Luna. It is in public beta, and gpt-6-luna is the only model it serves.

    OpenAI's wire differs from the System One format the other decision drivers share: the questions are an array whose items carry their own name, a Likelihood is a predicate, a Choice's options are choices: [{ value, description }], a Score's levels are levels: [{ label, description }], and the answers come back as an array keyed by name with distributions as arrays. This class builds that request and turns the answers back into the System One shape, so the answer mapping, renormalisation and telemetry in BaseSystemOneDecision apply unchanged.

    A refusal answer is passed through with its type, so the base class fails the result with a type mismatch that names it, and the failure allows failover to another decision model.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    DEFAULT_ENDPOINT: "https://api.openai.com/v1/decisions" = 'https://api.openai.com/v1/decisions'

    The OpenAI Decisions API endpoint.

    DEFAULT_MODEL: "gpt-6-luna" = 'gpt-6-luna'

    The model used when DecisionParams.Model is empty: the only model the API serves.

    Accessors

    • get apiKey(): string

      Only sub-classes can access the API key

      Returns string

    • get SecretsToRedact(): string[]

      The secrets an error message must never show, each removed with RedactSecret. Defaults to the credential's API key; a driver that sends only part of it (Cloudflare's token) adds that part.

      Returns string[]

    Methods

    • Executes a typed decision request across one or more questions about a given state. This method wraps driver execution with input validation, output verification, execution timing, and structured error handling. It never throws.

      Parameters

      • params: DecisionParams

        Decision request parameters including state, questions, and model.

      Returns Promise<DecisionResult>

      A Promise resolving to a DecisionResult.

    • The message of the error thrown for a non-2xx response. Defaults to the status and the first 500 characters of the body.

      Parameters

      • status: number

        The HTTP status.

      • bodyText: string

        The response body as text, possibly empty, with the API key already redacted (RedactSecret).

      Returns string

    • The error type for a non-2xx status whose ErrorAnalyzer reading is wrong for this API, or undefined (the default) to leave it to ErrorAnalyzer, which reads the message and the status. A type returned here is attached to the thrown error as a Retriable error that allows failover: another candidate may answer what this API refused.

      Parameters

      • _status: number

        The HTTP status.

      Returns AIErrorType

    • The request headers. Defaults to the credential's API key as a bearer token and a JSON content type.

      Parameters

      • _model: string

        The model being asked.

      Returns Record<string, string>

    • The request body's model field. Defaults to the model unchanged.

      Parameters

      • model: string

        The model being asked.

      Returns string

    • Sends the request. This is the driver's only network call; a test double overrides it to stand in for the network.

      Parameters

      • url: string

        The endpoint from GetEndpointURL.

      • init: RequestInit

        The POST: method, headers, JSON body and the caller's cancellation signal.

      Returns Promise<Response>

    • Validates input DecisionParams against the decision contract.

      Parameters

      Returns string[]

      An array of error descriptions, empty if valid.