0

Cerebras Provider

Cerebras Provider explains the cloud layer of MTPX with practical guidance for building inspectable, tool-using agents.

Ce
Cerebras Provider
Chapter 028ProvidersCloudIndex
01Orientation

Cerebras Provider belongs to the providers track. The page breaks the idea into responsibilities, implementation rules, failure modes, and the signals you should expose in a product UI.

Use this when

Use this when you need to understand how cerebras provider affects a real MTPX agent before you wire it into an application.

  • What cerebras provider owns in the runtime.
  • How it connects to planning, tool execution, events, providers, or storage.
  • What to log, test, and expose to users when this layer is active.
  • Common mistakes that make agent systems hard to inspect.
02 / syntax starter
from mtp import Agent
from mtp.providers import Groq

agent = Agent.MTPAgent(
    provider=Groq(model="llama-3.3-70b-versatile"),
    tools=tools,
)
03 / manual

Read the system

The complete source manual—syntax, examples, linked references, edge cases, and implementation notes.

Documentation index ↗

Cerebras runs Llama models on wafer-scale chips, delivering the fastest inference available (~2000 tokens/sec).

Install

bashpip install "mtpx[cerebras]"

This installs the openai SDK (used for the OpenAI-compatible API). Alternatively, install the native Cerebras SDK:

bashpip install cerebras-cloud-sdk

API Key Setup

  1. Install dotenv support:
bash   pip install python-dotenv

Or with the MTP extra:

bash   pip install "mtpx[dotenv]"
  1. Create a .env file in your project root:
text   CEREBRAS_API_KEY=csk-your_key_here
  1. Load it in your code before creating the provider:
python   from mtp import Agent

   Agent.load_dotenv_if_available()  # reads .env file

Get a free API key at cloud.cerebras.ai (no credit card required).

Option 2: System environment variable

bash# Linux/macOS
export CEREBRAS_API_KEY="csk-..."

# Windows PowerShell
$env:CEREBRAS_API_KEY="csk-..."

Quick Start

pythonfrom mtp import Agent
from mtp.providers import Cerebras

Agent.load_dotenv_if_available()  # loads CEREBRAS_API_KEY from .env

provider = Cerebras(model="llama-4-scout-17b-16e-instruct")
tools = Agent.ToolRegistry()
agent = Agent(provider=provider, tools=tools)

reply = agent.run_loop("What is 25 * 4 + 10?")
print(reply)

Parameters

ParameterTypeDefaultDescription
modelstr"llama-4-scout-17b-16e-instruct"Cerebras model ID
api_keystr | NoneNoneAPI key (falls back to CEREBRAS_API_KEY env var)
temperaturefloat0.0Sampling temperature
tool_choicestr | dict"auto"Tool selection strategy
parallel_tool_callsboolTrueAllow parallel tool calls
clientAny | NoneNonePre-configured Cerebras client instance

Capabilities

CapabilityValue
Tool callingYes
Parallel tool callsYes (configurable)
Input modalitiestext
StreamingFallback
Usage metricsRich
Reasoning metadataNo
Native asyncNo (uses thread fallback)
  • llama-4-scout-17b-16e-instruct — Best tool calling (default)
  • llama-3.3-70b — Strong general purpose
  • llama3.1-8b — Fastest

Full Example

pythonfrom mtp import Agent
from mtp.providers import Cerebras

Agent.load_dotenv_if_available()

provider = Cerebras(
    model="llama-4-scout-17b-16e-instruct",
    temperature=0.0,
    parallel_tool_calls=True,
)

tools = Agent.ToolRegistry()
agent = Agent(provider=provider, tools=tools, debug_mode=True)

reply = agent.run_loop(
    "Calculate (25 * 4) + 10",
    max_rounds=3,
)
print(reply)

Notes

  • Cerebras uses the native cerebras-cloud-sdk when available, falls back to the OpenAI client pointed at Cerebras endpoint.
  • Text-only input (no image/audio/video support).
  • The parallel_tool_calls parameter is gracefully handled if the SDK version doesn't support it.

Source

src/mtp/providers/cerebras_provider.py

01

Read

Understand where Cerebras Provider sits in the agent loop before adding abstractions.

02

Wire

Connect the smallest useful provider, registry, store, or event stream first.

03

Observe

Expose events, logs, results, and failure states while the runtime is still moving.

04

Harden

Add policy, tests, retries, and audit traces after the behavior is visible.

Next docCohere Provider