> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zeroruntime.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Cerebras

> Python API reference for the cerebras llm plugin.

<Card title="Usage guide" icon="book" href="/plugins/llm/cerebras" horizontal>
  Setup, environment variables, and Python/JavaScript/Go usage examples.
</Card>

## CerebrasLLM

Ultra-fast LLM inference on Cerebras wafer-scale hardware.

OpenAI-compatible chat completions with streaming and tool calling.

### Constructor

```python theme={null}
CerebrasLLM(*, api_key: 'str | None' = None, model: 'CerebrasLLMModel | str' = 'llama3.3-70b', temperature: 'float' = 0.7, tool_choice: 'str' = 'auto', max_completion_tokens: 'int | None' = None, top_p: 'float | None' = None, seed: 'int | None' = None, stop: 'str | None' = None, user: 'str | None' = None) -> 'None'
```

<ParamField path="api_key" type="str | None">
  Cerebras API key. Falls back to `CEREBRAS_API_KEY`.
</ParamField>

<ParamField path="model" type="CerebrasLLMModel | str" default="llama3.3-70b">
  Model id: `gpt-oss-120b`, `zai-glm-4.7`, or `llama3.3-70b` (default).
</ParamField>

<ParamField path="temperature" type="float" default="0.7">
  Sampling temperature, 0.0–1.5. Default 0.7.
</ParamField>

<ParamField path="tool_choice" type="str" default="auto">
  Tool selection mode (`"auto"`/`"none"`/`"required"`).
</ParamField>

<ParamField path="max_completion_tokens" type="int | None">
  Max tokens to generate. Default 1024.
</ParamField>

<ParamField path="top_p" type="float | None">
  Nucleus sampling probability mass. Default None.
</ParamField>

<ParamField path="seed" type="int | None">
  Seed for reproducible sampling. Default None.
</ParamField>

<ParamField path="stop" type="str | None">
  Stop sequence that halts generation. Default None.
</ParamField>

<ParamField path="user" type="str | None">
  Stable end-user identifier for abuse monitoring. Default None.
</ParamField>

### aclose

```python theme={null}
def aclose(self) -> 'None'
```

Release any resources held by the provider.

### cancel\_current\_generation

```python theme={null}
def cancel_current_generation(self) -> 'None'
```

Cancel the in-progress generation for the active session, if any.

### chat

```python theme={null}
def chat(self, messages: 'Any', tools: 'Any' = None, conversational_graph: 'Any' = None, **kwargs: 'Any') -> 'AsyncIterator[LLMResponse]'
```

Generate a streamed chat completion.

<ParamField path="messages" type="Any" required>
  The conversation history to send to the model.
</ParamField>

<ParamField path="tools" type="Any">
  Optional tool definitions the model may call.
</ParamField>

<ParamField path="conversational_graph" type="Any">
  Optional conversational graph guiding the exchange.
</ParamField>

<ResponseField name="returns" type="AsyncIterator[LLMResponse]">
  LLMResponse: Response chunks produced as the model generates output.
</ResponseField>

### emit

```python theme={null}
def emit(self, event: 'T', *args: 'Any') -> 'None'
```

Emit an event, invoking all registered handlers with the given arguments.

Handlers are called in registration order. Coroutine handlers are
scheduled on the running event loop. If the emitter is closed, the call
is a no-op.

<ParamField path="event" type="T" required>
  The event to emit.
</ParamField>

### off

```python theme={null}
def off(self, event: 'T', callback: 'Callable[..., Any]') -> 'None'
```

Remove a previously registered handler for an event.

If the handler is not registered for the event, the call is a no-op.

<ParamField path="event" type="T" required>
  The event the handler was registered for.
</ParamField>

<ParamField path="callback" type="Callable[..., Any]" required>
  The handler to remove.
</ParamField>

### on

```python theme={null}
def on(self, event: 'T', callback: 'Callable[..., Any] | None' = None) -> 'Callable[..., Any]'
```

Register a handler for an event.

Can be used directly by passing a callback, or as a decorator when
`callback` is omitted.

<ParamField path="event" type="T" required>
  The event to listen for.
</ParamField>

<ParamField path="callback" type="Callable[..., Any] | None">
  The handler to invoke when the event is emitted. If `None`, a decorator is returned that registers the decorated function.
</ParamField>

<ResponseField name="returns" type="Callable[..., Any]">
  The registered callback when `callback` is provided, otherwise a decorator that registers and returns the function it wraps.
</ResponseField>

***

## CerebrasLLMModel

```python theme={null}
CerebrasLLMModel = typing.Literal['gpt-oss-120b', 'zai-glm-4.7']
```
