> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2-himanshu-v3-tools-models-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Cerebras

> Use Cerebras high-speed inference with Agno agents.

[Cerebras Inference](https://inference-docs.cerebras.ai/introduction) provides high-speed, low-latency AI model inference powered by Cerebras Wafer-Scale Engines and CS-3 systems. Agno integrates directly with the Cerebras Python SDK.

<Warning>
  Cerebras deprecated `llama-4-scout-17b-16e-instruct` on 2025-11-03 — see [Cerebras's deprecation notice](https://inference-docs.cerebras.ai/support/deprecation). Agno v3.0 defaults `Cerebras.id` to `gpt-oss-120b`; earlier Agno versions default to the deprecated model, so set `id="gpt-oss-120b"` or another current [Cerebras model](https://inference-docs.cerebras.ai/models/overview) explicitly there.
</Warning>

## Prerequisites

To use Cerebras with Agno, you need to:

1. **Install the required packages:**

   ```shell theme={null}
   uv pip install -U cerebras-cloud-sdk agno
   ```

2. **Set your API key:**
   The Cerebras SDK expects your API key to be available as an environment variable:
   ```shell theme={null}
   export CEREBRAS_API_KEY=your_api_key_here
   ```

## Basic Usage

Use a Cerebras model with Agno:

```python theme={null}
from agno.agent import Agent
from agno.models.cerebras import Cerebras

agent = Agent(
    model=Cerebras(id="gpt-oss-120b"),
    markdown=True,
)

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

## Supported Models

Cerebras currently serves the following models (see the [model list](https://inference-docs.cerebras.ai/models/overview) for the latest):

| Model Name     | Model ID     | Parameters  | Availability |
| -------------- | ------------ | ----------- | ------------ |
| OpenAI GPT OSS | gpt-oss-120b | 120 billion | Production   |
| Gemma 4 31B    | gemma-4-31b  | 31 billion  | Preview      |
| Z.ai GLM 4.7   | zai-glm-4.7  | 355 billion | Preview      |

## Parameters

| Parameter               | Type                                               | Default          | Description                                                                                                                                 |
| ----------------------- | -------------------------------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`                    | `str`                                              | `"gpt-oss-120b"` | The ID of the Cerebras model to use                                                                                                         |
| `name`                  | `str`                                              | `"Cerebras"`     | The name of the model                                                                                                                       |
| `provider`              | `str`                                              | `"Cerebras"`     | The provider of the model                                                                                                                   |
| `parallel_tool_calls`   | `Optional[bool]`                                   | `None`           | Whether to run tool calls in parallel (automatically set to False for `llama-4-scout-17b-16e-instruct`, a model Cerebras has since retired) |
| `max_completion_tokens` | `Optional[int]`                                    | `None`           | Maximum number of completion tokens to generate                                                                                             |
| `repetition_penalty`    | `Optional[float]`                                  | `None`           | Penalty for repeating tokens (higher values reduce repetition)                                                                              |
| `temperature`           | `Optional[float]`                                  | `None`           | Controls randomness in the model's output (0.0 to 2.0)                                                                                      |
| `top_p`                 | `Optional[float]`                                  | `None`           | Controls diversity via nucleus sampling (0.0 to 1.0)                                                                                        |
| `top_k`                 | `Optional[int]`                                    | `None`           | Controls diversity via top-k sampling                                                                                                       |
| `strict_output`         | `bool`                                             | `True`           | Controls schema adherence for structured outputs                                                                                            |
| `extra_headers`         | `Optional[Any]`                                    | `None`           | Additional headers to include in requests                                                                                                   |
| `extra_query`           | `Optional[Any]`                                    | `None`           | Additional query parameters to include in requests                                                                                          |
| `extra_body`            | `Optional[Any]`                                    | `None`           | Additional body parameters to include in requests                                                                                           |
| `request_params`        | `Optional[Dict[str, Any]]`                         | `None`           | Additional parameters to include in the request                                                                                             |
| `api_key`               | `Optional[str]`                                    | `None`           | The API key for authenticating with Cerebras (defaults to CEREBRAS\_API\_KEY env var)                                                       |
| `base_url`              | `Optional[Union[str, httpx.URL]]`                  | `None`           | The base URL for the Cerebras API                                                                                                           |
| `timeout`               | `Optional[float]`                                  | `None`           | Request timeout in seconds                                                                                                                  |
| `max_retries`           | `Optional[int]`                                    | `None`           | Maximum number of retries for failed requests                                                                                               |
| `default_headers`       | `Optional[Any]`                                    | `None`           | Default headers to include in all requests                                                                                                  |
| `default_query`         | `Optional[Any]`                                    | `None`           | Default query parameters to include in all requests                                                                                         |
| `http_client`           | `Optional[Union[httpx.Client, httpx.AsyncClient]]` | `None`           | HTTP client instance for making requests                                                                                                    |
| `client_params`         | `Optional[Dict[str, Any]]`                         | `None`           | Additional parameters for client configuration                                                                                              |
| `client`                | `Optional[CerebrasClient]`                         | `None`           | A pre-configured instance of the Cerebras client                                                                                            |
| `async_client`          | `Optional[AsyncCerebrasClient]`                    | `None`           | A pre-configured instance of the async Cerebras client                                                                                      |

`Cerebras` is a subclass of the [Model](/reference/models/model) class and has access to the same params.

## Structured Outputs

The Cerebras model supports structured outputs using JSON schema:

```python theme={null}
from agno.agent import Agent
from agno.models.cerebras import Cerebras
from pydantic import BaseModel
from typing import List

class MovieScript(BaseModel):
    setting: str
    characters: List[str]
    plot: str

agent = Agent(
    model=Cerebras(id="gpt-oss-120b"),
    output_schema=MovieScript,
)
```

## Resources

* [Cerebras Inference Documentation](https://inference-docs.cerebras.ai/introduction)
* [Cerebras API Reference](https://inference-docs.cerebras.ai/api-reference/chat-completions)

### SDK Examples

* [More examples](/models/providers/gateways/cerebras/usage/basic)
