PHPackages                             aisdk/openai-compatible - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. aisdk/openai-compatible

ActiveLibrary[API Development](/categories/api)

aisdk/openai-compatible
=======================

Shared OpenAI-compatible chat-completions wire format (request builder, response/stream parsers) for the PHP AI SDK.

v0.1.0-alpha1(yesterday)02↑2900%1MITPHPPHP ^8.3

Since Jun 30Pushed yesterdayCompare

[ Source](https://github.com/phpaisdk/openai-compatible)[ Packagist](https://packagist.org/packages/aisdk/openai-compatible)[ Docs](https://github.com/phpaisdk/openai-compatible)[ RSS](/packages/aisdk-openai-compatible/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (6)Versions (2)Used By (1)

aisdk/openai-compatible
=======================

[](#aisdkopenai-compatible)

Shared OpenAI-compatible chat-completions wire adapter for the PHP AI SDK. Reusable by any provider that speaks the OpenAI `/chat/completions` REST/SSE protocol.

Installation
------------

[](#installation)

```
composer require aisdk/openai-compatible
```

What This Package Does
----------------------

[](#what-this-package-does)

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

It owns:

- Request body building (`ChatRequestBuilder`)
- Response parsing (`ChatResponseParser`)
- SSE stream parsing (`ChatStreamParser`)
- Message conversion (`ChatMessageConverter`)
- Tool conversion (`ChatToolConverter`)
- Usage normalization (`ChatUsage`)
- Finish reason mapping (`MapsFinishReason`)

It does **not** own:

- Provider authentication
- Model catalogs
- Provider-specific quirks or fallback behavior

Usage
-----

[](#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:

```
use AiSdk\OpenAICompatible\ChatRequestBuilder;
use AiSdk\OpenAICompatible\ChatResponseParser;
use AiSdk\OpenAICompatible\ChatStreamParser;

$body = ChatRequestBuilder::build($modelId, $providerName, $request, stream: false);
$payload = $this->runner()->postJson($url, $body, $headers, $providerName);
$response = ChatResponseParser::parse($payload, $providerName);
```

Provider Integration
--------------------

[](#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`.
3. Create a text model extending `BaseModel` that calls `ChatRequestBuilder::build()`, `ChatResponseParser::parse()`, and `ChatStreamParser::parse()`.
4. Add provider-specific auth, base URL, headers, and model catalog.
5. Apply any provider-specific adaptations (e.g., structured output downgrades) after calling `ChatRequestBuilder::build()`.

Testing
-------

[](#testing)

```
composer test
```

Links
-----

[](#links)

- [Core Package](https://github.com/phpaisdk/core)
- [Project Documentation](https://github.com/phpaisdk)

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance100

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ef29d1962da41e7526023f215cf844494e209b2fd163742084cb919a3b508021?d=identicon)[aisdk](/maintainers/aisdk)

---

Top Contributors

[![RanaMoizHaider](https://avatars.githubusercontent.com/u/58527494?v=4)](https://github.com/RanaMoizHaider "RanaMoizHaider (2 commits)")

---

Tags

aillmchat-completionsopenai-compatibleaisdk

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/aisdk-openai-compatible/health.svg)

```
[![Health](https://phpackages.com/badges/aisdk-openai-compatible/health.svg)](https://phpackages.com/packages/aisdk-openai-compatible)
```

###  Alternatives

[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

46784.5k5](/packages/deepseek-php-deepseek-php-client)[wordpress/php-ai-client

A provider agnostic PHP AI client SDK to communicate with any generative AI models of various capabilities using a uniform API.

28245.9k23](/packages/wordpress-php-ai-client)[mozex/anthropic-laravel

Laravel integration for the Anthropic API: facade, config publishing, install command, testing fakes, messages, streaming, tool use, thinking, and batches.

72287.1k1](/packages/mozex-anthropic-laravel)[mozex/anthropic-php

PHP client for the Anthropic API: messages, streaming, tool use, thinking, web search, code execution, batches, and more.

47480.9k16](/packages/mozex-anthropic-php)[wordpress/wp-ai-client

An AI client and API for WordPress to communicate with any generative AI models of various capabilities using a uniform API.

12521.8k3](/packages/wordpress-wp-ai-client)[neuron-core/neuron-laravel

Official Neuron AI Laravel SDK.

11125.7k1](/packages/neuron-core-neuron-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
