Skip to main content

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.

Installing aisdk/openai-compatible gives you the full set of shared OpenAI-compatible wire-format adapters — request builders, response parsers, and SSE stream parsers — that you can use as the foundation of any PHP AI SDK provider package. This package is intended for provider package authors, not for end-user application developers. If you are writing a provider that speaks the OpenAI-compatible API (chat completions or image generation), add this package as a dependency rather than reimplementing the wire format yourself.
This package has a minimum stability of alpha. Add "minimum-stability": "alpha" and "prefer-stable": true to your provider’s composer.json if you have not already done so.

Require the Package

composer require aisdk/openai-compatible
This will also pull in aisdk/core ^0.2 as a transitive dependency, which provides the portable contracts (TextModelRequest, ImageRequest, TextModelResponse, ImageResponse, StreamPart, etc.) that the adapter translates to and from.

Required Dependencies

The following require section reflects the real constraints declared in the package’s composer.json:
{
    "require": {
        "php": "^8.3",
        "aisdk/core": "^0.2"
    }
}
PHP 8.3 or higher is required. No other runtime dependencies are needed — the package has no HTTP client of its own and does not force a PSR-18 implementation on you.

Autoloading

The package registers a single PSR-4 namespace. After composer install, all public classes are available under AiSdk\OpenAICompatible\:
{
    "autoload": {
        "psr-4": {
            "AiSdk\\OpenAICompatible\\": "src/"
        }
    }
}
You do not need to configure anything in your own composer.json beyond the require entry — Composer’s autoloader handles the rest.

Verify the Installation

After running composer require, confirm the package is installed and check which version was resolved:
composer show aisdk/openai-compatible
You should see output similar to:
name     : aisdk/openai-compatible
descrip. : Shared OpenAI-compatible chat-completions wire format (request builder,
           response/stream parsers) for the PHP AI SDK.
keywords : ai, aisdk, chat-completions, llm, openai-compatible
homepage : https://github.com/phpaisdk/openai-compatible
license  : MIT

Build docs developers (and LLMs) love