Download the PHP package aisdk/openai-compatible without Composer

On this page you can find all versions of the php package aisdk/openai-compatible. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package openai-compatible

aisdk/openai-compatible

GitHub Workflow Status Total Downloads Latest Version License Why PHP in 2026


Shared OpenAI-compatible wire adapter for the PHP AI SDK. Reusable by any provider that speaks OpenAI-compatible Chat Completions, Responses, embedding, image generation, speech generation, or transcription APIs.

Installation

What This Package Does

This package provides the shared wire-format bridge between core portable contracts (AiSdk\*) and OpenAI-compatible provider shapes. It is used by providers like Groq, xAI, OpenRouter, and others that implement the OpenAI-compatible API.

It owns:

It does not own:

Usage

This package is consumed by provider packages, not directly by end users. A provider that speaks OpenAI-compatible chat completions uses it like this:

For Responses endpoints, use the separate Responses wire helpers rather than adapting a Chat Completions body:

For streaming, pass parsed SSE events to ResponsesStreamParser::parse() in the same way Chat Completions providers use ChatStreamParser.

ResponsesRequestProfile lets a provider declare safe endpoint differences such as its output-token field or reasoning parameter path. Unsupported portable features fail at request construction instead of being sent optimistically. Providers can still pass endpoint-specific fields through providerOptions($providerName, [...]).

For embedding endpoints:

Providers can configure the dimensions field name or omit it, and can disable the default encoding_format: float field when their endpoint uses a different wire shape. Provider-namespaced options and raw values are applied after portable fields.

For image generation endpoints:

For speech generation endpoints:

For OpenAI-compatible transcription endpoints:

Provider Integration

To build a provider on top of this package:

  1. Depend on aisdk/core and aisdk/openai-compatible.
  2. Create a provider class extending BaseProvider and implement protected capability hooks such as textModel() or embeddingModel().
  3. Expose only Provider::model('model-id') from the public facade, delegating to the provider instance's model() method.
  4. Create a text model extending BaseModel and select either the Chat Completions helpers or the Responses helpers for the provider endpoint. Both paths support text, tools, structured output, reasoning, streaming, normalized usage, and provider-namespaced options; multimodal content is used only when the provider advertises the corresponding core capability.
  5. Add provider-specific auth, base URL, headers, and adapter capabilities.
  6. Apply any provider-specific adaptations (e.g., structured output downgrades) after calling ChatRequestBuilder::build().

For embeddings, create a model implementing EmbeddingModelInterface, call EmbeddingRequestBuilder::build(), then parse the provider payload with EmbeddingResponseParser::parse(). For image generation, create an image model implementing ImageModelInterface, call ImageRequestBuilder::build(), then parse the provider payload with ImageResponseParser::parse(). For speech generation, create a speech model implementing SpeechModelInterface, call SpeechRequestBuilder::build(), then parse the raw audio response with SpeechResponseParser::parse(). For transcription, implement TranscriptionModelInterface, send the multipart body from TranscriptionRequestBuilder, then normalize the response with TranscriptionResponseParser. Provider packages still own authentication, endpoint paths, adapter capabilities, and public facades. Model IDs should pass through as opaque provider values instead of being maintained as a package-owned inventory.

Testing

Documentation

Community


All versions of openai-compatible with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
aisdk/core Version ^0.8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package aisdk/openai-compatible contains the following files

Loading the files please wait ...