Skip to content

Conversation

@sebastiand-cerebras
Copy link

  • Add CerebrasProvider using OpenAI SDK for Cerebras's OpenAI-compatible API
  • Support for Llama 3.3, Qwen 3, GPT-OSS, and GLM
  • Add cerebras optional dependency group
  • Add documentation with usage examples

Thank you for reviewing this.

- Add CerebrasProvider using OpenAI SDK for Cerebras's OpenAI-compatible API
- Support for Llama 3.3, Qwen 3, GPT-OSS, and GLM models
- Add cerebras optional dependency group
- Add documentation with usage examples and UTM tracking
- Simplify documentation with single sync example
- Fix test to expect None for unknown models
- Add missing newline at end of file
- All provider and documentation tests now pass
@DouweM
Copy link
Collaborator

DouweM commented Nov 20, 2025

@sebastiand-cerebras Hey Seb, Cerebras is already documented at https://ai.pydantic.dev/models/openai/#cerebras as it uses the OpenAIChatModel. So far, we've reserved dedicated pages under docs/models for those providers that have dedicated model classes that use their own API/SDK or implement additional functionality not provided by the basic OpenAI Chat Completions API spec and class.

In #3089, we're implementing a new OpenRouterModel as a subclass of OpenAIChatModel that enables OpenRouter-specific features.

Would it be an option to do same thing for Cerebras, implementing support for any Cerebras-specific additions to the chat completions API?

PS. We have a private Slack channel with Cerebras; happy to discuss this more there as well

- Implement CerebrasModel subclassing OpenAIChatModel
- Disable web search (Cerebras-specific feature)
- Use cerebras-cloud-sdk for official API support
- All tests passing (6/6 Cerebras-specific tests)
Implement CerebrasModel and CerebrasProvider using cerebras-cloud-sdk
to provide ultra-fast inference powered by Cerebras Wafer-Scale Engine.

Key features:
- CerebrasModel extends OpenAIChatModel with web search disabled
- Custom _completions_create override to handle SDK compatibility:
  - Filters OMIT and NOT_GIVEN parameters
  - Removes unsupported web_search_options parameter
  - Converts Cerebras SDK response to OpenAI ChatCompletion format
- CerebrasProvider uses AsyncCerebras client from cerebras-cloud-sdk
- Updated KnownModelName with current Cerebras model list
- Changed CerebrasProvider to use AsyncOpenAI instead of AsyncCerebras SDK
- Simplified CerebrasModel by removing custom _completions_create override
- Updated dependency from cerebras-cloud-sdk to openai package
- Follows OpenRouter pattern for consistency
- Reduced codebase by ~200 lines while maintaining all functionality
- All Cerebras tests passing (5/5)

This aligns with Pydantic team's request to use OpenAI-compatible approach
and removes the need for a separate SDK dependency.
- Add test for UserError when no API key provided
- Add test for passing openai_client directly
- Achieves 100% coverage for cerebras.py
@sebastiand-cerebras
Copy link
Author

Thank you so much for your feedback! I did add these:

  • Create a Cerebras model subclass of the OpenAI Chat model.
  • Set up Cerebras-specific code paths, similar to how OpenRouter handles them.
  • Remove SDK-related code.
  • Add a separate optional dependency group for OpenAI by Cerebras.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants