What is Hugging Face Inference Providers?
Hugging Face Inference Providers is a unified API that gives you access to multiple AI inference providers, including Cerebras, through a single interface. This means you can use familiar Hugging Face tools and SDKs to access Cerebras’s world-class inference speed without changing your existing code structure. Key features include:- Unified API - Use the same code structure across multiple providers
- Simple Integration - Works with OpenAI SDK, Hugging Face Hub client, and standard HTTP requests
- Model Discovery - Browse all available Cerebras models through Hugging Face’s model hub
- Flexible Authentication - Use your Hugging Face token to access Cerebras inference
Prerequisites
Before you begin, ensure you have:- Hugging Face Account - Create a free account at huggingface.co
- Hugging Face API Token - Generate a token at hf.co/settings/tokens
- Python 3.11 or higher - Required for running the Python examples
Getting Started
Install the required dependencies
Set up your API token
.env file in your project directory to store your Hugging Face token securely:Make your first inference request
:cerebras to the model name to specify Cerebras as the provider. With the Hugging Face Hub client, set provider="cerebras" instead.Try streaming responses
Available Cerebras Models
You can use any of the following model IDs through the Cerebras provider:- openai/gpt-oss-120b: Production text, coding, and tool-use workloads
- google/gemma-4-31B-it: Preview multimodal workloads with text and image input
- zai-org/GLM-4.7: Preview reasoning workloads until its scheduled deprecation on August 17, 2026
Advanced Usage
Using Custom Parameters
You can customize your requests with additional parameters supported by the Cerebras API to control response generation:Error Handling
Implement proper error handling to manage API errors gracefully in production applications:Using Environment Variables
For better security and configuration management, load environment variables using python-dotenv:Next Steps
- Explore the Hugging Face Inference Providers documentation for more advanced features
- Browse Cerebras models on Hugging Face
- Learn about Chat Completion parameters in our API reference
- Try different Cerebras models to find the best fit for your use case
- Check out Hugging Face’s guide on building AI apps
- Explore the Hugging Face Inference Providers documentation for current examples
- Review the Cerebras model catalog before choosing a production or preview model
FAQ
What additional latency can I expect when using Cerebras through Hugging Face?
What additional latency can I expect when using Cerebras through Hugging Face?
- Unified API across multiple providers
- Simplified authentication with Hugging Face tokens
- Integration with Hugging Face’s ecosystem and tools
- Easy provider switching without code changes
Can I send images through Hugging Face?
Can I send images through Hugging Face?
google/gemma-4-31B-it and send the image using Hugging Face’s multimodal chat message format. The other listed models accept text input only.How do I specify which Cerebras model to use?
How do I specify which Cerebras model to use?
provider="cerebras", use the model name without the provider suffix::cerebras to specify the provider:Why am I getting authentication errors?
Why am I getting authentication errors?
- Token not set in environment variables
- Token has expired or been revoked
- Token doesn’t have necessary permissions
- Typo in token value
Can I use Hugging Face Inference Providers for production applications?
Can I use Hugging Face Inference Providers for production applications?
- Latency: The routing layer adds minimal overhead, but direct API calls to Cerebras will be slightly faster
- Rate Limits: Check Hugging Face’s rate limits for your account tier
- Monitoring: Implement proper logging and error handling for production use
- Reliability: Both Hugging Face and Cerebras maintain high uptime SLAs
- Costs: Review pricing for both Hugging Face and Cerebras services
What's the difference between using the Hugging Face Hub client and OpenAI SDK?
What's the difference between using the Hugging Face Hub client and OpenAI SDK?
- Native integration with Hugging Face ecosystem
- Set provider explicitly with
provider="cerebras" - Use standard Hugging Face model names
- Better integration with Hugging Face datasets and tools
- Familiar interface if you’re already using OpenAI
- Append
:cerebrasto model names - Easy migration from OpenAI to Cerebras
- Compatible with OpenAI-style tooling

