{"slug": "stop-juggling-ai-sdks-in-php-meet-prisma", "title": "Stop juggling AI SDKs in PHP — meet Prisma", "summary": "Prisma is a lightweight, MIT-licensed PHP package (version 0.4) that provides a unified API for integrating over 25 AI providers across text, image, audio, and video domains, eliminating the need for multiple separate SDKs. It uses a consistent fluent interface—`Prisma::{domain}()->using(provider, config)->{method}()`—allowing developers to switch providers by changing a single string, and supports features like structured output, tool calling, and runtime capability checks. The package requires PHP 8.2+ and relies on Guzzle under the hood, with no framework coupling.", "body_md": "If you've ever integrated an AI provider into a PHP application, you know the drill. You pull in the OpenAI SDK. Then the client wants image generation, so you add StabilityAI — different SDK, different request format, different error handling. Then they want audio transcription — enter Deepgram, yet another integration. Before you know it, you're maintaining three separate API integrations, each with their own quirks, response formats, and retry logic.\nPrisma fixes this. One package. One API. 25+ providers. Text, image, audio, and video.\ncomposer require aimeos/prisma\nPrisma is a light-weight, MIT-licensed PHP package that provides a unified interface for working with AI providers across four media domains. No framework coupling. Just Guzzle under the hood, PHP 8.2+, and a clean fluent API.\nHere's the core idea — every provider works through the same interface:\nuse Aimeos\\Prisma\\Prisma;\n// Generate text with OpenAI\n$text = Prisma::text()\n->using('openai', ['api_key' => '...'])\n->write('Summarize the benefits of renewable energy')\n->text();\n// Generate an image with StabilityAI\n$image = Prisma::image()\n->using('stabilityai', ['api_key' => '...'])\n->imagine('a mountain landscape at sunset')\n->binary();\n// Transcribe audio with Deepgram\n$transcript = Prisma::audio()\n->using('deepgram', ['api_key' => '...'])\n->transcribe($audioFile)\n->text();\n// Describe a video with Gemini\n$description = Prisma::video()\n->using('gemini', ['api_key' => '...'])\n->describe($videoFile)\n->text();\nSame pattern everywhere: Prisma::{domain}()->using(provider, config)->{method}()\n. Switch providers by changing a single string. Your application code stays the same.\nImagine you're building a product listing tool. You need to:\nWithout Prisma, that's three different SDK integrations. With Prisma:\nuse Aimeos\\Prisma\\Prisma;\nuse Aimeos\\Prisma\\Schema\\Schema;\n// 1. Describe a product image\n$description = Prisma::image()\n->using('openai', ['api_key' => '...'])\n->describe($productPhoto)\n->text();\n// 2. Extract structured data\n$schema = Schema::for('product', [\n'name' => Schema::string()->required(),\n'price' => Schema::number(),\n'category' => Schema::string()->enum(['electronics', 'clothing', 'food', 'other']),\n]);\n$product = Prisma::text()\n->using('gemini', ['api_key' => '...'])\n->structured(\"Extract product info from: {$description}\", $schema)\n->structured();\n// ['name' => 'Wireless Headphones', 'price' => 79.99, 'category' => 'electronics']\n// 3. Generate a product image\n$image = Prisma::image()\n->using('stabilityai', ['api_key' => '...'])\n->imagine(\"Professional illustration of {$product['name']}\")\n->binary();\nThree providers, three media types, one consistent API. And if tomorrow you want to swap Gemini for Anthropic, you change one line.\nYou can also check provider capabilities at runtime:\n$provider = Prisma::image()->using('clipdrop', ['api_key' => '...']);\nif ($provider->has('upscale')) {\n$image = $provider->upscale($lowResImage)->binary();\n}\n// Or throw if the capability is missing\n$provider->ensure('upscale'); // throws NotImplementedException if not supported\nVersion 0.4 is a major release that adds text generation, structured output, tool calling, and a lot more. Here's what landed.\nThe write()\nmethod brings text generation to Prisma with support for OpenAI, Anthropic, Gemini, Bedrock, Mistral, Groq, Cohere, Deepseek, Alibaba, xAI, Perplexity, OpenRouter, Ollama, and Deepseek. All multimodal — pass images, audio, or documents alongside your prompt:\nuse Aimeos\\Prisma\\Base\\File;\n$response = Prisma::text()\n->using('anthropic', ['api_key' => '...'])\n->withSystemPrompt('You are a helpful assistant')\n->write('Describe this image', [File::from('photo.jpg')]);\necho $response->text();\nGet typed JSON responses from LLMs using a fluent Schema builder. Prisma uses each provider's native structured output API — no prompt engineering hacks:\nuse Aimeos\\Prisma\\Schema\\Schema;\n$schema = Schema::for('event', [\n'title' => Schema::string()->required(),\n'date' => Schema::string()->format('date')->required(),\n'attendees' => Schema::array()->items(Schema::string()),\n'location' => Schema::object([\n'city' => Schema::string()->required(),\n'country' => Schema::string(),\n]),\n]);\n$response = Prisma::text()\n->using('openai', ['api_key' => '...'])\n->structured('Parse: Team meetup on June 15 in Berlin with Alice and Bob', $schema);\n$event = $response->structured();\n// [\n// 'title' => 'Team meetup',\n// 'date' => '2026-06-15',\n// 'attendees' => ['Alice', 'Bob'],\n// 'location' => ['city' => 'Berlin', 'country' => 'Germany'],\n// ]\nThe Schema builder supports strings, integers, numbers, booleans, arrays, objects, enums (including PHP BackedEnum\n), nested objects, required()\n, nullable()\n, min()\n/max()\n, regex pattern()\n, and more. You can also pass raw JSON Schema arrays via Schema::fromArray()\n.\nThis is where things get interesting. Prisma supports full agentic tool calling with an automatic execution loop. You define tools, the model calls them, Prisma executes the handlers and feeds results back — all automatically:\nuse Aimeos\\Prisma\\Tools;\nuse Aimeos\\Prisma\\Schema\\Schema;\n$searchTool = Tools::make(\n'search_products',\n'Search the product database',\nSchema::for('search', [\n'query' => Schema::string()->description('Search query')->required(),\n'limit' => Schema::integer()->description('Max results')->min(1)->max(50),\n]),\nfunction(array $args): string {\n$results = ProductSearch::query($args['query'], $args['limit'] ?? 10);\nreturn json_encode($results);\n}\n);\n$response = Prisma::text()\n->using('openai', ['api_key' => '...'])\n->withTools([$searchTool])\n->withMaxSteps(5)\n->write('Find me the top 3 wireless headphones under $100');\necho $response->text();\n// The model searched, got results, and wrote a summary\nYou can inspect what happened during the tool loop:\nforeach ($response->steps() as $step) {\necho $step->name(); // 'search_products'\necho $step->arguments(); // ['query' => 'wireless headphones', 'limit' => 3]\necho $step->result(); // '[ ... search results ... ]'\n}\nTools also support:\nTools::make(...)->max(3)\n— the tool can only be called 3 times->failed(fn($e, $args) => 'Fallback message')\n— catch exceptions gracefully->concurrent()\n— tools run in parallel via pcntl_fork\n->withToolChoice(Provider::REQ)\nto force tool useSome providers offer built-in server-side tools like web search and code execution. Prisma normalizes these too:\nuse Aimeos\\Prisma\\Tools;\n$response = Prisma::text()\n->using('anthropic', ['api_key' => '...'])\n->withTools([\nTools::provider('web_search'),\nTools::provider('code_execution'),\n])\n->write('Search for the latest PHP version and verify it');\nAvailable provider tools include web_search\n, code_execution\n, file_search\n, web_fetch\n, image_generation\n, and document_library\n— each mapped to the providers that support them. You can mix custom and provider tools in the same request.\nAlready have tools built for Laravel AI or Symfony? Reuse them directly:\n// Laravel AI / Prism tools\n$tool = Tools::laravel(new MyLaravelTool());\n// Symfony #[AsTool] classes\n$tool = Tools::symfony(MySymfonyTool::class);\nEnable extended reasoning for models that support it. Prisma automatically maps token counts to each provider's native format:\n$response = Prisma::text()\n->using('anthropic', ['api_key' => '...'])\n->withThinkingBudget(5000)\n->withMaxTokens(4096)\n->write('Solve this step by step: ...');\n// Access the model's reasoning\n$thinking = $response->meta()['thinking'] ?? null;\nNormalized citation objects across providers that support them (Anthropic, OpenAI, Gemini, Perplexity, xAI):\nforeach ($response->citations() as $citation) {\n$citation->title(); // source title\n$citation->url(); // source URL\n$citation->text(); // output text that cites this source\n$citation->source(); // verbatim quote from the source\n}\n// Automatic retry with exponential backoff\n$response = Prisma::text()\n->using('openai', ['api_key' => '...'])\n->withClientRetry(3, fn($attempt, $resp) => 100 * pow(2, $attempt))\n->write('...');\n// Inspect rate limit headers\n$limit = $response->rateLimit();\n$limit->remaining(); // requests left\n$limit->retryAfter(); // seconds until reset\nHere's what's supported for text providers in 0.4:\nAnd that's just text. Prisma also covers 9 audio providers (speak, transcribe, demix, denoise, revoice, describe), 14 image providers (imagine, inpaint, upscale, vectorize, background, erase, and more), and video description via Gemini.\ncomposer require aimeos/prisma\nMinimal example:\n<?php\nuse Aimeos\\Prisma\\Prisma;\n// Text\necho Prisma::text()\n->using('openai', ['api_key' => getenv('OPENAI_API_KEY')])\n->write('What makes PHP great?')\n->text();\n// Image\n$binary = Prisma::image()\n->using('openai', ['api_key' => getenv('OPENAI_API_KEY')])\n->imagine('a PHP elephant wearing sunglasses')\n->binary();\nfile_put_contents('elephant.png', $binary);\nNo service providers, no config files, no framework dependencies. Just require and use.\nPrisma is MIT-licensed and open source. Check it out:\nIf you've been looking for a unified way to work with AI providers in PHP — especially beyond just text — give it a try. Feedback, issues, and stars are all welcome.\nIn case you like Prisma, leave a star in the Github repo :-)", "url": "https://wpnews.pro/news/stop-juggling-ai-sdks-in-php-meet-prisma", "canonical_source": "https://dev.to/aimeos/stop-juggling-ai-sdks-in-php-meet-prisma-4b2", "published_at": "2026-05-22 12:00:17+00:00", "updated_at": "2026-05-22 12:09:21.677351+00:00", "lang": "en", "topics": ["developer-tools", "artificial-intelligence", "open-source", "products"], "entities": ["Prisma", "OpenAI", "StabilityAI", "Deepgram", "Gemini", "Aimeos", "Guzzle", "PHP"], "alternates": {"html": "https://wpnews.pro/news/stop-juggling-ai-sdks-in-php-meet-prisma", "markdown": "https://wpnews.pro/news/stop-juggling-ai-sdks-in-php-meet-prisma.md", "text": "https://wpnews.pro/news/stop-juggling-ai-sdks-in-php-meet-prisma.txt", "jsonld": "https://wpnews.pro/news/stop-juggling-ai-sdks-in-php-meet-prisma.jsonld"}}