**Option 1 (Focus on Laravel integration):** Laravel LLM integration. Unified interface for interacting with various language models. #Laravel #LLM #AI **Option 2 (Focus on abstraction):** LLM abst
<p align="center">
<img src="assets/prism-logo.webp" alt="Prism Logo" />
</p>
<p align="center">
<a href="https://packagist.org/packages/prism-php/prism">
<img src="https://poser.pugx.org/prism-php/prism/d/total.svg" alt="Total Downloads">
</a>
<a href="https://packagist.org/packages/prism-php/prism">
<img src="https://poser.pugx.org/prism-php/prism/v/stable.svg" alt="Latest Stable Version">
</a>
<a href="https://packagist.org/packages/prism-php/prism">
<img src="https://poser.pugx.org/prism-php/prism/license.svg" alt="License">
</a>
</p>
# Prism: Model Context Protocol (MCP) for Laravel
Prism is a powerful Laravel package designed to streamline the integration of Large Language Models (LLMs) into your applications using a Model Context Protocol (MCP). It offers a fluent and intuitive interface for managing complex interactions with AI providers, allowing you to focus on building exceptional AI-powered features for your users.
**Key Features:**
* **Fluent Interface:** Simplify LLM interactions with an expressive and easy-to-use API.
* **Multi-Step Conversations:** Effortlessly manage and maintain context across multiple turns in a conversation.
* **Tool Integration:** Seamlessly integrate external tools and functions into your LLM workflows.
* **Provider Abstraction:** Easily switch between different AI providers (e.g., OpenAI, Cohere) without significant code changes.
* **Model Context Protocol (MCP):** Provides a standardized way to manage and persist the context of your LLM interactions. This includes conversation history, tool usage, and other relevant data, ensuring consistent and predictable behavior.
## Understanding the Model Context Protocol (MCP)
The core of Prism lies in its implementation of the Model Context Protocol (MCP). MCP defines a structured approach to managing the context of your LLM interactions. This context is crucial for:
* **Maintaining Conversation History:** Remembering previous turns in a conversation to provide relevant responses.
* **Tracking Tool Usage:** Keeping track of which tools have been used and their results, allowing the LLM to make informed decisions.
* **Ensuring Consistency:** Providing a consistent and predictable experience for users by ensuring the LLM has access to the necessary information.
Prism handles the complexities of MCP behind the scenes, allowing you to focus on defining the logic of your AI applications.
## Installation
```bash
composer require prism-php/prism
use Prism\Facades\Prism;
// Start a new conversation
$response = Prism::ask("What is the capital of France?");
echo $response; // Output: Paris
// Continue the conversation, leveraging the existing context
$response = Prism::ask("And what is its population?");
echo $response; // Output: (Population of Paris)
This example demonstrates how Prism automatically maintains the context of the conversation, allowing the LLM to understand that "its" refers to Paris.
Comprehensive documentation, including detailed explanations of the MCP implementation and advanced usage examples, can be found on the Prism website.
While we aren't officially affiliated with Laravel, we adhere to the Laravel Code of Conduct. We expect all contributors and users to abide by these guidelines.
This library is created by TJ Miller with contributions from the Open Source Community.
The MIT License (MIT). Please see License File for more information.
```
prism-php/prism
February 23, 2024
July 7, 2025
PHP