Skip to content

A Cloudflare Workers AI provider for Laravel AI

Cloudflare Workers AI in Laravel, with Clef and Clairic.

Run the Laravel AI code you already write on the models Cloudflare hosts: text, embeddings, reranking, images, speech, transcription, Clef decisions and Clairic typed extraction, directly or through AI Gateway.

composer require meirdick/laravel-cf-workersai

Answers, not generated text

Clef and Clairic are System One models. They don’t generate text. They read your input in one pass and return typed answers with probabilities, so you have nothing to parse.

Clef decides among options you list.

use Laravel\Ai\Classification;
use Laravel\Ai\Classification\Boolean;

$response = Classification::of($ticket)
    ->question('urgent', new Boolean('Urgent?'))
    ->classify(provider: 'workers-ai');

$response['urgent']->isTrue();
Clef guide

Clairic extracts a value of the type you ask for, or null.

use Meirdick\WorkersAi\Extraction;
use Meirdick\WorkersAi\Extraction\Number;

$invoice = Extraction::of($text)
    ->field('total', new Number(unit: 'USD'))
    ->extract();

$invoice['total']->value();
Clairic guide

Needs PHP 8.3 and laravel/ai 0.9 to 1.3, and Clef needs laravel/ai 1.0 or later. MIT license.

Type to search…

↑↓ navigate↵ selectEsc close