Cerebras OpenAI

Use Cerebras with Agno through an OpenAI-compatible interface.

OpenAI-Compatible Integration

Cerebras also exposes an OpenAI-compatible interface, so you can use it with tools and libraries built for the OpenAI API.

Basic Usage

The CerebrasOpenAI class provides an OpenAI-style interface for Cerebras models. First, install the required packages:

uv pip install -U agno openai cerebras-cloud-sdk
export CEREBRAS_API_KEY="your_cerebras_api_key"
from agno.agent import Agent
from agno.models.cerebras import CerebrasOpenAI

agent = Agent(
    model=CerebrasOpenAI(
        id="gpt-oss-120b",  # Model ID to use
        # base_url="https://api.cerebras.ai/v1", # Optional: default endpoint for Cerebras
    ),
    markdown=True,
)

# Print the response in the terminal
agent.print_response("write a two sentence horror story")

Configuration Options

The CerebrasOpenAI class accepts the following parameters:

ParameterTypeDescriptionDefault
idstrModel identifier (for example, "gpt-oss-120b")"gpt-oss-120b"
namestrDisplay name for the model"CerebrasOpenAI"
providerstrProvider name"CerebrasOpenAI"
api_keystrAPI key (falls back to CEREBRAS_API_KEY environment variable)None
base_urlstrURL of the Cerebras OpenAI-compatible endpoint"https://api.cerebras.ai/v1"
parallel_tool_callsOptional[bool]Whether to run tool calls in parallel (set to False automatically for llama-4-scout-17b-16e-instruct)None

CerebrasOpenAI also supports the parameters of OpenAI.

Examples