Prism is a powerful Laravel package for integrating Large Language Models (LLMs) into your applications. It provides a fluent interface for generating text, handling multi-step conversations, and utilizing tools with various AI providers. This way, you can focus on developing outstanding AI applications for your users without getting lost in the technical intricacies.
Official documentation can be found at prism.echolabs.dev.
First, let's add Prism to your project using Composer. Open your terminal, navigate to your project directory, and run:
composer require echolabsdev/prism
This command will download Prism and its dependencies into your project.
Prism comes with a configuration file that you'll want to customize. Publish it to your config directory by running:
php artisan vendor:publish --tag=prism-config
This will create a new file at config/prism.php
. We'll explore how to configure Prism in the next section.
<?php
$response = Prism::using('anthropic', 'claude-3-5-sonnet-20240620')
->generateText()
->withSystemMessage(view('prompts.nyx'))
->withPrompt('Explain quantum computing to a 5-year-old.')();
echo $response->text;
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.