rickphp / laravel-rick
Durable, tenant-aware AI workflow compilation and execution for Laravel
Requires
- php: ^8.3
- ext-json: *
- ext-mbstring: *
- illuminate/contracts: ^12.0|^13.0
- illuminate/database: ^12.0|^13.0
- illuminate/events: ^12.0|^13.0
- illuminate/pipeline: ^12.0|^13.0
- illuminate/queue: ^12.0|^13.0
- illuminate/support: ^12.0|^13.0
- laravel/ai: ^0.9.1 || ^0.10.0
- opis/json-schema: ^2.6
Requires (Dev)
- larastan/larastan: ^3.10
- laravel/pint: ^1.24
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-mutate: ^4.0
- phpstan/phpstan: ^2.2
- phpstan/phpstan-strict-rules: ^2.0
- predis/predis: ^2.3
README
Durable AI workflows for Laravel.
Laravel Rick turns typed workflow definitions into recoverable, tenant-aware runs. It supports synchronous and queued execution, Laravel AI calls, manual review and input, encrypted persistence, budgets, metrics, recovery, and a transactional outbox.
Demo
Run the human-in-the-loop demo to generate five candidates, pause for a human decision, and continue with the selected result. It is free and deterministic by default, with an optional live Laravel AI provider mode.
Installation
Laravel Rick requires PHP 8.3+ and Laravel 12 or 13.
composer require rickphp/laravel-rick:^0.1 php artisan migrate
Provider setup
For OpenRouter, add your key and model to .env:
OPENROUTER_API_KEY=your-key-here RICK_LLM_PROVIDER=openrouter RICK_LLM_MODEL=google/gemini-3.5-flash-lite
Publish the package configuration:
php artisan vendor:publish --tag=rick-config
Then route the medium tier in config/rick.php:
'medium' => [ 'provider' => env('RICK_LLM_PROVIDER', 'openrouter'), 'model' => env('RICK_LLM_MODEL'), ],
After changing .env or configuration, run php artisan config:clear.
Laravel Rick routes through every text provider supported by the installed Laravel AI SDK. With Laravel AI 0.10, that includes OpenAI, OpenAI Compatible, Anthropic, Gemini, Azure OpenAI, Amazon Bedrock, Groq, xAI, DeepSeek, Mistral, Ollama, and OpenRouter. Structured workflows also require a selected model that supports structured output. OpenRouter is live-tested by this package; Gemini structured schemas are covered by regression fixtures. Other providers use the same adapter but are not yet live-tested by the package.
See Installation and configuration for all model tiers, provider credentials, cost notes, and troubleshooting. Laravel AI maintains the current provider support matrix.
Quick start
After configuring a Laravel AI provider and model, run a prompt as a durable workflow:
use Rick\Laravel\Rick; $rick = app(Rick::class); $workflow = $rick->workflow('summary') ->rawPrompt('Summarize the latest customer feedback.') ->build(); $run = $rick->run($workflow); echo $run->output();
Longer workflows can generate candidates, pause for human input, run in parallel, enforce quality gates, verify grounding, and resume through queues.
Typical tasks
The examples below assume $rick = app(Rick::class).
Generate content within a fixed budget
$workflow = $rick->workflow('product-description') ->budget(maxCostUsd: '0.10') ->resolve('Write a product description.', 'A concise description is ready.') ->context('product') ->generate('description', outputKey: 'description') ->outputGlue('description') ->build(); $run = $rick->run($workflow, ['product' => $product]);
Process a list through queues
$workflow = $rick->workflow('ticket-summaries') ->resolve('Summarize every support ticket.', 'Every ticket has a summary.') ->context('tickets') ->map('tickets', 'items', 'rick.text', 'summaries', maxItems: 100) ->outputGlue('summaries') ->build(); $run = $rick->schedule($workflow, ['tickets' => ['items' => $tickets]]);
Generate variants and let a person choose
$workflow = $rick->workflow('campaign-copy') ->resolve('Write campaign copy.', 'Three distinct drafts are ready.') ->draft(candidates: 3) ->manualJudge() ->outputGlue('draft') ->build(); $run = $rick->run($workflow); $review = $rick->pendingReview($run->id); $rick->selectCandidate($run->id, $review->candidates[0]->id);
Verify an answer against supplied evidence
$workflow = $rick->workflow('grounded-answer') ->resolve('Answer the question from the evidence.', 'Every claim is grounded.') ->context('question') ->context('evidence') ->generate('answer', outputKey: 'answer', reads: ['question', 'evidence']) ->groundedVerify('answer', ['evidence'], output: 'verified') ->outputGlue('verified') ->build(); $run = $rick->run($workflow, compact('question', 'evidence'));
Documentation
- Installation and configuration
- Building workflows
- Use cases
- Manual review and external input
- Queues and transactional outbox
- Public API
- Testing without provider calls
Testing
composer qa
Project
- See CHANGELOG.md for release history.
- See CONTRIBUTING.md for contribution guidelines.
- Report vulnerabilities through GitHub private security advisories; see SECURITY.md.
- Laravel Rick is released under the MIT License.
