Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/phpaisdk/core/llms.txt

Use this file to discover all available pages before exploring further.

aisdk/core gives PHP developers a single, expressive API for interacting with any AI provider. One fluent interface covers text generation, streaming, tool calling, structured output, image generation, and reasoning — with full PSR-7/17/18 compatibility and zero framework lock-in.

Installation

Install via Composer and get your first response in minutes

Quickstart

A working end-to-end example to get you up and running fast

Core Concepts

Understand the Generate facade, models, and capability system

API Reference

Full reference for every class, method, and enum

What you can build

Text Generation

Generate text with any provider model using a single fluent call

Streaming

Stream responses token-by-token with chunk, finish, and error hooks

Tool Calling

Define tools inline or as classes; the SDK handles the agentic loop

Structured Output

Extract typed JSON objects using the Schema builder

Image Generation

Generate and save images with portable size and aspect ratio options

Reasoning

Enable thinking mode with effort levels or exact token budgets

Get started in three steps

1

Install the package

composer require aisdk/core
2

Install a provider

composer require aisdk/openai
3

Generate your first response

use AiSdk\Generate;
use AiSdk\OpenAI;

$result = Generate::text('Explain closures in PHP.')
    ->model(OpenAI::model('gpt-4o'))
    ->run();

echo $result->text;
aisdk/core is provider-agnostic. It ships contracts, value objects, and the fluent API — actual HTTP calls are handled by separate provider packages such as aisdk/openai and aisdk/anthropic.

Build docs developers (and LLMs) love