You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To use `CerebrasModel`, you need to either install `pydantic-ai`, or install `pydantic-ai-slim` with the `cerebras` optional group (which installs `openai`):
6
+
7
+
```bash
8
+
pip install "pydantic-ai-slim[cerebras]"
9
+
```
10
+
11
+
or
12
+
13
+
```bash
14
+
uv add "pydantic-ai-slim[cerebras]"
15
+
```
16
+
17
+
## Configuration
18
+
19
+
To use [Cerebras](https://cerebras.ai/) through their API, go to [cloud.cerebras.ai](https://cloud.cerebras.ai/?utm_source=3pi_pydantic-ai&utm_campaign=partner_doc) and follow your nose until you find the place to generate an API key.
20
+
21
+
`CerebrasModelName` contains a list of available Cerebras models.
22
+
23
+
## Environment variable
24
+
25
+
Once you have the API key, you can set it as an environment variable:
26
+
27
+
```bash
28
+
export CEREBRAS_API_KEY='your-api-key'
29
+
```
30
+
31
+
You can then use `CerebrasModel` by name:
32
+
33
+
```python
34
+
from pydantic_ai import Agent
35
+
36
+
agent = Agent('cerebras:llama-3.3-70b')
37
+
...
38
+
```
39
+
40
+
Or initialise the model directly with just the model name:
41
+
42
+
```python
43
+
from pydantic_ai import Agent
44
+
from pydantic_ai.models.cerebras import CerebrasModel
45
+
46
+
model = CerebrasModel('llama-3.3-70b')
47
+
agent = Agent(model)
48
+
...
49
+
```
50
+
51
+
## `provider` argument
52
+
53
+
You can provide a custom `Provider` via the `provider` argument:
54
+
55
+
```python
56
+
from pydantic_ai import Agent
57
+
from pydantic_ai.models.cerebras import CerebrasModel
58
+
from pydantic_ai.providers.cerebras import CerebrasProvider
0 commit comments