인셔셔RSS 관심 있는 블로그, 뉴스, 기술 정보를 효율적으로 추적하고 읽으세요
원문 읽기 InertiaRSS에서 열기

추천 피드

V
V2EX
博客园 - 叶小钗
Y
Y Combinator Blog
大猫的无限游戏
大猫的无限游戏
博客园 - 【当耐特】
酷 壳 – CoolShell
酷 壳 – CoolShell
D
Docker
WordPress大学
WordPress大学
Blog — PlanetScale
Blog — PlanetScale
博客园 - Franky
G
Google Developers Blog
爱范儿
爱范儿
Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
aimingoo的专栏
aimingoo的专栏
V
Visual Studio Blog
M
MIT News - Artificial intelligence
Hugging Face - Blog
Hugging Face - Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python)
PHP에서 AI SDK를 놓치지 마라 — Prisma를 만나보세요
Aimeos · 2026-05-22 · via DEV Community

PHP 애플리케이션에 AI 제공자를 통합해 본 적이 있다면, 과정을 알고 있습니다. OpenAI SDK를 가져옵니다. 그런 다음 클라이언트가 이미지 생성을 원하므로 StabilityAI를 추가합니다 — 다른 SDK, 다른 요청 형식, 다른 오류 처리. 그런 다음 오디오 녹음을 원합니다 — Deepgram을 입력하면 또 다른 통합이 필요합니다. 이전에 알지 못했을 때, 세 가지 개별 API 통합을 유지하고 있으며, 각각 고유한 특징, 응답 형식, 재시도 논리가 있습니다.

Prisma는 이를 해결합니다. 하나의 패키지. 하나의 API. 25개 이상의 제공자. 텍스트, 이미지, 오디오, 비디오.

composer require aimeos/prisma

전체 화면 모드 입력 전체 화면 모드 종료

Prisma는 무엇인가요?

Prisma는 경량의 MIT 라이선스를 가진 PHP 패키지로, 네 가지 미디어 도메인에 걸쳐 AI 제공자와 작업하기 위한 통일된 인터페이스를 제공합니다. 프레임워크 결합 없이, 하드웨어에 Guzzle가 있으며, PHP 8.2+와 깨끗한 fluently API입니다.

핵심 아이디어는 모든 제공자가 동일한 인터페이스를 통해 작동한다는 것입니다.

use Aimeos\Prisma\Prisma;

// Generate text with OpenAI
$text = Prisma::text()
    ->using('openai', ['api_key' => '...'])
    ->write('Summarize the benefits of renewable energy')
    ->text();

// Generate an image with StabilityAI
$image = Prisma::image()
    ->using('stabilityai', ['api_key' => '...'])
    ->imagine('a mountain landscape at sunset')
    ->binary();

// Transcribe audio with Deepgram
$transcript = Prisma::audio()
    ->using('deepgram', ['api_key' => '...'])
    ->transcribe($audioFile)
    ->text();

// Describe a video with Gemini
$description = Prisma::video()
    ->using('gemini', ['api_key' => '...'])
    ->describe($videoFile)
    ->text();

전체 화면 모드로 입력하세요. 전체 화면 모드를 종료하세요.

모든 곳에서 동일한 패턴입니다.Prisma::{domain}()->using(provider, config)->{method}(). 단일 문자열을 변경하여 공급자를 전환합니다. 애플리케이션 코드는 동일하게 유지됩니다.

실제로 이것이 왜 중요한가요

제품 목록 도구를 만들고 있다고 상상해보세요. 다음을 수행해야 합니다.

  1. 이미지에서 제품 설명을 생성합니다.
  2. 제품 설명에서 구조화된 데이터(이름, 가격, 카테고리)를 추출합니다.
  3. 결측된 마케팅 이미지를 생성합니다.

Prisma가 없다면, 세 가지 다른 SDK 통합이 필요합니다. Prisma가 있다면:

use Aimeos\Prisma\Prisma;
use Aimeos\Prisma\Schema\Schema;

// 1. Describe a product image
$description = Prisma::image()
    ->using('openai', ['api_key' => '...'])
    ->describe($productPhoto)
    ->text();

// 2. Extract structured data
$schema = Schema::for('product', [
    'name' => Schema::string()->required(),
    'price' => Schema::number(),
    'category' => Schema::string()->enum(['electronics', 'clothing', 'food', 'other']),
]);

$product = Prisma::text()
    ->using('gemini', ['api_key' => '...'])
    ->structured("Extract product info from: {$description}", $schema)
    ->structured();
// ['name' => 'Wireless Headphones', 'price' => 79.99, 'category' => 'electronics']

// 3. Generate a product image
$image = Prisma::image()
    ->using('stabilityai', ['api_key' => '...'])
    ->imagine("Professional illustration of {$product['name']}")
    ->binary();

전체 화면 모드를 입력하세요 전체 화면 모드를 종료하세요

세 제공자, 세 미디어 유형, 일관된 API. 그리고 내일 당신이 Gemini를 Anthropic으로 바꾸고 싶다면, 한 줄만 변경하면 됩니다.

또한 실행 시 제공자 기능을 확인할 수 있습니다:

$provider = Prisma::image()->using('clipdrop', ['api_key' => '...']);

if ($provider->has('upscale')) {
    $image = $provider->upscale($lowResImage)->binary();
}

// Or throw if the capability is missing
$provider->ensure('upscale'); // throws NotImplementedException if not supported

전체 화면 모드를 입력하세요 전체 화면 모드 종료

0.4 버전에서 새로운 기능은 무엇인가요

버전 0.4는 텍스트 생성, 구조화된 출력, 도구 호출 등을 추가하는 주요 릴리스입니다. 여기서는 어떤 기능이 추가되었는지 소개합니다.

14개의 제공자 간의 텍스트 생성

Thewrite() 메소드는 OpenAI, Anthropic, Gemini, Bedrock, Mistral, Groq, Cohere, Deepseek, Alibaba, xAI, Perplexity, OpenRouter, Ollama, 및 Deepseek을 지원하여 Prisma에 텍스트 생성을 가져옵니다. 모든 멀티모달 — 이미지, 오디오, 또는 문서를 프롬프트와 함께 전달하세요:

use Aimeos\Prisma\Base\File;

$response = Prisma::text()
    ->using('anthropic', ['api_key' => '...'])
    ->withSystemPrompt('You are a helpful assistant')
    ->write('Describe this image', [File::from('photo.jpg')]);

echo $response->text();

전체 화면 모드 전체 화면 모드 종료

구조화된 출력

LLM에서 유연한 스키마 빌더를 사용하여 타이핑된 JSON 응답을 얻으세요. Prisma는 각 제공자의 자연스러운 구조화된 출력 API를 사용합니다 — 프롬프트 엔지니어링 해킹은 없습니다:

use Aimeos\Prisma\Schema\Schema;

$schema = Schema::for('event', [
    'title' => Schema::string()->required(),
    'date' => Schema::string()->format('date')->required(),
    'attendees' => Schema::array()->items(Schema::string()),
    'location' => Schema::object([
        'city' => Schema::string()->required(),
        'country' => Schema::string(),
    ]),
]);

$response = Prisma::text()
    ->using('openai', ['api_key' => '...'])
    ->structured('Parse: Team meetup on June 15 in Berlin with Alice and Bob', $schema);

$event = $response->structured();
// [
//     'title' => 'Team meetup',
//     'date' => '2026-06-15',
//     'attendees' => ['Alice', 'Bob'],
//     'location' => ['city' => 'Berlin', 'country' => 'Germany'],
// ]

전체 화면 모드 입력 전체 화면 모드 종료

스키마 빌더는 문자열, 정수, 숫자, 불리언, 배열, 객체, 열거형(PHP BackedEnum 포함), 중첩 객체를 지원합니다required(), nullable(), min()/max(), 정규식 pattern(), 그리고 더 많은 것들. 원시 JSON 스키마 배열도 Schema::fromArray()를 통해 전달할 수 있습니다.

도구 호출 및 자동 실행

여기서부터는 흥미로운 일이 시작됩니다. Prisma는 자동 실행 루프와 함께 전체 에ージ엔트 도구 호출을 지원합니다. 도구를 정의하고, 모델이 그들을 호출하면, Prisma는 핸들러를 실행하고 결과를 피드백으로 보내 — 모두 자동으로:

use Aimeos\Prisma\Tools;
use Aimeos\Prisma\Schema\Schema;

$searchTool = Tools::make(
    'search_products',
    'Search the product database',
    Schema::for('search', [
        'query' => Schema::string()->description('Search query')->required(),
        'limit' => Schema::integer()->description('Max results')->min(1)->max(50),
    ]),
    function(array $args): string {
        $results = ProductSearch::query($args['query'], $args['limit'] ?? 10);
        return json_encode($results);
    }
);

$response = Prisma::text()
    ->using('openai', ['api_key' => '...'])
    ->withTools([$searchTool])
    ->withMaxSteps(5)
    ->write('Find me the top 3 wireless headphones under $100');

echo $response->text();
// The model searched, got results, and wrote a summary

전체 화면 모드로 진입 전체 화면 모드 종료

도구 루프期间에 무엇이 일어났는지 확인할 수 있습니다:

foreach ($response->steps() as $step) {
    echo $step->name();      // 'search_products'
    echo $step->arguments(); // ['query' => 'wireless headphones', 'limit' => 3]
    echo $step->result();    // '[ ... search results ... ]'
}

전체 화면 모드로 진입 전체 화면 모드 종료

도구도 지원합니다:

  • 각 도구별 호출 제한: Tools::make(...)->max(3) — 도구는 3회만 호출할 수 있습니다
  • 사용자 지정 오류 처리기: ->failed(fn($e, $args) => 'Fallback message') — 예외를 부드럽게 처리합니다
  • 동시 실행: ->concurrent() — 도구가 병렬로 실행됩니다pcntl_fork
  • 데코레이터는 로깅, 캐싱, 또는 어떤 고유한 동작과 함께 도구를 감싸십니다
  • 도구 선택->withToolChoice(Provider::REQ)를 강제로 사용하도록 합니다

제공자 도구

일부 제공자는 웹 검색 및 코드 실행과 같은 서버 측 도구를 제공합니다. Prisma는 이러한 것들도 정규화합니다

use Aimeos\Prisma\Tools;

$response = Prisma::text()
    ->using('anthropic', ['api_key' => '...'])
    ->withTools([
        Tools::provider('web_search'),
        Tools::provider('code_execution'),
    ])
    ->write('Search for the latest PHP version and verify it');

전체 화면 모드 입력 전체 화면 모드 종료

사용 가능한 제공자 도구는 web_search, code_execution, file_search, web_fetch, image_generation, 그리고 document_library로 구성되어 있으며, 각각은 해당을 지원하는 제공자에 매핑됩니다. 당신은 동일한 요청에서 맞춤형 도구와 제공자 도구를 혼합할 수 있습니다.

프레임워크 도구 어댑터

Laravel AI 또는 Symfony용 도구가 이미 있나요? 직접 재사용하세요:

// Laravel AI / Prism tools
$tool = Tools::laravel(new MyLaravelTool());

// Symfony #[AsTool] classes
$tool = Tools::symfony(MySymfonyTool::class);

전체 화면 모드로 전환 전체 화면 모드 종료

예산 생각하기

지원하는 모델에 확장된 추론을 활성화합니다. Prisma는 토큰 수를 각 제공업체의 네이티브 형식으로 자동으로 매핑합니다.

$response = Prisma::text()
    ->using('anthropic', ['api_key' => '...'])
    ->withThinkingBudget(5000)
    ->withMaxTokens(4096)
    ->write('Solve this step by step: ...');

// Access the model's reasoning
$thinking = $response->meta()['thinking'] ?? null;

전체 화면 모드로 전환 전체 화면 모드 종료

인용

Anthropic, OpenAI, Gemini, Perplexity, xAI을 지원하는 제공자 간의 정규화된 인용 개체:

foreach ($response->citations() as $citation) {
    $citation->title();  // source title
    $citation->url();    // source URL
    $citation->text();   // output text that cites this source
    $citation->source(); // verbatim quote from the source
}

전체 화면 모드를 입력하세요 전체 화면 모드를 종료하세요

요청 제한 및 재시도 처리

// Automatic retry with exponential backoff
$response = Prisma::text()
    ->using('openai', ['api_key' => '...'])
    ->withClientRetry(3, fn($attempt, $resp) => 100 * pow(2, $attempt))
    ->write('...');

// Inspect rate limit headers
$limit = $response->rateLimit();
$limit->remaining();  // requests left
$limit->retryAfter(); // seconds until reset

전체 화면 모드를 입력하세요 전체 화면 모드를 종료하세요

제공자 범위

0.4에서 텍스트 제공자에 대해 지원되는 내용은 다음과 같습니다:

Provider 구조화 번역 쓰기 참조 커스텀 도구 Provider 도구 생각 예산
Alibaba - -
Anthropic
Bedrock -
Cohere - -
Deepseek - -
DeepL
Gemini
Google
Groq - -
Mistral - -
Ollama 베타 베타 - -
OpenAI
Openrouter - -
Perplexity 베타 베타 -
xAI 베타 베타

그것도 텍스트일 뿐입니다. Prisma는 9 오디오 제공자 (speak, transcribe, demix, denoise, revoice, describe), 14 이미지 제공자 (imagine, inpaint, upscale, vectorize, background, erase, 그리고 더 많은 것들), 그리고 Gemini를 통해 비디오 설명을 제공합니다.

시작하기

composer require aimeos/prisma

전체 화면 모드 입력 전체 화면 모드 종료

최소 예제:

<?php

use Aimeos\Prisma\Prisma;

// Text
echo Prisma::text()
    ->using('openai', ['api_key' => getenv('OPENAI_API_KEY')])
    ->write('What makes PHP great?')
    ->text();

// Image
$binary = Prisma::image()
    ->using('openai', ['api_key' => getenv('OPENAI_API_KEY')])
    ->imagine('a PHP elephant wearing sunglasses')
    ->binary();

file_put_contents('elephant.png', $binary);

전체 화면 모드 입력 전체 화면 모드 종료

서비스 제공자가 없고, 구성 파일이 없으며, 프레임워크 종속성이 없습니다. 단지 필요한 것을 가져와 사용하세요.


Prisma는 MIT 라이선스로 개방 소스입니다. 더 알아보세요:

PHP에서 AI 제공자와 통합된 방법을 찾고 계신다면 — 특히 텍스트 외의 것까지 — 시도해 보세요. 피드백, 문제, 그리고 별은 모두 환영합니다.

Prisma를 좋아하신다면, Github 저장소에 별을 남겨주세요 :-)