TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/phpaisdk/openai/llms.txt
Use this file to discover all available pages before exploring further.
aisdk/openai package is the official OpenAI provider for the PHP AI SDK. It bridges the unified PHP AI SDK interface to OpenAI’s Chat Completions and Images APIs, giving your application access to GPT-4o, o-series reasoning models, DALL-E, and gpt-image-1 — all through a clean, type-safe PHP API.
Installation
Install via Composer and configure your API key in under a minute.
Quickstart
Generate your first AI response with five lines of PHP.
Configuration
Set API keys, base URLs, organization IDs, and custom headers.
API Reference
Full reference for the OpenAI facade and provider classes.
What you can build
Text Generation
Chat completions with system prompts, temperature, and token limits.
Streaming
Server-sent event streaming for real-time token delivery.
Tool Calling
Define tools with typed schemas and let the model invoke them.
Structured Output
Force JSON Schema responses for reliable data extraction.
Reasoning
Control reasoning effort on o-series models like o3 and o4-mini.
Image Generation
Generate images with gpt-image-1, DALL-E 3, and DALL-E 2.
Multimodal Input
Pass images, audio, and files alongside text in your prompts.
Custom Models
Register new OpenAI models without waiting for a package release.
Quick example
quickstart.php