
# Cerebras Provider

The [Cerebras](https://cerebras.ai) provider offers access to powerful language models through the Cerebras API, including their high-speed inference capabilities powered by Wafer-Scale Engines and CS-3 systems.

API keys can be obtained from the [Cerebras Platform](https://cloud.cerebras.ai).

## Setup

The Cerebras provider is available via the `@ai-sdk/cerebras` module. You can install it with:

<Tabs items={['pnpm', 'npm', 'yarn', 'bun']}>
  <Tab>
    <Snippet text="pnpm add @ai-sdk/cerebras" dark />
  </Tab>
  <Tab>
    <Snippet text="npm install @ai-sdk/cerebras" dark />
  </Tab>
  <Tab>
    <Snippet text="yarn add @ai-sdk/cerebras" dark />
  </Tab>

  <Tab>
    <Snippet text="bun add @ai-sdk/cerebras" dark />
  </Tab>
</Tabs>

## Provider Instance

You can import the default provider instance `cerebras` from `@ai-sdk/cerebras`:

```ts
import { cerebras } from '@ai-sdk/cerebras';
```

For custom configuration, you can import `createCerebras` and create a provider instance with your settings:

```ts
import { createCerebras } from '@ai-sdk/cerebras';

const cerebras = createCerebras({
  apiKey: process.env.CEREBRAS_API_KEY ?? '',
});
```

You can use the following optional settings to customize the Cerebras provider instance:

- **baseURL** _string_

  Use a different URL prefix for API calls.
  The default prefix is `https://api.cerebras.ai/v1`.

- **apiKey** _string_

  API key that is being sent using the `Authorization` header. It defaults to
  the `CEREBRAS_API_KEY` environment variable.

- **headers** _Record&lt;string,string&gt;_

  Custom headers to include in the requests.

- **fetch** _(input: RequestInfo, init?: RequestInit) => Promise&lt;Response&gt;_

  Custom [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) implementation.

## Language Models

You can create language models using a provider instance:

```ts
import { cerebras } from '@ai-sdk/cerebras';
import { generateText } from 'ai';

const { text } = await generateText({
  model: cerebras('llama3.1-8b'),
  prompt: 'Write a vegetarian lasagna recipe for 4 people.',
});
```

Cerebras language models can be used in the `streamText` function
(see [AI SDK Core](/docs/ai-sdk-core)).

You can create Cerebras language models using a provider instance. The first argument is the model ID, e.g. `llama-3.3-70b`:

```ts
const model = cerebras('llama-3.3-70b');
```

You can also use the `.languageModel()` and `.chat()` methods:

```ts
const model = cerebras.languageModel('llama-3.3-70b');
const model = cerebras.chat('llama-3.3-70b');
```

### Reasoning Models

Cerebras offers several reasoning models including `gpt-oss-120b`, `qwen-3-32b`, and `zai-glm-4.7` that generate intermediate thinking tokens before their final response. The reasoning output is streamed through the standard AI SDK reasoning parts.

For `gpt-oss-120b`, you can control the reasoning depth using the `reasoningEffort` provider option:

```ts
import { cerebras } from '@ai-sdk/cerebras';
import { streamText } from 'ai';

const result = streamText({
  model: cerebras('gpt-oss-120b'),
  providerOptions: {
    cerebras: {
      reasoningEffort: 'medium',
    },
  },
  prompt: 'How many "r"s are in the word "strawberry"?',
});

for await (const part of result.fullStream) {
  if (part.type === 'reasoning') {
    console.log('Reasoning:', part.text);
  } else if (part.type === 'text-delta') {
    process.stdout.write(part.textDelta);
  }
}
```

See [AI SDK UI: Chatbot](/docs/ai-sdk-ui/chatbot#reasoning) for more details on how to integrate reasoning into your chatbot.

### Provider Options

The following optional provider options are available for Cerebras language models:

- **reasoningEffort** _'low' | 'medium' | 'high'_

  Controls the depth of reasoning for GPT-OSS models. Defaults to `'medium'`.

- **user** _string_

  A unique identifier representing your end-user, which can help with monitoring and abuse detection.

- **strictJsonSchema** _boolean_

  Whether to use strict JSON schema validation. When `true`, the model uses constrained decoding to guarantee schema compliance. Defaults to `true`.

## Model Capabilities

| Model                            | Image Input         | Object Generation   | Tool Usage          | Tool Streaming      | Reasoning           |
| -------------------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- |
| `llama3.1-8b`                    | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> |
| `llama-3.3-70b`                  | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> |
| `gpt-oss-120b`                   | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
| `qwen-3-32b`                     | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
| `qwen-3-235b-a22b-instruct-2507` | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> |
| `qwen-3-235b-a22b-thinking-2507` | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> |
| `zai-glm-4.6`                    | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> |
| `zai-glm-4.7`                    | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |

<Note>
  The models `qwen-3-32b` and `llama-3.3-70b` are scheduled for deprecation on
  February 16, 2026. Please see the [Cerebras
  docs](https://inference-docs.cerebras.ai/introduction) for more details about
  the available models and migration guidance. You can also pass any available
  provider model ID as a string if needed.
</Note>


## Navigation

- [AI Gateway](/v7/providers/ai-sdk-providers/ai-gateway)
- [xAI Grok](/v7/providers/ai-sdk-providers/xai)
- [Vercel](/v7/providers/ai-sdk-providers/vercel)
- [OpenAI](/v7/providers/ai-sdk-providers/openai)
- [Azure OpenAI](/v7/providers/ai-sdk-providers/azure)
- [Anthropic](/v7/providers/ai-sdk-providers/anthropic)
- [Open Responses](/v7/providers/ai-sdk-providers/open-responses)
- [Amazon Bedrock](/v7/providers/ai-sdk-providers/amazon-bedrock)
- [Groq](/v7/providers/ai-sdk-providers/groq)
- [Fal](/v7/providers/ai-sdk-providers/fal)
- [AssemblyAI](/v7/providers/ai-sdk-providers/assemblyai)
- [DeepInfra](/v7/providers/ai-sdk-providers/deepinfra)
- [Deepgram](/v7/providers/ai-sdk-providers/deepgram)
- [Black Forest Labs](/v7/providers/ai-sdk-providers/black-forest-labs)
- [Gladia](/v7/providers/ai-sdk-providers/gladia)
- [LMNT](/v7/providers/ai-sdk-providers/lmnt)
- [Google](/v7/providers/ai-sdk-providers/google)
- [Hume](/v7/providers/ai-sdk-providers/hume)
- [Google Vertex AI](/v7/providers/ai-sdk-providers/google-vertex)
- [Rev.ai](/v7/providers/ai-sdk-providers/revai)
- [Baseten](/v7/providers/ai-sdk-providers/baseten)
- [Hugging Face](/v7/providers/ai-sdk-providers/huggingface)
- [Mistral AI](/v7/providers/ai-sdk-providers/mistral)
- [Together.ai](/v7/providers/ai-sdk-providers/togetherai)
- [Cohere](/v7/providers/ai-sdk-providers/cohere)
- [Fireworks](/v7/providers/ai-sdk-providers/fireworks)
- [DeepSeek](/v7/providers/ai-sdk-providers/deepseek)
- [Moonshot AI](/v7/providers/ai-sdk-providers/moonshotai)
- [Alibaba](/v7/providers/ai-sdk-providers/alibaba)
- [Cerebras](/v7/providers/ai-sdk-providers/cerebras)
- [Replicate](/v7/providers/ai-sdk-providers/replicate)
- [Prodia](/v7/providers/ai-sdk-providers/prodia)
- [Perplexity](/v7/providers/ai-sdk-providers/perplexity)
- [Luma](/v7/providers/ai-sdk-providers/luma)
- [ByteDance](/v7/providers/ai-sdk-providers/bytedance)
- [Kling AI](/v7/providers/ai-sdk-providers/klingai)
- [ElevenLabs](/v7/providers/ai-sdk-providers/elevenlabs)


[Full Sitemap](/sitemap.md)
