pydantic_ai.models.openai_decisions
For details on how to set up authentication with this model, see model configuration for OpenAI.
Bases: DecisionModelSettings
Settings used for an OpenAI Decisions API request.
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.
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.
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.
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
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
The model name.
Type: OpenAIDecisionsModelName
The system / model provider: 'openai-decisions', whatever the provider is called.
The Decisions API shares OpenAI’s URL with the Responses API, so this name is what tells its responses apart:
genai-prices prices the endpoint as its own provider, and an
OpenAIResponsesModel continuing the conversation must not
take a decision response, which has no Responses ID to continue from, for one of its own.
Type: str
def __init__(
model_name: OpenAIDecisionsModelName,
*,
provider: Literal['openai', 'openai-decisions'] | OpenAIProvider = 'openai-decisions',
profile: ModelProfileSpec | None = None,
settings: ModelSettings | None = None,
)
Initialize an OpenAI Decisions model.
The name of the OpenAI model to use, such as gpt-6-luna.
provider : Literal[‘openai’, ‘openai-decisions’] | OpenAIProvider Default: 'openai-decisions'
The provider to use for the API’s URL and key: an
OpenAIProvider, as for the other OpenAI models, or
'openai' or 'openai-decisions' (the default), which both create one.
profile : ModelProfileSpec | None Default: None
The model profile to use. Defaults to a decision model’s profile for the model name.
settings : ModelSettings | None Default: None
Model-specific settings used as defaults for this model.
@async
def decide(
request: DecisionRequest,
model_settings: DecisionModelSettings,
) -> DecisionResponse
Send one request to the /v1/decisions endpoint.
DecisionResponse
The ID of the model to ask, such as gpt-6-luna, which the Responses API also serves.
Default: str | Literal['gpt-6-luna']