DE

developing-with-prism

Simplifies LLM integration in Laravel with a fluent API for text generation and structured outputs.

Install

mkdir -p .claude/skills/developing-with-prism && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/5285" && unzip -o skill.zip -d .claude/skills/developing-with-prism && rm skill.zip

Installs to .claude/skills/developing-with-prism

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Guide for developing with Prism PHP package - a Laravel package for integrating LLMs. Activate or use when working with Prism features including text generation, structured output, embeddings, image generation, audio processing, streaming, tools/function calling, or any LLM provider integration (OpenAI, Anthropic, Gemini, Mistral, Groq, XAI, DeepSeek, OpenRouter, Ollama, VoyageAI, ElevenLabs). Activate for any Prism-related development tasks.
446 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Intermediate

Key capabilities

  • Generate text using various LLM providers
  • Produce structured JSON output via schema definitions
  • Stream LLM responses using server-sent events
  • Execute tools and function calls with multi-step support
  • Process multi-modal inputs including images and documents

How it works

The package provides a fluent API facade to interact with multiple LLM providers, abstracting provider-specific implementation details into a unified interface.

Inputs & outputs

You give it
Prompt text or media file path
You get back
Text, structured object, or stream response

When to use developing-with-prism

  • Generating structured content from LLMs
  • Adding LLM capabilities to Laravel apps
  • Implementing streaming AI responses

About this skill

Developing with Prism

Prism is a Laravel package for integrating Large Language Models (LLMs) into applications with a fluent, expressive and eloquent API.

Basic Usage Examples

Text Generation

use Prism\Prism\Facades\Prism;
use Prism\Prism\Enums\Provider;

$response = Prism::text()
    ->using(Provider::Anthropic, 'claude-3-5-sonnet-20241022')
    ->withSystemPrompt('You are an expert mathematician.')
    ->withPrompt('Explain the Pythagorean theorem.')
    ->asText();

echo $response->text;

Structured Output

use Prism\Prism\Facades\Prism;
use Prism\Prism\Enums\Provider;
use Prism\Prism\Schema\ObjectSchema;
use Prism\Prism\Schema\StringSchema;

$schema = new ObjectSchema(
    name: 'movie_review',
    description: 'A structured movie review',
    properties: [
        new StringSchema('title', 'The movie title'),
        new StringSchema('rating', 'Rating out of 5 stars'),
        new StringSchema('summary', 'Brief review summary')
    ],
    requiredFields: ['title', 'rating', 'summary']
);

$response = Prism::structured()
    ->using(Provider::OpenAI, 'gpt-4o')
    ->withSchema($schema)
    ->withPrompt('Review the movie Inception')
    ->asStructured();

$review = $response->structured;
echo $review['title'];

Streaming (Server-Sent Events)

Route::get('/chat', function () {
    return Prism::text()
        ->using('anthropic', 'claude-3-7-sonnet')
        ->withPrompt(request('message'))
        ->asEventStreamResponse();
});

Tools / Function Calling

use Prism\Prism\Facades\Prism;
use Prism\Prism\Tool;

$weatherTool = Tool::as('get_weather')
    ->for('Get current weather for a location')
    ->withStringParameter('location', 'The city and state')
    ->using(fn (string $location): string =>
        "Weather in {$location}: 72F, sunny"
    );

$response = Prism::text()
    ->using('anthropic', 'claude-3-5-sonnet-latest')
    ->withTools([$weatherTool])
    ->withMaxSteps(3)
    ->withPrompt('What is the weather in San Francisco?')
    ->asText();

Multi-Modal (Images/Documents)

use Prism\Prism\ValueObjects\Media\Image;
use Prism\Prism\ValueObjects\Media\Document;

$response = Prism::text()
    ->using(Provider::Anthropic, 'claude-3-5-sonnet-20241022')
    ->withPrompt(
        'What objects do you see in this image?',
        [Image::fromLocalPath('/path/to/image.jpg')]
    )
    ->asText();

Prism Documentation

IMPORTANT: Always search the docs before implementing Prism features.

How to Search

  1. Read a specific doc file directly:

    read vendor/prism-php/prism/docs/core-concepts/text-generation.md
    read vendor/prism-php/prism/docs/providers/openai.md
    
  2. Search for a topic across docs:

    grep "streaming" vendor/prism-php/prism/docs/
    grep "withProviderOptions" vendor/prism-php/prism/docs/providers/
    
  3. Find all doc files:

    glob "vendor/prism-php/prism/docs/**/*.md"
    

Documentation Paths

NeedRead This File
Text generationdocs/core-concepts/text-generation.md
Streaming responsesdocs/core-concepts/streaming-output.md
Tools / function callingdocs/core-concepts/tools-function-calling.md
Structured JSON outputdocs/core-concepts/structured-output.md
Embeddingsdocs/core-concepts/embeddings.md
Image generationdocs/core-concepts/image-generation.md
Audio (TTS/STT)docs/core-concepts/audio.md
Schema definitionsdocs/core-concepts/schemas.md
Testingdocs/core-concepts/testing.md
Image inputdocs/input-modalities/images.md
Document input (PDF)docs/input-modalities/documents.md
OpenAI optionsdocs/providers/openai.md
Anthropic optionsdocs/providers/anthropic.md
Other providersdocs/providers/{provider}.md
Error handlingdocs/advanced/error-handling.md

Source Code Reference

For implementation details:

glob "src/**/*.php"
grep "class Tool" src/

Key Patterns

  • Use Prism\Prism\Facades\Prism facade or prism() helper
  • Core methods: Prism::text(), Prism::structured(), Prism::embeddings(), Prism::image(), Prism::audio()
  • Chain ->using(Provider::Name, 'model-id') to specify provider/model
  • Finalize with: ->asText(), ->asStructured(), ->asStream(), ->asEventStreamResponse(), ->asDataStreamResponse()

Provider-Specific Options

Use ->withProviderOptions([...]) to pass provider-specific features:

$response = Prism::text()
    ->using('anthropic', 'claude-3-7-sonnet-latest')
    ->withPrompt('Your prompt')
    ->withProviderOptions(['thinking' => ['enabled' => true]])  // Anthropic-specific
    ->asText();

Always search the provider docs first to find available options for each provider:

  • docs/providers/openai.md - strict mode, reasoning, image generation options
  • docs/providers/anthropic.md - thinking mode, prompt caching, citations
  • docs/providers/gemini.md, docs/providers/mistral.md, etc.

Common Pitfalls

Wrong Package Name

NEVER use the old package: echolabsdev/prism is deprecated.

ALWAYS use: prism-php/prism

# Correct
composer require prism-php/prism

# Wrong - do not use
composer require echolabsdev/prism

Wrong Namespace

ALWAYS use the Prism\Prism namespace for all Prism classes:

// Correct
use Prism\Prism\Facades\Prism;
use Prism\Prism\Enums\Provider;
use Prism\Prism\Tool;
use Prism\Prism\Schema\ObjectSchema;

// Wrong - these namespaces do not exist
use EchoLabs\Prism\Prism;
use Prism\Facades\Prism;

Decision Workflow

When working with Prism, follow this pattern:

  1. Determine what you need:

    Text generation? → Use Prism::text() Structured JSON output? → Use Prism::structured() Embeddings? → Use Prism::embeddings() Image generation? → Use Prism::image() Audio (TTS/STT)? → Use Prism::audio()

  2. Always read the relevant docs first before implementing.

Related Packages

When not to use it

  • Using the deprecated echolabsdev/prism package
  • Using incorrect namespaces outside of Prism\Prism

Prerequisites

prism-php/prism composer package

Limitations

  • Requires specific provider-side documentation for advanced options
  • Must use the prism-php/prism package instead of deprecated versions

How it compares

It provides a consistent, expressive Laravel-native interface for LLM integration compared to manually managing individual provider SDKs.

Compared to similar skills

developing-with-prism side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
developing-with-prism (this skill)16moReviewIntermediate
laravel-specialist123moNo flagsIntermediate
developing-with-turbo-streams15moNo flagsIntermediate
payment-integration16moReviewIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

laravel-specialist

Jeffallan

Use when building Laravel 10+ applications requiring Eloquent ORM, API resources, or queue systems. Invoke for Laravel models, Livewire components, Sanctum authentication, Horizon queues.

1215

developing-with-turbo-streams

hotwired-laravel

Basics of developing with Turbo Streams in web applications. Activate when working on projects that utilize Turbo Streams for enhancing user experience through real-time updates, dynamic content changes, and partial page updates without full reloads.

15

payment-integration

mrgoonie

Integrate payments with SePay (VietQR), Polar, Stripe, Paddle (MoR subscriptions), Creem.io (licensing). Checkout, webhooks, subscriptions, QR codes, multi-provider orders.

13

laravel-query-builder

relaticle

Build filtered, sorted, and included API endpoints using spatie/laravel-query-builder. Activates when working with QueryBuilder, AllowedFilter, AllowedSort, AllowedInclude, or when the user mentions query parameters, API filtering, sorting, includes, or spatie/laravel-query-builder.

00

echo-development

WageFolabessy

Develops real-time broadcasting with Laravel Echo. Activates when setting up broadcasting (Reverb, Pusher, Ably); creating ShouldBroadcast events; defining broadcast channels (public, private, presence, encrypted); authorizing channels; configuring Echo; listening for events; implementing client eve

00

mcp-development

128na

Use this skill for Laravel MCP development only. Trigger when creating or editing MCP tools, resources, prompts, or servers in Laravel projects. Covers: artisan make:mcp-* generators, mcp:inspector, routes/ai.php, Tool/Resource/Prompt classes, schema validation, shouldRegister(), OAuth setup, URI te

00

Search skills

Search the agent skills registry