Skip to content

Conversation

@sebastiand-cerebras
Copy link
Contributor

  • 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.

@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

@sebastiand-cerebras
Copy link
Contributor 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.
@sebastiand-cerebras sebastiand-cerebras force-pushed the add-cerebras-support branch 2 times, most recently from d0d58e4 to 92d59c7 Compare November 26, 2025 00:12
@DouweM DouweM changed the title Add Cerebras provider support Add CerebrasModel Nov 26, 2025
Copy link
Collaborator

@DouweM DouweM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sebastiand-cerebras, just one tiny thing and I'll merge!

- Update docs/models/cerebras.md: use pip/uv-add format, link to Cerebras docs - Fix httpx.AsyncClient typo in cerebras.md, groq.md, mistral.md - Add docs/api/models/cerebras.md and update mkdocs.yml - Remove Cerebras section from openai.md, move to main list in overview.md - Add str | to CerebrasModelName for arbitrary model names - Add CerebrasModelSettings with cerebras_disable_reasoning field - Add zai_model_profile, restore unsupported_model_settings and json_schema_transformer - Pass lowercase model name to profile functions - Add tests/providers/test_cerebras.py with full coverage - Remove type ignore in models/__init__.py
Documentation changes: - Revert openrouter example to moonshotai in docs/models/openai.md - Remove OpenRouter section from docs/models/openai.md (now has its own model class) - Restore alphabetical ordering in docs/models/overview.md - Restore ModelAPIError references in docs/models/overview.md - Restore alphabetical ordering and openrouter.md in mkdocs.yml Code changes: - Remove openrouter from OpenAI-compatible providers list in models/__init__.py - Move OpenAIChatModel import into try block in models/cerebras.py - Rename _KnownCerebrasModelName to LatestCerebrasModelNames - Implement cerebras_disable_reasoning setting via extra_body transformation - Move zai_model_profile to profiles/zai.py (returns None, properties handled at provider level) - Add X-Cerebras-3rd-Party-Integration header to all Cerebras API requests Tests: - Add tests/models/test_cerebras.py with unit and integration tests for disable_reasoning
zai_model_profile returns None, so supports_json_object_output and supports_json_schema_output default to False from OpenAIModelProfile base.
@DouweM
Copy link
Collaborator

DouweM commented Dec 10, 2025

@sebastiand-cerebras Please have a look at the linter failure; we'll likely need a pyright: ignore[...] in the test!

@DouweM DouweM enabled auto-merge (squash) December 10, 2025 19:35
@DouweM DouweM merged commit 50b53a7 into pydantic:main Dec 10, 2025
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment