Skip to content

pydantic_ai.models.cerebras

Setup

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

Cerebras model implementation using OpenAI-compatible API.

CerebrasModelSettings

Bases: ModelSettings

Settings used for a Cerebras model request.

ALL FIELDS MUST BE cerebras_ PREFIXED SO YOU CAN MERGE THEM WITH OTHER MODELS.

Attributes

cerebras_disable_reasoning

Disable reasoning for the model.

Deprecated: use the unified thinking=False setting instead.

Type: bool

cerebras_clear_thinking

Whether Cerebras strips prior reasoning from earlier turns on multi-turn zai/GLM requests.

True (Cerebras’s API default) drops thinking from previous turns before the next request; False preserves it, which improves multi-turn coherence and prompt-cache hit rates at the cost of more tokens. Pydantic AI sends False by default for zai/GLM models (which replay prior reasoning as <think> tags) so the replayed reasoning isn’t stripped; set this explicitly to override. GLM-specific setting.

Type: bool

CerebrasModel

Bases: OpenAIChatModel

A model that uses Cerebras’s OpenAI-compatible API.

Cerebras provides ultra-fast inference powered by the Wafer-Scale Engine (WSE).

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

Methods

__init__
def __init__(
    model_name: CerebrasModelName,
    provider: Literal['cerebras'] | Provider[AsyncOpenAI] = 'cerebras',
    profile: ModelProfileSpec | None = None,
    settings: CerebrasModelSettings | None = None,
)

Initialize a Cerebras model.

Parameters

model_name : CerebrasModelName

The name of the Cerebras model to use.

provider : Literal[‘cerebras’] | Provider[AsyncOpenAI] Default: 'cerebras'

The provider to use. Defaults to ‘cerebras’.

profile : ModelProfileSpec | None Default: None

The model profile to use. Defaults to a profile based on the model name.

settings : CerebrasModelSettings | None Default: None

Model-specific settings that will be used as defaults for this model.

CerebrasModelName

Possible Cerebras model names.

Since Cerebras supports a variety of models and the list changes frequently, we explicitly list known models but allow any name in the type hints.

See https://inference-docs.cerebras.ai/models/overview for an up to date list of models.

Default: str | LatestCerebrasModelNames