# @standardagents/cerebras

Cerebras provider package for Standard Agents using the Cerebras Chat Completions API

> **Info:**
>
> For direct access, set `CEREBRAS_API_KEY` in your environment. Standard Agents Builder can use hosted routing through `STANDARD_AGENTS_API_KEY` when the provider key is absent. Hosted access depends on platform configuration.

## Overview

The `@standardagents/cerebras` package provides a Cerebras provider factory for Standard Agents. It targets Cerebras' OpenAI-compatible Chat Completions API and adds typed `providerOptions`, public model discovery, and request inspection support in the admin UI.

- Key Features

  - Direct integration with `https://api.cerebras.ai/v1/chat/completions`
  - Typed `providerOptions` for Cerebras-specific parameters
  - Public model discovery from Cerebras' public models endpoint
  - Tool calling, structured outputs, streaming, and reasoning support

## Installation

```bash npm
npm install @standardagents/cerebras
```

```bash pnpm
pnpm add @standardagents/cerebras
```

```bash yarn
yarn add @standardagents/cerebras
```

## Quick Start

```typescript agents/models/cerebras_fast.ts
import { defineModel } from '@standardagents/spec';
import { cerebras } from '@standardagents/cerebras';

export default defineModel({
  name: 'cerebras-fast',
  provider: cerebras,
  model: 'qwen-3.8-27b',
  // Prices change. Check https://www.cerebras.ai/pricing
  inputPrice: 0.99,
  outputPrice: 1.49,
});
```

## Provider Factory

```typescript
import { cerebras } from '@standardagents/cerebras';

defineModel({
  name: 'reasoning-model',
  provider: cerebras,
  model: 'gpt-oss-120b',
});
```

## Provider Options

```typescript
import { defineModel } from '@standardagents/spec';
import { cerebras } from '@standardagents/cerebras';

export default defineModel({
  name: 'cerebras-reasoning',
  provider: cerebras,
  model: 'gpt-oss-120b',
  providerOptions: {
    service_tier: 'default',
    reasoning_effort: 'high',
    user: 'user-123',
    seed: 42,
  },
});
```

### Available Options

| Option             | Type                                          | Description                                          |
| ------------------ | --------------------------------------------- | ---------------------------------------------------- |
| `service_tier`     | `'priority' \| 'default' \| 'auto' \| 'flex'` | Request prioritization tier                          |
| `reasoning_effort` | `'none' \| 'low' \| 'medium' \| 'high'`       | Override reasoning behavior directly                 |
| `clear_thinking`   | `boolean`                                     | Preserve or clear prior thinking on supported models |
| `user`             | `string`                                      | End-user identifier                                  |
| `seed`             | `number`                                      | Best-effort deterministic sampling seed              |
| `logprobs`         | `boolean`                                     | Return token log probabilities                       |
| `top_logprobs`     | `number`                                      | Number of top logprobs to return                     |

> **Note:**
>
> Standard Agents also maps `reasoning.level` to Cerebras `reasoning_effort` automatically for supported models like `gpt-oss-120b`.

## Model IDs

Cerebras model IDs are sent directly, for example:

- `qwen-3.8-27b`
- `gpt-oss-120b`

The provider reads public model metadata from `https://api.cerebras.ai/public/v1/models?format=openrouter` and exposes those models in the Standard Agents UI.

For request cost tracking, the provider calculates cost from token usage with a built-in pricing map for documented models like `llama3.1-8b`, `qwen-3-235b-a22b-instruct-2507`, `gpt-oss-120b`, and `zai-glm-4.7`.

## Capabilities

The provider maps Cerebras public model metadata into Standard Agents capabilities:

- `supportsToolCalls` from `supported_features`
- `supportsJsonMode` from `json_mode` / `structured_outputs`
- `maxContextTokens` from `context_length`
- `maxOutputTokens` from `max_output_length`

For models not returned by the current public endpoint, the package includes fallback metadata for documented models like `gpt-oss-120b` and `zai-glm-4.7`.

## Environment Setup

```bash .dev.vars
CEREBRAS_API_KEY=...
```

For a deployed project, set `CEREBRAS_API_KEY` in your project's environment settings on the Standard Agents platform.

## Notes

- The provider uses Chat Completions, not OpenAI Responses.
- Cerebras documents `frequency_penalty`, `presence_penalty`, and `logit_bias` as currently unsupported.
- `json_object` responses are not compatible with streaming on the Cerebras API.
- For custom or private Cerebras models, set `inputPrice` and `outputPrice` explicitly if you want cost tracking in logs.

## Related

- [Models](/docs/core-concepts/models)

  Core model concepts

* [OpenAI Provider](/docs/providers/openai)

  Compare with OpenAI

- [OpenRouter Provider](/docs/providers/openrouter)

  Compare with OpenRouter
