Skip to content

pydantic_ai.models.openai_decisions

Setup

For details on how to set up authentication with this model, see model configuration for OpenAI.

OpenAIDecisionsModelSettings

Bases: DecisionModelSettings

Settings used for an OpenAI Decisions API request.

OpenAIDecisionsModel

Bases: DecisionModel[AsyncOpenAI]

The model class for OpenAI’s Decisions API, which runs a GPT model as a decision model.

The Decisions API answers typed questions about text or images, each with a probability or a distribution over the options, rather than writing text. An agent whose job is to decide something runs on it like on any other model, with the output_type as the questions:

from typing import Literal

from pydantic import BaseModel, Field

from pydantic_ai import Agent


class Handling(BaseModel):
    verdict: Literal['run', 'reject', 'ask'] = Field(description='How to handle this command.')
    irreversible: bool = Field(description='Would running this destroy data or leak secrets?')


agent = Agent('openai-decisions:gpt-6-luna', output_type=Handling)
...

See Decision models for how an agent’s output type and tools become questions, and OpenAI for setup.

Apart from __init__, all methods are private or match those of the base class.

Attributes

max_images

The API accepts at most 128 image parts across all input messages; a 129th returns HTTP 400.

DecisionInput in https://github.com/openai/openai-openapi/blob/main/openapi.yaml. An oversized request raises ModelAPIError before image URLs are downloaded or the SDK is called.

Type: int | None Default: 128

max_questions

The API accepts at most 200 questions per request; a 201st returns HTTP 400.

DecisionRequest.questions.maxItems in https://github.com/openai/openai-openapi/blob/main/openapi.yaml. The shared planner splits speculative fields into a second request when needed; a request that still exceeds the cap raises ModelAPIError before image URLs are downloaded or the SDK is called.

Type: int | None Default: 200

max_choice_options

The API takes at most this many options in one pick-one; a 256th is a 400.

QuestionParamChoice in https://github.com/openai/openai-openapi/blob/main/openapi.yaml

Type: int | None Default: 255

max_score_levels

The API takes at most this many levels in one rubric; an 11th is a 400.

QuestionParamScore in https://github.com/openai/openai-openapi/blob/main/openapi.yaml

Type: int | None Default: 10

model_name

The model name.

Type: OpenAIDecisionsModelName

system

The system / model provider.

Type: str

Methods

__init__
def __init__(
    model_name: OpenAIDecisionsModelName,
    *,
    provider: Literal['openai-decisions'] | OpenAIDecisionsProvider = 'openai-decisions',
    profile: ModelProfileSpec | None = None,
    settings: ModelSettings | None = None,
)

Initialize an OpenAI Decisions model.

Parameters

model_name : OpenAIDecisionsModelName

The name of the OpenAI model to use, such as gpt-6-luna.

provider : Literal[‘openai-decisions’] | OpenAIDecisionsProvider Default: 'openai-decisions'

The provider to use for the API’s URL and key.

profile : ModelProfileSpec | None Default: None

The model profile to use. Defaults to one selected by the provider.

settings : ModelSettings | None Default: None

Model-specific settings used as defaults for this model.

decide

@async

def decide(
    request: DecisionRequest,
    model_settings: DecisionModelSettings,
) -> DecisionResponse

Send one request to the /v1/decisions endpoint.

Returns

DecisionResponse

OpenAIDecisionsModelName

The ID of the model to ask, such as gpt-6-luna, which the Responses API also serves.

Default: str | Literal['gpt-6-luna']