Skip to content

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
output simulated preview

status:

clip.mp4 · 00:08

generating audio

status.mp3

 

// 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.

  1. 01

    Text generation

    One fluent builder for prompts, instructions, conversation history, and generation settings across providers.

    Generate::text()->prompt(...)->run()

  2. 02

    Streaming

    Stream text chunks without handling provider-specific stream formats.

    foreach ($stream->chunks() as $chunk) { ... }

  3. 03

    Image generation

    Generate images with portable size and aspect-ratio controls, then save them anywhere.

    Generate::image()->size('1024x1024')

  4. 04

    Video generation

    Create video with duration, resolution, and aspect-ratio control, including long-running jobs.

    Generate::video()->duration(8)

  5. 05

    Speech generation

    Turn text into audio with voice and format options across supported providers.

    Generate::speech()->voice('coral')

  6. 06

    Transcription

    Turn uploaded audio into text with language, segment, and timing information.

    Generate::transcription($audio)->run()

  7. 07

    Live Voice

    Build full-duplex voice agents with audio, text, tools, and normalized events.

    Live::voice()->model(...)->connect($transport)

  8. 08

    Live Transcription

    Receive streaming transcript deltas and revisions from supported providers.

    Live::transcribe()->model(...)->connect($transport)

  9. 09

    Live Translation

    Translate spoken audio in a stateful session with text and audio events.

    Live::translate()->model(...)->connect($transport)

  10. 10

    Embeddings

    Create vectors for semantic search, retrieval, classification, and recommendations.

    Generate::embedding([...])->run()

  11. 11

    Tool calling

    Define typed tools and handlers. The SDK runs the call, execute, and response loop.

    ->tool($weather)->maxSteps(4)

  12. 12

    Structured output

    Describe a schema and receive validated data instead of parsing model prose.

    ->output(Schema::object(...))

  13. 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.

01

Framework agnostic

Works in Laravel, Symfony, Slim, or a plain PHP script. No service container required.

02

One API across providers

Switch models or providers by changing one line while keeping prompts, tools, and app logic intact.

03

Multimodal by design

Text, images, video, speech, transcription, live audio, and embeddings share one clear mental model.

04

Streaming built in

Iterate over text chunks with foreach while the SDK handles provider stream formats.

05

Tools & structured output

Build agents and typed workflows with schema-validated results and automatic tool execution.

06

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.

- ->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 docs
use 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;

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

No single package covers all of that yet. Try removing a filter.

Model-level details live in the docs

Build AI in PHP.

Build AI apps in PHP without rewriting your provider layer.

composer require aisdk/core aisdk/openai
Read the docs