Skip to content
Development
Skill

/developing-with-prism

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

From plugin
prism
2.4k1 skill

Claude Code

$ npx -y skills add prism-php/prism --skill developing-with-prism --agent claude-code

SKILL.md

developing-with-prism.SKILL.md
name: developing-with-prism
description: 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.

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-sonnet-5-5')
    ->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-6.1-sol')
    ->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-sonnet-5-5')
        ->withPrompt(request('message'))
        ->asEventStreamResponse();
});

Tools / Function Calling

use Prism\Prism\Facades\Prism;
use Prism\Prism\Facades\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-sonnet-5-5')
    ->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-sonnet-5-5')
    ->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

| Need | Read This File | |------|----------------| | Text generation | `docs/core-concepts/text-generation.md` | | Streaming responses | `docs/core-concepts/streaming-output.md` | | Tools / function calling | `docs/core-concepts/tools-function-calling.md` | | Structured JSON output | `docs/core-concepts/structured-output.md` | | Embeddings | `docs/core-concepts/embeddings.md` | | Image generation | `docs/core-concepts/image-generation.md` | | Audio (TTS/STT) | `docs/core-concepts/audio.md` | | Schema definitions | `docs/core-concepts/schemas.md` | | Testing | `docs/core-concepts/testing.md` | | Image input | `docs/input-modalities/images.md` | | Document input (PDF) | `docs/input-modalities/documents.md` | | OpenAI options | `docs/providers/openai.md` | | Anthropic options | `docs/providers/anthropic.md` | | Other providers | `docs/providers/{provider}.md` | | Error handling | `docs/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-opus-5-5')
    ->withPrompt('Your prompt')
    ->withProviderOptions([  // Anthropic-specific
        'thinking' => ['type' => 'adaptive'],
        'effort' => 'high',
    ])
    ->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

Continuing Conversations

Pass `$response->messages` back with `withMessages()` to continue a conversation, and persist each message's `additionalContent` when storing it. Rebuilding `AssistantMessage`s from `$response->text` drops the thinking blocks and reasoning items that current Claude and OpenAI models expect back. For streamed responses, build the messages with `StreamedMessa

Read more
Stats
2,430
Stars
316
Forks
Active
Maintenance
PHP
Language
MIT
License
Last commit
Created

Repo: prism-php/prism

@prism-php
Ships withprism

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.

Stars on GitHub

Momentum

stars in total
2.4k
Star history of prism-php/prism on GitHub, a chart by star-history.com

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills13d309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc2w293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react4d252k
@facebook@facebookInstall Skill

Questions about developing-with-prism.

Which coding agents can use developing-with-prism?
developing-with-prism installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.