Documentation Index
Fetch the complete documentation index at: https://mintlify.com/phpaisdk/openai-compatible/llms.txt
Use this file to discover all available pages before exploring further.
aisdk/openai-compatible is the shared wire-format bridge between the PHP AI SDK’s portable contracts and any provider that implements the OpenAI-compatible /chat/completions or /images/generations API. Instead of every provider re-implementing the same JSON serialization, response parsing, and SSE stream handling, they each depend on this package.
Installation
Add the package to your project with Composer and configure your autoloader.
Quickstart
See a complete provider integration in minutes using the core builders and parsers.
Build a Provider
Step-by-step guide to creating a new OpenAI-compatible provider for the PHP AI SDK.
API Reference
Full signatures, parameters, and return types for every public class.
What this package provides
aisdk/openai-compatible covers the complete OpenAI-compatible wire layer so provider packages stay thin:
Chat Request Builder
Builds
/chat/completions request bodies including messages, tools, streaming options, reasoning effort, and structured output.Chat Response Parser
Parses completion payloads into typed
TextModelResponse with TextPart and ToolCallPart.Chat Stream Parser
Converts raw SSE events into typed
StreamPart objects — text deltas, tool-call fragments, reasoning, and finish signals.Image Builders & Parsers
Builds
/images/generations payloads and normalizes image responses including base64 data, MIME types, and usage.Getting started
This package is consumed by provider packages, not directly by end users. If you are building a provider that speaks the OpenAI-compatible API, start with the Building a Provider guide.