Laravel AI Tasks
AI task orchestrator for Laravel. Handles routing, queuing, audit logging, budget tracking, and webhook processing on top of laravel/ai as the transport layer.
Every AI call is a task class: it builds the request, optionally shapes the response, and reacts to the final result. The package takes care of everything around the call:
- Routing with fallback — a chain of drivers per task; the next one is tried when a provider is down
- Queues —
AI::queue()with idempotency, delayed dispatch, retries of unusable results - Audit log — every run is stored in
ai_runs: driver, model, tokens, cost, duration, status - Budgets — monthly spend limit per tenant
- Cost tracking — per-driver and per-model rates, prompt-cache tokens, reasoning tokens
- Dashboard — runs list, driver state, stuck runs, retry from the browser
- Modalities — text, image, embeddings, text-to-speech, transcription
- Tools & MCP, structured output, tool approval, streaming
- Testing —
AI::fake()with assertions

Quick example
Section titled “Quick example”use Fomvasss\AiTasks\DTO\AiPayload;use Fomvasss\AiTasks\Tasks\AiTask;use Laravel\Ai\Messages\UserMessage;
class SummarizeTask extends AiTask{ public function __construct(private readonly string $text) {}
public function modality(): string { return 'text'; }
public function toPayload(): AiPayload { return new AiPayload( modality: 'text', messages: [new UserMessage("Summarize: {$this->text}")], systemPrompt: 'Reply in 3 sentences max.', ); }}use Fomvasss\AiTasks\Facades\AI;
$response = AI::send(new SummarizeTask($article->body));echo $response->content;Contents
Section titled “Contents”Getting started
Usage
- Tasks
- Running tasks
- Queued tasks
- Driver routing
- Structured output
- Tools & MCP
- Tool choice & approval
- Modalities
- Budgets & tenants
- Cost tracking
- Per-request provider override
- Dashboard
- Async providers & webhooks
- Testing
Guides — experience from production integrations
- Production checklist
- Building a chat assistant
- Tools in practice
- Provider quirks
- Testing in practice
Reference