open source · v0.11.1 · php 8.3+ · framework agnostic
The AI SDK for PHP.
Build AI apps in Laravel, Symfony, or plain PHP with one framework-agnostic API for text, images, video, speech, transcription, Live voice, embeddings, tools, structured output, and streaming.
composer require aisdk/core aisdk/openai
status:
generating audio
›
// output is a simulated preview. Install the SDK and bring your own API keys to run it for real
See supported models and capabilities →01 / capabilities
Every modality. One mental model.
The same fluent builder pattern across the whole surface. Learn it once for text, use it for everything else.
-
01
Text generation
One fluent builder for prompts, instructions, conversation history, and generation settings across providers.
Generate::text()->prompt(...)->run()
-
02
Streaming
Stream text chunks without handling provider-specific stream formats.
foreach ($stream->chunks() as $chunk) { ... }
-
03
Image generation
Generate images with portable size and aspect-ratio controls, then save them anywhere.
Generate::image()->size('1024x1024')
-
04
Video generation
Create video with duration, resolution, and aspect-ratio control, including long-running jobs.
Generate::video()->duration(8)
-
05
Speech generation
Turn text into audio with voice and format options across supported providers.
Generate::speech()->voice('coral')
-
06
Transcription
Turn uploaded audio into text with language, segment, and timing information.
Generate::transcription($audio)->run()
-
07
Live Voice
Build full-duplex voice agents with audio, text, tools, and normalized events.
Live::voice()->model(...)->connect($transport)
-
08
Live Transcription
Receive streaming transcript deltas and revisions from supported providers.
Live::transcribe()->model(...)->connect($transport)
-
09
Live Translation
Translate spoken audio in a stateful session with text and audio events.
Live::translate()->model(...)->connect($transport)
-
10
Embeddings
Create vectors for semantic search, retrieval, classification, and recommendations.
Generate::embedding([...])->run()
-
11
Tool calling
Define typed tools and handlers. The SDK runs the call, execute, and response loop.
->tool($weather)->maxSteps(4)
-
12
Structured output
Describe a schema and receive validated data instead of parsing model prose.
->output(Schema::object(...))
-
13
Provider options
Use provider-specific parameters when you need them without leaving the unified API.
->providerOptions('openai', [...])
02 / why php ai sdk
Built for the PHP ecosystem, not ported to it.
Framework agnostic
Works in Laravel, Symfony, Slim, or a plain PHP script. No service container required.
One API across providers
Switch models or providers by changing one line while keeping prompts, tools, and app logic intact.
Multimodal by design
Text, images, video, speech, transcription, live audio, and embeddings share one clear mental model.
Streaming built in
Iterate over text chunks with foreach while the SDK handles provider stream formats.
Tools & structured output
Build agents and typed workflows with schema-validated results and automatic tool execution.
PSR-friendly
PSR-7/17/18 HTTP under the hood, PSR-3 logging, and clean interfaces for the PHP ecosystem.
03 / providers
Swap providers. Keep your code.
Each provider ships as its own Composer package on top of aisdk/core. Install only what you use.
- OpenAI
- Anthropic
- Groq
- xAI
- Azure
- Amazon Bedrock
- DeepSeek
- fal
- Google Cloud Agent Platform
- Ollama
- OpenRouter
- Voyage AI
- ElevenLabs
- Alibaba
- ByteDance
- Kling AI
- Meta
- Mistral
- Moonshot AI
- Perplexity
- Replicate
- Together AI
- + more on the way
- ->model(OpenAI::model('gpt-4o'))
+ ->model(Anthropic::model('claude-sonnet-5-5'))
04 / in practice
Ten lines or fewer, most of the time.
Real PHP, no framework required. The same builder runs in Laravel, Symfony, Slim, or a bare script.
Browse every example in the docsuse AiSdk\Generate;use AiSdk\OpenAI;$result = Generate::text() ->model(OpenAI::model('gpt-4o')) ->instructions('Write short, clear answers.') ->prompt('Explain closures in PHP.') ->run();echo $result->text;use AiSdk\Generate;use AiSdk\Anthropic;$stream = Generate::text('Draft release notes for v2.4.0.') ->model(Anthropic::model('claude-sonnet-4-6')) ->stream();foreach ($stream->chunks() as $chunk) { echo $chunk; flush();}use AiSdk\Generate;use AiSdk\OpenAI;use AiSdk\Schema;$result = Generate::text('Analyse: "Fast shipping, packaging was meh."') ->model(OpenAI::model('gpt-4o')) ->output(Schema::object('review', properties: [ Schema::enum(['positive', 'neutral', 'negative'], 'sentiment')->required(), Schema::array(Schema::string(), 'topics')->required(), ])) ->run();$review = $result->output;use AiSdk\Generate;use AiSdk\Anthropic;use AiSdk\Schema;use AiSdk\Tool;$weather = Tool::make('weather', 'Get current weather') ->input(Schema::string('city')->required()) ->run(fn (string $city): string => Weather::lookup($city));$result = Generate::text('Should I bike to work in Amsterdam today?') ->model(Anthropic::model('claude-sonnet-4-6')) ->tool($weather)->maxSteps(4)->run();
05 / availability
What are you building?
Pick what you need. We'll show the provider packages that cover all of it.
Open any provider to see everything it supports. ◐ means supported through an adaptation. Providers that support
-
Text Streaming Structured output Tools Image Speech Transcription Embeddings Live voice Live transcription Live translation
Text · Streaming · Structured output · Tools · Image · Speech · Transcription · Embeddings · Live voice · Live transcription · Live translation
-
Text Streaming Structured output ◐ Tools
Text · Streaming · Structured output ◐ · Tools
-
Text Streaming Structured output ◐ Tools Speech Transcription Embeddings
Text · Streaming · Structured output ◐ · Tools · Speech · Transcription · Embeddings
-
Text Streaming Structured output Tools Image Speech Transcription Video Embeddings Live voice Live transcription
Text · Streaming · Structured output · Tools · Image · Speech · Transcription · Video · Embeddings · Live voice · Live transcription
-
Text Streaming Structured output Tools Image Speech Transcription Embeddings Live voice Live transcription Live translation
Text · Streaming · Structured output · Tools · Image · Speech · Transcription · Embeddings · Live voice · Live transcription · Live translation
-
Text Streaming Structured output Tools Image Video Embeddings Live voice
Text · Streaming · Structured output · Tools · Image · Video · Embeddings · Live voice
-
Text Streaming Structured output ◐ Tools
Text · Streaming · Structured output ◐ · Tools
-
Image Speech Transcription Video
Image · Speech · Transcription · Video
-
Text Streaming Structured output Tools Image Speech Transcription Video Embeddings Live voice Live translation
Text · Streaming · Structured output · Tools · Image · Speech · Transcription · Video · Embeddings · Live voice · Live translation
-
Text Streaming Structured output Tools Image Speech Transcription Video Embeddings Live voice
Text · Streaming · Structured output · Tools · Image · Speech · Transcription · Video · Embeddings · Live voice
-
Text Streaming Structured output Tools Image Embeddings
Text · Streaming · Structured output · Tools · Image · Embeddings
-
Text Streaming Structured output Tools Image Speech Transcription Video Embeddings
Text · Streaming · Structured output · Tools · Image · Speech · Transcription · Video · Embeddings
-
Embeddings
Embeddings
-
Speech Transcription Live transcription
Speech · Transcription · Live transcription
-
Text Streaming Structured output Tools Image Speech Video Embeddings
Text · Streaming · Structured output · Tools · Image · Speech · Video · Embeddings
-
Text Streaming Structured output Tools Image Video Embeddings
Text · Streaming · Structured output · Tools · Image · Video · Embeddings
-
Image Speech Video
Image · Speech · Video
-
Text Streaming Structured output Tools
Text · Streaming · Structured output · Tools
-
Text Streaming Structured output ◐ Tools Embeddings
Text · Streaming · Structured output ◐ · Tools · Embeddings
-
Text Streaming Structured output ◐ Tools
Text · Streaming · Structured output ◐ · Tools
-
Text Streaming Structured output ◐ Tools
Text · Streaming · Structured output ◐ · Tools
-
Image Video
Image · Video
-
Text Streaming Structured output ◐ Tools
Text · Streaming · Structured output ◐ · Tools
No single package covers all of that yet. Try removing a filter.
Model-level details live in the docs06 / sponsors
Open source, kept moving by people like you.
Sponsorship keeps PHP AI SDK moving: provider maintenance, new capabilities, documentation, testing, and dependable releases.
Become a sponsorBuild AI in PHP.
Build AI apps in PHP without rewriting your provider layer.
composer require aisdk/core aisdk/openai