Skip to main content
Prism Logo Large Language Models (LLMs) have revolutionized how we interact with artificial intelligence, enabling applications to understand, generate, and manipulate human language with unprecedented sophistication. These powerful models open up exciting possibilities for developers, from creating chatbots and content generators to building complex AI-driven applications. Prism simplifies the process of integrating LLMs into your Laravel projects, providing a unified interface to work with various AI providers. This allows you to focus on crafting innovative AI features for your users, rather than getting bogged down in the intricacies of different APIs and implementation details.

Quick example

Here’s how you can generate text using Prism:
use Prism\Prism\Facades\Prism;
use Prism\Prism\Enums\Provider;

$response = Prism::text()
    ->using(Provider::Anthropic, 'claude-3-7-sonnet-latest')
    ->withSystemPrompt(view('prompts.system'))
    ->withPrompt('Explain quantum computing to a 5-year-old.')
    ->asText();

echo $response->text;

Key features

Unified provider interface

Switch seamlessly between AI providers like OpenAI, Anthropic, and Ollama without changing your application code.

Multi-modal capabilities

Work with text, images, audio, and video seamlessly using the same elegant API for rich, context-aware responses.

Tool system

Extend AI capabilities by defining custom tools that can interact with your application’s business logic.

Structured output

Transform AI responses into strongly-typed data with schema validation and rich object mapping.

First-class testing support

Write confident code with comprehensive testing utilities, including response faking and detailed assertion helpers.

Fluent API

Craft AI-powered applications with an intuitive, chainable API that feels right at home in your Laravel projects.

Helper function

Prism provides a fluent prism() helper function to resolve the Prism instance from the application container:
use Prism\Prism\Enums\Provider;

prism()
    ->text()
    ->using(Provider::OpenAI, 'gpt-4')
    ->withPrompt('Explain quantum computing to a 5-year-old.')
    ->asText();

Supported providers

We currently offer first-party support for these leading AI providers:

Anthropic

Claude models with extended thinking capabilities

OpenAI

GPT models with function calling and structured outputs

Ollama

Local LLM deployment for privacy-focused applications

Mistral

Open-source models with strong performance

Groq

Ultra-fast inference for real-time applications

DeepSeek

Cost-effective models with strong reasoning capabilities

xAI

Grok models with real-time information access

Gemini

Google’s multi-modal AI models
Each provider brings its own strengths to the table, and Prism makes it easy to use them all through a consistent, elegant interface.

Next steps

Installation

Install Prism via Composer and publish the configuration file

Quickstart

Get up and running with your first AI-powered feature in minutes

Configuration

Configure providers and customize Prism for your application

Text generation

Learn how to generate text with LLMs

Inspiration

Prism draws significant inspiration from the Vercel AI SDK, adapting its powerful concepts and developer-friendly approach to the Laravel ecosystem.

Build docs developers (and LLMs) love