PHPackages                             papi-ai/laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. papi-ai/laravel

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

papi-ai/laravel
===============

Laravel bridge for PapiAI - AI agent library

v0.9.1(2mo ago)04MITPHPPHP ^8.2CI passing

Since Mar 7Pushed 2mo agoCompare

[ Source](https://github.com/papi-ai/laravel)[ Packagist](https://packagist.org/packages/papi-ai/laravel)[ RSS](/packages/papi-ai-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (7)Versions (4)Used By (0)

PapiAI Laravel Bridge
=====================

[](#papiai-laravel-bridge)

[![CI](https://github.com/papi-ai/laravel/workflows/CI/badge.svg)](https://github.com/papi-ai/laravel/actions?query=workflow%3ACI) [![Latest Version](https://camo.githubusercontent.com/edabb453a89d62435bb39d04eee7cbe74d45535049a1d5659d738da62bcf3548/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706170692d61692f6c61726176656c2e737667)](https://packagist.org/packages/papi-ai/laravel) [![Total Downloads](https://camo.githubusercontent.com/9682330448db6b83ee9272cbe6e88baf9636adf96711875f3a4920c7fb288080/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706170692d61692f6c61726176656c2e737667)](https://packagist.org/packages/papi-ai/laravel) [![PHP Version](https://camo.githubusercontent.com/90e5591592bc1558bcc7cb14aaffe1de377debf0b7c922a80784f5def9e3c22d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f706170692d61692f6c61726176656c2e737667)](https://packagist.org/packages/papi-ai/laravel) [![License](https://camo.githubusercontent.com/54bfaaeb0d2c962cc8610eadf5682c55d733794b51a774e52b72193313b3160b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f706170692d61692f6c61726176656c2e737667)](https://packagist.org/packages/papi-ai/laravel)

Laravel integration for the [PapiAI](https://github.com/papi-ai/papi-core) AI agent library. Provides a service provider, facade, Eloquent conversation store, and queue integration.

Installation
------------

[](#installation)

```
composer require papi-ai/laravel
```

The service provider is auto-discovered by Laravel. No manual registration needed.

Configuration
-------------

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --tag=papi-config
```

This creates `config/papi.php` where you can configure:

- **Default provider** -- which AI provider to use (`openai`, `anthropic`, etc.)
- **Provider settings** -- API keys, models, and driver classes
- **Middleware** -- middleware classes applied to all agents
- **Conversation storage** -- file-based or Eloquent-based

### Environment Variables

[](#environment-variables)

```
PAPI_PROVIDER=openai
OPENAI_API_KEY=your-openai-key
ANTHROPIC_API_KEY=your-anthropic-key
```

Usage
-----

[](#usage)

### Using the Facade

[](#using-the-facade)

```
use PapiAI\Laravel\Facades\Papi;

// Simple prompt
$response = Papi::run('What is the capital of France?');
echo $response->text;

// Streaming
foreach (Papi::stream('Tell me a story') as $chunk) {
    echo $chunk->text;
}
```

### Resolving from the Container

[](#resolving-from-the-container)

```
// Get the configured provider
$provider = app('papi');

// Get the pre-configured agent
$agent = app('papi.agent');
$response = $agent->run('Hello!');
```

### Adding Tools

[](#adding-tools)

```
use PapiAI\Laravel\Facades\Papi;

Papi::addTool(new MyCustomTool());
$response = Papi::run('Use my tool to do something');
```

### Middleware

[](#middleware)

Configure middleware in `config/papi.php`:

```
'middleware' => [
    \PapiAI\Core\Middleware\LoggingMiddleware::class,
    \PapiAI\Core\Middleware\RetryMiddleware::class,
],
```

Or add middleware at runtime:

```
use PapiAI\Laravel\Facades\Papi;

Papi::addMiddleware(new RateLimitMiddleware(maxRequests: 10));
```

### Conversation Storage

[](#conversation-storage)

Switch to Eloquent-based storage in `config/papi.php`:

```
'conversation' => [
    'store' => 'eloquent',
],
```

The Eloquent store uses the `papi_conversations` table. Create a migration:

```
Schema::create('papi_conversations', function (Blueprint $table) {
    $table->string('id')->primary();
    $table->json('data');
    $table->timestamp('updated_at')->nullable();
});
```

### Queue Integration

[](#queue-integration)

Dispatch agent jobs to Laravel queues:

```
use PapiAI\Laravel\Queue\LaravelQueue;
use PapiAI\Core\AgentJob;

$queue = app(LaravelQueue::class);

$jobId = $queue->dispatch(new AgentJob(
    agentClass: MyAgent::class,
    prompt: 'Process this in the background',
));

$status = $queue->status($jobId);
```

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 10, 11, or 12
- papi-ai/papi-core ^0.9

License
-------

[](#license)

MIT

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance88

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

3

Last Release

61d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/126c34b4dff8d42336ea07ac5297bcc3ec0a0e306fd964a7497f02240da4b142?d=identicon)[md](/maintainers/md)

---

Top Contributors

[![MarcelloDuarte](https://avatars.githubusercontent.com/u/144535?v=4)](https://github.com/MarcelloDuarte "MarcelloDuarte (6 commits)")

###  Code Quality

TestsPest

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/papi-ai-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/papi-ai-laravel/health.svg)](https://phpackages.com/packages/papi-ai-laravel)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
