
# 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']}>
  <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>
</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)).

## Model Capabilities

| Model          | Image Input         | Object Generation   | Tool Usage          | Tool Streaming      |
| -------------- | ------------------- | ------------------- | ------------------- | ------------------- |
| `llama3.1-8b`  | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
| `llama3.1-70b` | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
| `llama3.3-70b` | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |

<Note>
  Please see the [Cerebras
  docs](https://inference-docs.cerebras.ai/introduction) for more details about
  the available models. Note that context windows are temporarily limited to
  8192 tokens in the Free Tier.
</Note>


## Navigation

- [xAI Grok](/v4/providers/ai-sdk-providers/xai)
- [Vercel](/v4/providers/ai-sdk-providers/vercel)
- [OpenAI](/v4/providers/ai-sdk-providers/openai)
- [Azure OpenAI](/v4/providers/ai-sdk-providers/azure)
- [Anthropic](/v4/providers/ai-sdk-providers/anthropic)
- [Amazon Bedrock](/v4/providers/ai-sdk-providers/amazon-bedrock)
- [Groq](/v4/providers/ai-sdk-providers/groq)
- [Fal](/v4/providers/ai-sdk-providers/fal)
- [AssemblyAI](/v4/providers/ai-sdk-providers/assemblyai)
- [DeepInfra](/v4/providers/ai-sdk-providers/deepinfra)
- [Deepgram](/v4/providers/ai-sdk-providers/deepgram)
- [Gladia](/v4/providers/ai-sdk-providers/gladia)
- [LMNT](/v4/providers/ai-sdk-providers/lmnt)
- [Google Generative AI](/v4/providers/ai-sdk-providers/google-generative-ai)
- [Hume](/v4/providers/ai-sdk-providers/hume)
- [Google Vertex AI](/v4/providers/ai-sdk-providers/google-vertex)
- [Rev.ai](/v4/providers/ai-sdk-providers/revai)
- [Mistral AI](/v4/providers/ai-sdk-providers/mistral)
- [Together.ai](/v4/providers/ai-sdk-providers/togetherai)
- [Cohere](/v4/providers/ai-sdk-providers/cohere)
- [Fireworks](/v4/providers/ai-sdk-providers/fireworks)
- [DeepSeek](/v4/providers/ai-sdk-providers/deepseek)
- [Cerebras](/v4/providers/ai-sdk-providers/cerebras)
- [Replicate](/v4/providers/ai-sdk-providers/replicate)
- [Perplexity](/v4/providers/ai-sdk-providers/perplexity)
- [Luma](/v4/providers/ai-sdk-providers/luma)
- [ElevenLabs](/v4/providers/ai-sdk-providers/elevenlabs)


[Full Sitemap](/sitemap.md)
