Prism

A unified, fluent Laravel interface for working with large language models across every major AI provider.

Library
Composer
vv0.100.1
2,413stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
55/100Fair
Development Activity8
Maintenance48
Community76
Maturity48
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
86/100Excellent
Architecture86
Code Quality88
Innovation90
Learning Curve72

Prism is a Laravel package that gives you one fluent, expressive API for integrating large language models into your applications. Instead of learning a different SDK for every provider, you write the same chainable calls to generate text, produce structured output, create embeddings, generate images, transcribe audio, and run moderation—then swap the underlying model with a single line.

Built for Laravel developers, Prism handles multi-step conversations, tool/function calling, and streaming out of the box, with first-class support for OpenAI, Anthropic, Gemini, Groq, Mistral, Ollama, DeepSeek, xAI, OpenRouter, and more. It leans on Laravel’s service container and configuration conventions so AI features feel native to the framework.

What You Get

  • A fluent, chainable API for text generation, structured output, embeddings, images, audio, and moderation
  • First-class support for OpenAI, Anthropic, Gemini, Groq, Mistral, Ollama, DeepSeek, xAI, OpenRouter, Perplexity, and more
  • Built-in tool/function calling with multi-step conversation handling and streaming responses
  • Deep Laravel integration via a service provider, config file, and testing fakes

Common Use Cases

  • Adding chat, summarization, or content-generation features to a Laravel application
  • Extracting structured, schema-validated data from unstructured text with LLMs
  • Building AI agents that call tools and reason over multiple steps
  • Powering semantic search and retrieval with provider-agnostic embeddings

Under The Hood

Architecture Prism centers on the Prism class (exposed via a Laravel facade), which returns a capability-specific PendingRequest for text, structured, embeddings, image, audio, or moderation. Each PendingRequest collects provider, model, messages, tools, and options via chainable setters, then dispatches through a PrismManager that resolves the configured provider driver under src/Providers/. Providers share a common Provider contract, so response handling, streaming, and tool orchestration are uniform regardless of vendor. A PrismServiceProvider wires everything into the container and publishes config.

Tech Stack The package targets PHP 8.2+ and Laravel 11, 12, and 13, using strict types throughout. It depends only on the Laravel framework and ext-fileinfo at runtime. Development tooling is modern and thorough: Pest 3/4 for testing, PHPStan 2 for static analysis, Laravel Pint for formatting, and Rector for automated refactoring, with Orchestra Testbench and a workbench app for package testing.

Code Quality The codebase is well-structured and heavily tested, with a dedicated Pest suite including architecture tests (ArchTest.php), concurrent tool-execution tests, and per-capability test folders. Strict typing, PHPStan enforcement, and Pint/Rector automation signal a disciplined, maintained project. Code is organized by domain (Text, Structured, Embeddings, Audio, Images, Moderation, Tools) rather than by technical layer, keeping related logic together.

API Design The public API is the standout: a fluent, discoverable interface that reads almost like prose and hides provider differences behind consistent method names. Getting started requires minimal boilerplate—resolve the facade, chain a few setters, call generate—and swapping providers is a configuration change. Documentation lives on a dedicated site (prismphp.com) rather than in the README, so the ergonomics are excellent once you know where the docs are.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search