# AI Provider for Cerebras

AI Provider for Cerebras for the [WordPress AI Client](https://github.com/WordPress/php-ai-client). Works as both a Composer package and a WordPress plugin.

This provider registers **Cerebras** with the AI Client, exposing the open models Cerebras serves on its ultra-fast wafer-scale inference platform (Llama, Qwen, GPT-OSS, and more) for text generation through Cerebras's OpenAI-compatible Chat Completions API.

## Requirements

- PHP 7.4+
- WordPress 6.9+ (when used as a plugin)
- The [`wordpress/php-ai-client`](https://github.com/WordPress/php-ai-client) SDK
- A Cerebras API key from the [Cerebras Cloud console](https://cloud.cerebras.ai/)

## How it works

Cerebras exposes an OpenAI-compatible API, so this provider is intentionally thin:

| Class | Responsibility |
| --- | --- |
| `Provider\CerebrasProvider` | Registers the provider, base URL (`https://api.cerebras.ai/v1`), API-key auth, and metadata. |
| `Metadata\CerebrasModelMetadataDirectory` | Lists models from `GET /v1/models` and maps capabilities/options. |
| `Models\CerebrasTextGenerationModel` | Sends `POST /v1/chat/completions` via the shared OpenAI-compatible base class. |

Because Cerebras speaks the Chat Completions format, `CerebrasTextGenerationModel` extends
`AbstractOpenAiCompatibleTextGenerationModel` from the SDK and only overrides request construction.

## Supported capabilities

- Text generation (chat) with the open models hosted on Cerebras
- Function calling and JSON / structured output

## Installation

### As a WordPress plugin

Copy this directory into `wp-content/plugins/` and activate it alongside the WordPress AI Client.

### As a Composer package

```bash
composer require itzmekhokan/ai-provider-for-cerebras
```

## Author

[Khokan Sardar](https://profiles.wordpress.org/khokansardar/)

## License

GPL-2.0-or-later
