What is AI Suite?
AI Suite is a Python library that provides a unified interface for interacting with multiple large language model (LLM) providers. With AI Suite, you can easily switch between different providers and models using the same codebase, making it simple to compare performance, cost, and accuracy across providers. By integrating Cerebras with AI Suite, you can leverage Cerebras’s ultra-fast inference speeds while maintaining the flexibility to use other providers when needed. Learn more at the AI Suite GitHub repository.Prerequisites
Before you begin, ensure you have:- Cerebras API Key - Get a free API key here.
- Python 3.11 or higher installed on your system.
Configure AI Suite
1
Install AI Suite
Install the AI Suite library using pip. This lightweight package provides the unified interface for accessing multiple LLM providers:
If you want to compare Cerebras with other providers (as shown in the examples below), you’ll also need to install their SDKs:
2
Set up your API key
Configure your Cerebras API key as an environment variable. AI Suite will automatically detect and use this key when making requests to Cerebras:For a more permanent solution, add this to your If you’re using other providers for comparison, set their API keys as well:
.env file:3
Initialize the AI Suite client
Create an AI Suite client instance. This single client can be used to access any supported LLM provider, including Cerebras:The client automatically configures itself based on your environment variables, so no additional setup is needed.
4
Make your first request
To use Cerebras models through AI Suite, prefix the model name with This code sends a chat completion request to Cerebras’s Llama 3.3 70B model and prints the response.
cerebras: followed by the model identifier. Here’s a simple example that generates a response:Compare Multiple Models
One of AI Suite’s key advantages is the ability to easily compare responses from different models. Here’s how to query multiple Cerebras models with the same prompt:- Compare response quality across different Cerebras models
- Benchmark inference speeds across model sizes
- Test different models for specific use cases
- Easily switch between models without changing your code structure
You can also compare Cerebras with other providers like OpenAI or Anthropic by adding their models to the list (e.g.,
"openai:gpt-4o", "anthropic:claude-opus-4-5"). Just make sure to install their SDKs and set the appropriate API keys as shown in the setup steps above.Available Cerebras Models
You can use any of Cerebras’s production models through AI Suite by prefixing them withcerebras::
cerebras:llama-3.3-70b- Best for complex reasoning, long-form content, and tasks requiring deep understandingcerebras:qwen-3-32b- Balanced performance for general-purpose applicationscerebras:llama3.1-8b- Fastest option for simple tasks and high-throughput scenarioscerebras:gpt-oss-120b- Largest model for the most demanding taskscerebras:zai-glm-4.6- Advanced 357B parameter model with strong reasoning capabilities
Advanced Usage
Adjusting Parameters
Customize model behavior with parameters like temperature, max_tokens, and top_p to fine-tune responses for your specific use case:Multi-Turn Conversations
Maintain context across multiple exchanges by building up your messages array:Frequently Asked Questions
How does AI Suite handle API keys for multiple providers?
How does AI Suite handle API keys for multiple providers?
AI Suite automatically detects API keys from environment variables based on the provider prefix. For Cerebras, it looks for
CEREBRAS_API_KEY. You can set multiple provider keys (like OPENAI_API_KEY, ANTHROPIC_API_KEY) and AI Suite will use the appropriate key based on the model prefix in your request.Can I use AI Suite with async/await patterns?
Can I use AI Suite with async/await patterns?
Currently, AI Suite focuses on synchronous API calls. For async operations, you may need to wrap calls in your own async functions or use the provider’s native SDK directly. Check the AI Suite GitHub repository for updates on async support.
How do I handle errors when switching between providers?
How do I handle errors when switching between providers?
Different providers may have different error formats. Wrap your API calls in try-except blocks and handle provider-specific errors. AI Suite attempts to normalize responses, but error handling may vary by provider.
Does AI Suite support function calling or tool use?
Does AI Suite support function calling or tool use?
AI Suite provides a unified interface for basic chat completions. Advanced features like function calling depend on the underlying provider’s capabilities. Check the specific provider’s documentation for feature availability and implementation details.
How can I optimize costs when using multiple providers?
How can I optimize costs when using multiple providers?
Use AI Suite to benchmark different models for your specific use case. Cerebras offers competitive pricing with ultra-fast inference speeds. Start with smaller models like
cerebras:llama3.1-8b for simple tasks and reserve larger models for complex reasoning. Visit the Cerebras pricing page for detailed cost information.Next Steps
- Explore the AI Suite GitHub repository for more examples and documentation
- Try different Cerebras models to find the best fit for your use case
- Check out other integrations to enhance your AI workflow
- Check out the GLM4.6 migration guide to use the latest model
Troubleshooting
API Key Not Found
API Key Not Found
If you see an error about missing API keys:
- Verify your
CEREBRAS_API_KEYenvironment variable is set correctly - Ensure you’re running your script in the same terminal session where you exported the variable
- Try using a
.envfile with a library likepython-dotenvfor persistent configuration - Restart your Python interpreter or IDE after setting environment variables
Model Not Found
Model Not Found
If you receive a model not found error:
- Verify you’re using the correct model name format:
cerebras:model-name - Check that the model name matches one of the available Cerebras models
- Ensure there are no typos in the model identifier (note the hyphen in
llama-3.3-70b) - Confirm you’re using a current production model, not a deprecated version
Connection Errors
Connection Errors
If you experience connection issues:
- Verify your internet connection is stable
- Check that your API key is valid and has not expired in your dashboard
- Ensure you’re not hitting rate limits (check your usage in the dashboard)
- Try a simple test request to isolate the issue
Slow Response Times
Slow Response Times
If responses seem slower than expected:
- Cerebras typically provides the fastest inference speeds in the industry
- Compare with other providers using the multi-model example above to benchmark
- Check your network latency and consider your geographic location relative to Cerebras’s servers
- Verify you’re not using an unnecessarily large model for simple tasks
- Ensure you’re not rate-limited or experiencing API throttling
Import Errors
Import Errors
If you encounter import errors:
- Verify AI Suite is installed:
pip show aisuite - Ensure you’re using the correct import statement:
import aisuite as ai - Check your Python version is 3.7 or higher:
python --version - Try reinstalling the package:
pip install --upgrade aisuite

