Skip to main content
The Cerebras API is compatible with OpenAI client libraries for many common workflows. Existing applications can use Cerebras by changing the API key, base URL, and model ID. Cerebras also provides dedicated Python and TypeScript SDKs.

Configure OpenAI to use the Cerebras API

Set the API key and base URL when you initialize the client. Python uses api_key and base_url; JavaScript uses apiKey and baseURL.
Use an exact Cerebras model ID in each request. The examples below use qwen-3.8-27b:

Compatibility differences

Reasoning compatibility

Kimi K2.7 Code is currently available only through customer trials, not on the public shared tier. See Reasoning and Image Inputs for complete model-specific behavior.

Image input with the OpenAI client

The standard OpenAI image_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.
For 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 between system 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 combining tools 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_format and let the model invoke tools. For structured arguments, define a JSON schema in the tool’s parameters field.
  • Structured Outputs only: Omit tools and use response_format with a JSON schema. See Structured Outputs.
  • Two-step pipeline: Make one request with tools to gather data, then make another request with response_format to format the final result.
See Tool Use and Structured Outputs for details on each capability.

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_body for untyped extensions.
Pass Cerebras-specific parameters through extra_body when using an OpenAI client:
Pass Cerebras-specific parameters as top-level arguments when using a Cerebras SDK: