Introduction
Prism provides a unified PHP interface for language-model APIs in Laravel applications. Use it to generate text, stream responses, call tools and work with multimodal input.
Generate text by selecting a provider and model:
use Prism\Prism\Facades\Prism; use Prism\Prism\Enums\Provider; $response = Prism::text() ->using(Provider::Anthropic, 'claude-sonnet-5-5') ->withSystemPrompt('Explain concepts in plain language.') ->withPrompt('Explain quantum computing to a 5-year-old.') ->asText(); echo $response->text;
use Prism\Prism\Facades\Prism; use Prism\Prism\Enums\Provider; $response = Prism::text() ->using(Provider::Mistral, 'mistral-medium-3-5') ->withSystemPrompt('Explain concepts in plain language.') ->withPrompt('Explain quantum computing to a 5-year-old.') ->asText(); echo $response->text;
use Prism\Prism\Facades\Prism; use Prism\Prism\Enums\Provider; $response = Prism::text() ->using(Provider::Ollama, 'llama3.2') ->withSystemPrompt('Explain concepts in plain language.') ->withPrompt('Explain quantum computing to a 5-year-old.') ->asText(); echo $response->text;
use Prism\Prism\Facades\Prism; use Prism\Prism\Enums\Provider; $response = Prism::text() ->using(Provider::OpenAI, 'gpt-4.1') ->withSystemPrompt('Explain concepts in plain language.') ->withPrompt('Explain quantum computing to a 5-year-old.') ->asText(); echo $response->text;
use Prism\Prism\Facades\Prism; use Prism\Prism\Enums\Provider; $response = Prism::text() ->using(Provider::Replicate, 'meta/meta-llama-3.1-405b-instruct') ->withSystemPrompt('Explain concepts in plain language.') ->withPrompt('Explain quantum computing to a 5-year-old.') ->asText(); echo $response->text;
Prism's API is inspired by the Vercel AI SDK.
Key Features#
- Text and conversations, structured output, and streaming.
- Custom and provider tools, including client execution and approvals on supported integrations.
- Embeddings, image generation/editing, audio processing, and moderation.
- Images, documents, audio and video as model inputs.
- Files, Batch, and Mistral fill-in-the-middle.
- Response fakes, telemetry events, and an optional OpenAI-compatible server.
Support varies by provider and model; a shared method does not imply that every integration supports it. The Ollama example requires that the named model is installed on your server.
Prism also provides a fluent prism() helper function to resolve the Prism instance from the application container.
prism() ->text() ->using(Provider::OpenAI, 'gpt-4.1') ->withPrompt('Explain quantum computing to a 5-year-old.') ->asText();
Providers#
Prism includes integrations for the following providers:
- Anthropic
- Azure OpenAI
- DeepSeek
- ElevenLabs
- Gemini
- Groq
- Mistral
- Ollama
- OpenAI
- OpenRouter
- Perplexity
- Qwen
- Replicate
- Requesty
- Vertex AI
- VoyageAI
- xAI
- Z
Provider Support#
See each provider's page for supported features, configuration and limitations. Availability also depends on the selected model.
| Provider | Text | Streaming | Structured | Embeddings | Image | Speech-to-Text | Text-to-Speech | Tools | Documents | Moderation |
|---|---|---|---|---|---|---|---|---|---|---|
| Anthropic | ✅ | ✅ | ✅ | — | ✅ | — | — | ✅ | ✅ | — |
| Azure OpenAI | ✅ | ✅ | ✅ | ✅ | ✅ | — | — | ✅ | — | — |
| DeepSeek | ✅ | ✅ | ✅ | — | ✅ | — | — | ✅ | — | — |
| ElevenLabs | — | — | — | — | — | ✅ | ✅ | — | — | — |
| Gemini | ✅ | ✅ | ✅ | ✅ | ✅ | — | ✅ | ✅ | ✅ | — |
| Groq | ✅ | ✅ | ✅ | — | ✅ | ✅ | ✅ | ✅ | — | — |
| Mistral | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | — | ✅ | ✅ | — |
| Ollama | ✅ | ✅ | ✅ | ✅ | ✅ | — | — | ✅ | — | — |
| OpenRouter | ✅ | ✅ | ✅ | ✅ | ✅ | — | — | ✅ | ✅ | — |
| Requesty | ✅ | ✅ | ✅ | ✅ | ✅ | — | — | ✅ | ✅ | — |
| OpenAI | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Qwen | ✅ | ✅ | ✅ | ✅ | ✅ | — | — | ✅ | — | — |
| Replicate | ✅ | ✅ | ⚙️ | ✅ | — | ✅ | ✅ | — | — | — |
| VoyageAI | — | — | — | ✅ | — | — | — | — | — | — |
| xAI | ✅ | ✅ | ✅ | — | ✅ | — | — | ✅ | — | — |
| Perplexity | ✅ | ✅ | ✅ | — | — | — | — | — | — | — |
| Vertex AI | ✅ | ✅ | ✅ | ✅ | ✅ | — | — | ✅ | ✅ | — |
| Z | ✅ | ✅ | ✅ | — | ✅ | — | — | ✅ | ✅ | — |
✅ supported · 🟡 planned · ⚙️ adapted · — not supported