Kritim Yantra
May 07, 2025
Artificial Intelligence is transforming how we build web applications. With the rise of Large Language Models (LLMs) like OpenAI’s GPT, Anthropic’s Claude, and Mistral, developers can now integrate powerful AI features into their apps effortlessly. That’s where PrismPHP comes in—a Laravel package designed to simplify and supercharge your LLM integrations.
In this beginner-friendly blog post, we'll explore what PrismPHP is, why it’s useful, and how you can start using it in your Laravel projects.
PrismPHP is a modern Laravel package that provides a unified, fluent interface for working with LLMs. Instead of juggling multiple SDKs and API formats, PrismPHP lets you focus on what matters—building smart features—while handling all the messy details behind the scenes.
Whether you want to build a chatbot, generate content, analyze documents, or use AI for structured data, PrismPHP gives you a clean, expressive Laravel-style syntax to do it all.
Out of the box, PrismPHP supports popular providers like OpenAI, Anthropic, Mistral, Ollama, and more. Switching between providers is as simple as changing a method.
Generate text using a chainable API similar to Laravel’s Facades. It's intuitive, clean, and fun to use.
PrismPHP allows you to stream model responses in real time—ideal for long-form answers or live chat interfaces.
Define custom tools (like database lookups or API calls) that LLMs can invoke on-the-fly during conversation.
Ensure your AI responses match specific formats using schema validation and structured response parsing.
Incorporate images and documents seamlessly, thanks to support for vision tasks and document analysis.
Expose your AI models via an OpenAI-compatible API using Prism Server—perfect for building your own internal LLM-based services.
Use built-in testing tools to fake responses and simulate AI behavior without hitting live APIs.
composer require prism-php/prism
php artisan vendor:publish --tag=prism-config
This will create a config/prism.php
file where you can customize settings and provider credentials.
use Prism\Prism\Prism;
use Prism\Prism\Enums\Provider;
$response = Prism::text()
->using(Provider::Anthropic, 'claude-3-sonnet')
->withSystemPrompt(view('prompts.system'))
->withPrompt('Explain quantum computing in simple terms.')
->asText();
echo $response->text;
That’s it! You’ve just used an advanced LLM to generate a simple explanation using clean, readable code.
Use embeddings for similarity search and schema-based outputs for consistent data formats.
Integrate with any other LLM provider by implementing Prism’s Provider
contract.
Turn your Prism-powered app into an API service that mimics OpenAI’s endpoints. Great for internal tools and extensions.
PrismPHP is the Laravel-native toolkit you need to bring AI power into your web applications. It combines the flexibility of multi-provider support with Laravel’s elegance and developer-friendly syntax.
Whether you’re building an AI assistant, a content generator, or a smart internal dashboard, PrismPHP makes it easy and enjoyable.
So why wait? Install PrismPHP today and start building the future with Laravel and AI.
No comments yet. Be the first to comment!
Please log in to post a comment:
Sign in with Google