-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add Cerebras provider support #3486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sebastiand-cerebras
wants to merge
10
commits into
pydantic:main
Choose a base branch
from
sebastiand-cerebras:add-cerebras-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
34969b2
Add Cerebras provider support
sebastiand-cerebras 6e4c5b8
Fix test: unknown models return None, matching Groq behavior
sebastiand-cerebras 774bd05
Fix Cerebras provider and documentation
sebastiand-cerebras 3e552fb
Add missing newline at end of file
sebastiand-cerebras ea6372a
Add Cerebras model support with official SDK
sebastiand-cerebras 376573e
Add Cerebras model support with official SDK
sebastiand-cerebras 12a46ae
refactor: Cerebras to use OpenAI client instead of SDK
sebastiand-cerebras ce53b2b
Merge branch 'main' into add-cerebras-support
sebastiand-cerebras 1229a8b
fix: remove unnecessary type ignore comments in Cerebras tests
sebastiand-cerebras d7b1664
test: add coverage for CerebrasProvider error cases
sebastiand-cerebras File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # Cerebras | ||
|
|
||
| Cerebras provides ultra-fast inference using their Wafer-Scale Engine (WSE), delivering predictable performance for any workload. | ||
|
|
||
| ## Installation | ||
|
|
||
| To use Cerebras, you need to either install `pydantic-ai`, or install `pydantic-ai-slim` with the `cerebras` optional group: | ||
|
|
||
| ```bash | ||
| # pip | ||
| pip install "pydantic-ai-slim[cerebras]" | ||
|
|
||
| # uv | ||
| uv add "pydantic-ai-slim[cerebras]" | ||
| ``` | ||
|
|
||
| ## Configuration | ||
|
|
||
| To use Cerebras, go to [cloud.cerebras.ai](https://cloud.cerebras.ai/?utm_source=3pi_pydantic-ai&utm_campaign=partner_doc) to get an API key. | ||
|
|
||
| ### Environment Variable | ||
|
|
||
| Set your API key as an environment variable: | ||
|
|
||
| ```bash | ||
| export CEREBRAS_API_KEY='your-api-key' | ||
| ``` | ||
|
|
||
| ### Available Models | ||
|
|
||
| Cerebras supports the following models: | ||
|
|
||
| - `llama-3.3-70b` (recommended) - Latest Llama 3.3 model | ||
| - `llama-3.1-8b` - Llama 3.1 8B (faster, smaller) | ||
| - `qwen-3-235b-a22b-instruct-2507` - Qwen 3 235B | ||
| - `qwen-3-32b` - Qwen 3 32B | ||
| - `gpt-oss-120b` - GPT-OSS 120B | ||
| - `zai-glm-4.6` - GLM 4.6 model | ||
|
|
||
|
|
||
| See the [Cerebras documentation](https://inference-docs.cerebras.ai/introduction?utm_source=3pi_pydantic-ai&utm_campaign=partner_doc) for the latest models. | ||
|
|
||
| ## Usage | ||
|
|
||
| ```python | ||
| from pydantic_ai import Agent | ||
|
|
||
| agent = Agent('cerebras:llama-3.3-70b') | ||
| result = agent.run_sync('What is the capital of France?') | ||
| print(result.output) | ||
| #> The capital of France is Paris. | ||
| ``` | ||
|
|
||
| ## Why Cerebras? | ||
|
|
||
| - **Ultra-fast inference** - Powered by the world's largest AI chip (WSE) | ||
| - **Predictable performance** - Consistent latency for any workload | ||
| - **OpenAI-compatible** - Drop-in replacement for OpenAI API | ||
| - **Cost-effective** - Competitive pricing with superior performance | ||
|
|
||
| ## Resources | ||
|
|
||
| - [Cerebras Inference Documentation](https://inference-docs.cerebras.ai?utm_source=3pi_pydantic-ai&utm_campaign=partner_doc) | ||
| - [Get API Key](https://cloud.cerebras.ai/?utm_source=3pi_pydantic-ai&utm_campaign=partner_doc) | ||
| - [Model Pricing](https://cerebras.ai/pricing?utm_source=3pi_pydantic-ai&utm_campaign=partner_doc) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.