fomvasss/laravel-ai-tasks
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.

- Routing with fallback — a chain of drivers per task, the next one is tried when a provider is down
- Queues — idempotency, delayed dispatch, retries of unusable results,
onCompleted()/onFailed()hooks - Audit log — every run in
ai_runs: driver, model, tokens, cost, duration, status - Budgets and cost tracking — per tenant, per driver and per model
- Dashboard — runs, driver state, stuck runs, retry from the browser
- Text, image, embeddings, TTS, transcription, tools & MCP, structured output, streaming
AI::fake()for tests
Requirements
- PHP ^8.3
- Laravel ^12 | ^13
- laravel/ai ^1.2
Installation
composer require fomvasss/laravel-ai-tasks
php artisan vendor:publish --provider="Laravel\Ai\AiServiceProvider" --tag=ai-config
php artisan vendor:publish --tag=ai-tasks-config
php artisan vendor:publish --tag=ai-migrations
php artisan migrate
AI_DEFAULT=openai
OPENAI_API_KEY=sk-...
Security: the dashboard at
/ai-tasksis open to anyone by default. Setdashboard.middlewareto e.g.['web', 'auth']before deploying.
Quick start
php artisan ai:make-task SummarizeTask
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($text)); // sync
$runId = AI::queue(new SummarizeTask($text)); // queue
AI::stream(new SummarizeTask($text), fn (string $chunk) => print($chunk));
Documentation
Online: https://fomvasss.github.io/laravel-ai-tasks/ — the same pages as in docs/.
- Installation · Configuration
- Tasks · Running tasks · Queued tasks · Driver routing
- Structured output · Tools & MCP · Tool choice & approval · Modalities
- Budgets & tenants · Cost tracking · Provider override
- Dashboard · Webhooks · Testing
- Guides: Production checklist · Chat assistant · Tools in practice · Provider quirks · Testing in practice
- Reference: AI facade · AiTask · AiPayload & AiResponse · ai_runs · Events · Commands · Providers
- Upgrading · Changelog
License
MIT — see LICENSE.
Support
If this package is useful to you, consider supporting its development:
USDT TRC20:
THLgp6DxiAtbNHvgnKV56vk1L38UuUagKf
Related Packages
The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, an...
Comprehensive observability for AI/LLM operations in Laravel applications
Give your Laravel app a brain, safely. Build AI Agents that can execute real act...
Drop-in AI chatbox widget for Laravel with RAG, streaming, Vue 3 frontend, and s...
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 3.27.1 | ^8.3 | ^12.0| | MIT | |
| 3.27.0 | ^8.3 | ^12.0| | MIT | |
| 3.26.1 | ^8.3 | ^12.0| | MIT | |
| 3.26.0 | ^8.3 | ^12.0| | MIT | |
| 3.25.1 | ^8.3 | ^12.0| | MIT | |
| 3.25.0 | ^8.3 | ^12.0| | MIT | |
| 3.24.3 | ^8.3 | ^12.0| | MIT | |
| 3.24.2 | ^8.3 | ^12.0| | MIT | |
| 3.24.1 | ^8.3 | ^12.0| | MIT | |
| 3.24.0 | ^8.3 | ^12.0| | MIT | |
| 3.23.0 | ^8.3 | ^12.0| | MIT | |
| 3.22.0 | ^8.3 | ^12.0| | MIT | |
| 3.21.3 | ^8.3 | ^12.0| | MIT | |
| 3.21.2 | ^8.3 | ^12.0| | MIT | |
| 3.21.1 | ^8.3 | ^12.0| | MIT | |
| 3.21.0 | ^8.3 | ^12.0| | MIT | |
| 3.20.0 | ^8.3 | ^12.0| | MIT | |
| 3.19.1 | ^8.3 | ^12.0| | MIT | |
| 3.19.0 | ^8.3 | ^12.0| | MIT | |
| 3.18.0 | ^8.3 | ^12.0| | MIT | |
| 3.17.0 | ^8.3 | ^12.0| | MIT | |
| 3.16.0 | ^8.3 | ^12.0| | MIT | |
| 3.15.0 | ^8.3 | ^12.0| | MIT | |
| 3.14.1 | ^8.3 | ^12.0| | MIT | |
| 3.14.0 | ^8.3 | ^12.0| | MIT | |
| 3.13.0 | ^8.3 | ^12.0| | MIT | |
| 3.12.0 | ^8.3 | ^12.0| | MIT | |
| 3.11.2 | ^8.3 | ^12.0| | MIT | |
| 3.11.1 | ^8.3 | ^12.0| | MIT | |
| 3.11.0 | ^8.3 | ^12.0| | MIT |
Showing the latest 30 of 50. See every release on Packagist