Prerequisites
Before you begin, ensure you have:- Cerebras API Key - Get a free API key here
- Python 3.12 or higher - Required by current OGX releases
- uv package manager - Used to install and run the OGX starter distribution
Configure OGX with Cerebras
1
Install OGX
Install the OGX starter distribution and the OpenAI SDK in a persistent project environment:For a quick evaluation without creating a project,
uvx can install and run the server in one command:2
Configure environment variables
Export your Cerebras API key as an environment variable:You can also add this to your shell profile (e.g.,
~/.bashrc or ~/.zshrc) for persistence.3
Start the OGX server
Launch the starter distribution. It enables the Cerebras provider automatically when The server starts on
CEREBRAS_API_KEY is set:http://localhost:8321 by default. Confirm that Cerebras models were discovered before sending requests:4
Make your first inference request
Use any OpenAI-compatible client to make inference requests through OGX.
5
Try streaming responses
OGX supports streaming responses for real-time output. Streaming is particularly useful for interactive applications where you want to display responses as they’re generated.
Using Cerebras Directly with OpenAI SDK
If you prefer to use Cerebras directly without the OGX server, you can use the OpenAI SDK with Cerebras endpoints. This approach gives you direct access to Cerebras while still tracking usage through the integration header.Advanced Features
Using Multiple Models
OGX discovers the models available to your Cerebras account at startup. Use the provider-prefixed IDs returned byGET /v1/models, for example:
Then switch between models in your code:
System Prompts and Temperature Control
Customize model behavior with system prompts and sampling parameters to fine-tune responses:Multi-Turn Conversations
The OpenAI-compatible chat endpoint supports multi-turn conversations:FAQ
What's the difference between using OGX and calling Cerebras directly?
What's the difference between using OGX and calling Cerebras directly?
OGX provides a provider-agnostic, OpenAI-compatible server plus APIs for responses, files, vector stores, batches, and skills. If you only need basic inference, calling Cerebras directly with the OpenAI SDK is simpler.
Can I use OGX without running a local server?
Can I use OGX without running a local server?
Yes. Point any OpenAI-compatible client at a remote OGX server that has the Cerebras provider enabled. Alternatively, use the OpenAI SDK directly as shown in the “Using Cerebras Directly” section.
Which Cerebras models work best with OGX?
Which Cerebras models work best with OGX?
Use
gpt-oss-120b for production text, coding, and tool-use workloads. Use the preview gemma-4-31b model when you need image input. Check the model catalog for current availability before configuring additional preview models.What Python versions are supported?
What Python versions are supported?
Current OGX packages require Python 3.12 or higher.
How do I handle rate limits and errors?
How do I handle rate limits and errors?
Handle
429 and transient 5xx responses with bounded retries and exponential backoff in your application. Monitor account usage through the Cerebras Cloud dashboard.Troubleshooting
Server won’t start
If the OGX server fails to start:- Verify your Python version is 3.12 or higher:
python --version - Check that your
CEREBRAS_API_KEYenvironment variable is set:echo $CEREBRAS_API_KEY - Confirm the package can start:
uvx --from "ogx[starter]" ogx stack run starter - Check the OGX releases page for breaking changes
Connection errors
If you see connection errors when making requests:- Verify the OGX server is running on the expected port (default: 8321)
- Check that your Cerebras API key is valid by testing it directly with the OpenAI SDK
- Ensure there are no firewall rules blocking localhost connections
- Try restarting the OGX server
- Verify your network connectivity to
api.cerebras.ai
Model not found errors
If you get “model not found” errors:- Use the
cerebras/prefix for model names (e.g.,cerebras/gpt-oss-120b) - List available models:
curl http://localhost:8321/v1/models - Restart the OGX server after changing provider environment variables
- Consult the Cerebras models page for the current list of available models
Slow response times
If responses are slower than expected:- Verify you’re using Cerebras models (not accidentally routing through another provider)
- Check your network connection and latency to Cerebras endpoints
- Reduce unnecessary prompt and output tokens
- Enable streaming to get partial responses faster
- Check your Cerebras account for any rate limiting or usage quotas
Import errors with the OpenAI SDK
If you get import errors:- Ensure the OpenAI SDK is installed:
uv add openai - Check that you’re using the correct import:
from openai import OpenAI - Verify that your base URL includes
/v1 - Create a fresh virtual environment if issues persist
Next Steps
- Explore the OGX documentation for APIs, providers, and deployment options
- Review the OGX Cerebras provider reference
- Try different Cerebras models to find the best fit for your use case
- Review the OGX GitHub repository for releases and examples
OGX was formerly named Llama Stack. The current package is
ogx, the current command is ogx, and the server runs on port 8321 by default.
