Skip to content

pydantic_ai.models.cloudflare_decisions

Setup

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

CloudflareDecisionsModel

Bases: AsyncClient]

A Clef decision model on Cloudflare Workers AI.

See Cloudflare configuration for authentication, supported models, and images. The adapter forwards timeout, extra_headers, and extra_body. Generic sampling settings, including temperature, are ignored because Clef does not accept them.

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

Attributes

client

The underlying HTTP client.

Type: httpx2.AsyncClient

base_url

The account-scoped Cloudflare API base URL.

Type: str

model_name

The Workers AI model ID.

Type: CloudflareDecisionsModelName

system

The system / model provider: 'cloudflare-decisions', whatever the provider is called.

It makes the model ID cloudflare-decisions:<model name>, which resolves back to this class, and keeps a CloudflareChatModel continuing the conversation from taking a decision response for one of its own.

Type: str

Methods

__init__
def __init__(
    model_name: CloudflareDecisionsModelName,
    *,
    provider: Literal['cloudflare', 'cloudflare-decisions'] | CloudflareProvider = 'cloudflare-decisions',
    profile: ModelProfileSpec | None = None,
    settings: ModelSettings | None = None,
)

Initialize a Cloudflare Decisions model.

Parameters

model_name : CloudflareDecisionsModelName

The full Workers AI model ID, such as @cf/cloudflare/clef-flash.

provider : Literal[‘cloudflare’, ‘cloudflare-decisions’] | CloudflareProvider Default: 'cloudflare-decisions'

The provider to use for authentication, account URL, and HTTP client: 'cloudflare' or 'cloudflare-decisions' (the default), which both create one.

profile : ModelProfileSpec | None Default: None

The model profile to use. Defaults to Clef’s decision model profile for the model name.

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 account’s Workers AI run endpoint.

Returns

DecisionResponse

CloudflareDecisionsModelName

The name of a Clef model served by Cloudflare Workers AI.

Default: Literal['@cf/cloudflare/clef', '@cf/cloudflare/clef-flash'] | str