Getting Started

Code language

View this guide and its examples in your language.

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:

Anthropic
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;
Mistral
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;
Ollama
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;
OpenAI
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;
Replicate
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#

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:

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