Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Prism Laravel Package

prism-php/prism

Prism is a Laravel package for integrating LLMs with a fluent API. Generate text, run multi-step conversations, and call tools across multiple AI providers, so you can build AI features in your app without wrestling with provider-specific details.

View on GitHub
Deep Wiki
Context7

A powerful Laravel package for integrating Large Language Models (LLMs) into your applications.

Frequently asked questions about Prism
How do I install Prism in a Laravel project?
Run `composer require prism-php/prism` in your project directory. Prism requires Laravel 11+ and PHP 8.2+. After installation, publish the config file with `php artisan vendor:publish --tag=prism-config` and set your API keys in `.env`.
Which AI providers does Prism support out of the box?
Prism supports OpenAI, Anthropic, and other providers via a unified interface. You can switch providers dynamically at runtime using methods like `Prism::text()->using(Provider::OpenAI)`. Additional providers can be added via custom adapters.
Can Prism handle multi-step conversations like chatbots?
Yes, Prism includes built-in support for multi-step conversations. You can maintain conversation state using `Prism::conversation()` and chain messages sequentially. For persistence, store the conversation history in a database or cache layer.
How do I integrate custom tools or functions with LLM responses?
Use the `Prism::text()->withTools()` method to define functions the LLM can call. Tools are mapped to PHP closures or controller methods, enabling dynamic interactions like database queries or external API calls. Example: `->withTools([new DatabaseQueryTool()])`.
What Laravel versions does Prism support?
Prism is designed for Laravel 11+ and requires PHP 8.2+. It leverages Laravel’s service container, Facades, and caching, so older versions (e.g., Laravel 10) are not supported. Check the [Prism website](https://prismphp.com) for version-specific updates.
How do I secure API keys for multiple providers?
Store API keys in Laravel’s `.env` file (e.g., `ANTHROPIC_API_KEY=...`). Prism retrieves them via the service container. For production, use Laravel Forge, Vault, or a secrets manager. Never hardcode keys in your application.
Can I use Prism for async LLM operations to avoid timeouts?
Yes, dispatch LLM requests asynchronously using Laravel queues. Wrap Prism calls in a job (e.g., `PrismJob::dispatch()`) and process responses later. Configure `request_timeout` in `config/prism.php` to handle long-running operations.
What’s the best way to test Prism in a CI/CD pipeline?
Mock LLM responses using Laravel’s HTTP testing helpers or a library like `mockery`. Test conversation flows with `Prism::conversation()->assertResponse()`. For provider-specific tests, use mock adapters or stubbed API responses to avoid rate limits.
How do I handle rate limits or cost spikes with Prism?
Monitor usage with Laravel’s `throttle` middleware or a package like `spatie/rate-limiting`. Implement budget alerts via Laravel Notifications or a dashboard. Prism supports runtime provider switching, so you can fallback to a cheaper provider if needed.
Are there alternatives to Prism for LLM integration in Laravel?
Alternatives include `laravel-ai` (official Laravel AI tools) or `php-ai` for general-purpose LLM wrappers. Prism stands out for its fluent API, multi-provider support, and built-in tool/function calling. Choose based on your need for abstraction (Prism) vs. flexibility (raw API clients).
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope