Download the PHP package rmh/laravel-openui without Composer
On this page you can find all versions of the php package rmh/laravel-openui. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rmh/laravel-openui
More information about rmh/laravel-openui
Files in rmh/laravel-openui
Package laravel-openui
Short Description OpenUI Generative UI integration for the Laravel AI SDK - inject OpenUI Lang system prompts, define component libraries, and stream structured UI responses.
License MIT
Informations about the package laravel-openui
laravel-openui
OpenUI Generative UI integration for the Laravel AI SDK.
This package connects OpenUI — the open standard for Generative UI — with the Laravel AI SDK. It handles system prompt injection, component library management, caching, and streaming, so your agents can respond with structured, interactive UI instead of plain text.
How It Works
OpenUI works in four steps:
- You define which React components the LLM is allowed to generate.
- This package injects a system prompt into your agent's instructions describing those components and the OpenUI Lang syntax.
- The LLM responds in OpenUI Lang (a compact, streaming-native format).
- Your frontend's
<Renderer />from@openuidev/react-langparses and renders it live.
Installation
Publish the config file:
Quick Start
Option 1: Global Middleware (zero-touch, all agents)
Register the middleware once in your AppServiceProvider and every agent will automatically receive the OpenUI system prompt:
Your agents need no changes. Stream the response back to your OpenUI frontend:
Option 2: GeneratesUI Trait (explicit opt-in per agent)
Add the trait to agents that should produce UI. Rename instructions() to agentInstructions():
Toggle UI per call:
Option 3: Per-agent Middleware
Add the middleware only to specific agents:
Option 4: Anonymous Agents / Inline Calls
Defining Your Component Library
In config/openui.php
Supported prop types: string, int, float, bool, array, ComponentName[], enum:a|b|c. Append ? to mark any type as optional.
Via the Facade (programmatic / runtime)
The cache is automatically invalidated when you add components via the facade.
Via the Artisan Command
Scaffold a typed component definition class:
This generates app/Ai/OpenUI/Components/CardComponent.php. Register it in your service provider:
Export for Frontend
Export your component definitions to TypeScript/Zod for your frontend:
This generates resources/js/openui.ts with Zod schemas:
Export options:
| Option | Description |
|---|---|
--path=... |
Custom output path (default: resources/js/openui.ts) |
--format=zod\|ts\|json |
Output format (default: zod) |
--types |
TypeScript types only (shorthand for --format=ts) |
--force |
Overwrite existing file |
Examples:
Configuration Reference
Frontend Integration
Option 1: Use Exported Schema (Recommended)
Export your component definitions and import them directly:
Then in your frontend:
Option 2: Manual Schema Definition
Define schemas manually on the frontend:
Inspecting the Generated System Prompt
Testing
When writing tests for agents that use OpenUI, you can temporarily disable injection:
Or assert on the generated prompt:
Changelog
Please see CHANGELOG.md.
License
MIT — see LICENSE.md.