Configure OpenAI to use the Cerebras API
Set the API key and base URL when you initialize the client. Python usesapi_key and base_url; JavaScript uses apiKey and baseURL.
model field selects the inference target:
- With Shared Inference, use an exact Cerebras model ID.
- With Dedicated Inference, use your stable endpoint ID. The endpoint routes the request to its active deployment.
qwen-3.8-27b through Shared Inference. This model is also available through Dedicated Inference, using your assigned endpoint ID:
Use OpenAI SDK v3 for Python
Use the same Cerebras configuration with OpenAI SDK v3 for Python.openai 3.5.0 passed Cerebras compatibility tests for model listing, Chat Completions, Completions, and streaming.
OpenAI SDK v3 for Python requires Python 3.10 or later and uses HTTPX2 instead of HTTPX. If you use the default HTTP client, you don’t need to change your Cerebras API calls.
Review OpenAI’s HTTPX2 migration guide for:
- Custom HTTP clients
- HTTPX-specific request mocks or instrumentation
- Corporate TLS-inspecting proxies
- Custom certificate bundles
Connect a third-party tool or app
Many agents, chat apps, and developer tools that aren’t listed in Integrations let you add a custom OpenAI-compatible provider. To use Cerebras with one of these tools, open its model provider settings and enter these values:
Enter the base URL exactly as shown. Most tools append
/chat/completions automatically. If your tool asks for the full endpoint URL instead, use https://api.cerebras.ai/v1/chat/completions.
The exact field names depend on the tool. Check the tool’s own documentation for where to set a custom OpenAI-compatible provider.
Compatibility differences
Reasoning compatibility
This guide covers both Shared Inference and Dedicated Inference.kimi-k2.7-code, kimi-k3, and zai-glm-5.3-flash are available through Dedicated Inference. Use the endpoint ID assigned to your organization as the request’s model value.
See Reasoning and Image Inputs for complete model-specific behavior.
Image input with the OpenAI client
The standard OpenAIimage_url content shape is supported. Supply the image as a base64 data URI:
Developer-level instructions via system and developer roles
This section applies only to
gpt-oss-120b.gpt-oss-120b, the API supports both the system and developer message roles. Both are mapped to a developer-level instruction layer in the prompt hierarchy, elevated above normal user instructions and injected into the model’s internal system prompt. This gives you significant control over the assistant’s tone, style, and behavior while preserving the model’s built-in safety guardrails.
The developer role is functionally equivalent to system. The system role remains supported for backward compatibility.
Key differences from OpenAI
OpenAI’s API distinguishes betweensystem and developer roles with different behavior. On Cerebras, both roles act at the developer level, meaning they may have stronger influence than system messages in OpenAI’s API.
As a result, the same prompt may yield different behavior here compared to OpenAI. This is expected.
Unsupported parameter combinations
Support for combiningtools and response_format is model-dependent. Do not combine them unless the selected model’s documentation explicitly supports and validates the combination. gpt-oss-120b rejects requests containing both fields. For portable behavior across Cerebras models, use one of the following approaches:
- Tool calling only: Omit
response_formatand let the model invoke tools. For structured arguments, define a JSON schema in the tool’sparametersfield. - Structured Outputs only: Omit
toolsand useresponse_formatwith a JSON schema. See Structured Outputs. - Two-step pipeline: Make one request with
toolsto gather data, then make another request withresponse_formatto format the final result.
Pass non-standard parameters
reasoning_effort is a standard OpenAI parameter. reasoning_format and clear_thinking are Cerebras-specific parameters.
- OpenAI client libraries: Pass Cerebras-specific parameters through
extra_body. - Cerebras SDKs: Pass Cerebras-specific parameters as top-level arguments. The SDKs also accept
extra_bodyfor untyped extensions.
Use an OpenAI client
Use an OpenAI client
Pass Cerebras-specific parameters through
extra_body when using an OpenAI client:Use a Cerebras SDK
Use a Cerebras SDK
Pass Cerebras-specific parameters as top-level arguments when using a Cerebras SDK:

