PHPackages                             dewaldhugo/laravel-ai-governor - 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. [API Development](/categories/api)
4. /
5. dewaldhugo/laravel-ai-governor

ActiveLibrary[API Development](/categories/api)

dewaldhugo/laravel-ai-governor
==============================

Prompt versioning, token governance, and deployment tooling for Laravel AI applications. Compatible with Prism PHP, the Laravel AI SDK, and openai-php/laravel.

v1.0.0(1mo ago)32↓100%MITPHPPHP ^8.2CI passing

Since Mar 23Pushed 1mo ago1 watchersCompare

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

READMEChangelogDependencies (7)Versions (2)Used By (0)

Laravel AI Governor
===================

[](#laravel-ai-governor)

[![Tests](https://github.com/dewaldhugo/laravel-ai-governor/actions/workflows/tests.yml/badge.svg)](https://github.com/dewaldhugo/laravel-ai-governor/actions)[![Latest Version on Packagist](https://camo.githubusercontent.com/7643f5a2b5c1b7603923672ccbe06627e01feb0f15d714596f2927a60f5daae7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f646577616c646875676f2f6c61726176656c2d61692d676f7665726e6f722e737667)](https://packagist.org/packages/dewaldhugo/laravel-ai-governor)[![License](https://camo.githubusercontent.com/dad1d86531631de076594716484dc073a18d7ff2d9eb4d50d973fbf009d7e79a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f646577616c646875676f2f6c61726176656c2d61692d676f7665726e6f722e737667)](LICENSE.md)

**Prompt versioning, token governance, and deployment tooling for Laravel AI applications.**

Most Laravel AI packages solve the provider integration problem. AI Governor solves what comes after: how do you version prompts like schema, enforce spending limits per user, and deploy AI configuration through CI without touching production databases?

Compatible with [Prism PHP](https://github.com/echolabs/prism), the [Laravel AI SDK](https://github.com/laravel/ai), and `openai-php/laravel`. No hard provider dependencies.

---

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

[](#requirements)

DependencyVersionPHP8.2+Laravel11 / 12---

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

[](#installation)

```
composer require dewaldhugo/laravel-ai-governor
```

Publish the config and run migrations:

```
php artisan vendor:publish --tag=ai-governor-config
php artisan migrate
```

Set your provider key in `.env`:

```
OPENAI_API_KEY=sk-...
```

---

Core Concepts
-------------

[](#core-concepts)

AI Governor is built around three independent concerns that compose into a governance layer:

**Prompt Migrations** — Prompt definitions live in version control as PHP files. A sync command writes them to the database deterministically, making prompt state part of your deployment pipeline.

**Budget Enforcement** — Any Eloquent model (User, Team, Tenant) can hold a token budget. The `GovernedExecutor` checks the budget before calling the provider and records usage after. Hard limits throw an exception. Soft limits log a warning.

**The Adapter Contract** — Provider calls are isolated behind a single interface. Swap providers by changing one config value. Your application code never changes.

---

Prompt Migrations
-----------------

[](#prompt-migrations)

### 1. Generate a definition

[](#1-generate-a-definition)

```
php artisan make:prompt SummarizeArticle
```

This creates a timestamped file in `app/Prompts`:

```
