A Cloudflare Workers AI provider for Laravel AI
Cloudflare Workers AI in Laravel, with Clef and Clairic.
Cloudflare Workers AI provider for the Laravel AI SDK: text, embeddings, reranking, images, speech, transcription, Clef decisions and Clairic typed extraction, with AI Gateway routing.
composer require meirdick/laravel-cf-workersaiAnswers, not generated text
Clef and Clairic are System One models. They do not generate tokens. They read your input in one pass and return typed answers with probabilities.
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();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();All of Laravel AI
Text, tools, embeddings, reranking, images, speech and transcription, with the Laravel AI code you already write.
Direct or gateway
One config key adds AI Gateway logs, caching and rate limits. Your calling code does not change.
Cloudflare failures handled
A token cap, an exception on an empty answer, retries for edge errors, and neuron figures.
Needs PHP 8.3 and laravel/ai 0.9 to 1.3. Clef needs laravel/ai 1.0 or later. MIT license.