Model or dataset
openai-php/client avatar
openai-php/client

OpenAI PHP's twenty-nine live resources, its PHP 8.2 floor, and a version that never left 0.x

⚡️ OpenAI PHP is a supercharged community-maintained PHP API client that allows you to interact with OpenAI API.

5,837 stars682 forksPHPMIT

At a glance

What is it?
OpenAI PHP wraps the OpenAI API in PHP method calls, grouped into resources the way the API groups its own endpoints: twenty-nine current ones, one marked legacy, seven marked deprecated. It is community maintained rather than official, still on a 0.x version, and it leans on PSR-18 discovery for its HTTP client, which is the setup detail the front page spends the most words on.
Who is it for?
Use it when you want PHP method calls shaped like the API's own resources and you are ready for pre-1.0 movement, and pin your version. Do not adopt it expecting an official or settled surface: the newest tag is v0.22.0, seven resources are already marked deprecated and Completions is labelled legacy, so you are choosing which generation of the API to code against.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository received new commits within the last day.
What is it written in?
Mainly PHP, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 14, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • openai-php/client5,837 ★ · +5
Star history
Repository2026-09-152026-11-14
openai-php/client5.8k5.8k

5 Stars in the last 60 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

v0.21.0 means this client has never claimed a stable surface

The three most recent tags are v0.20.1 on 2026-07-20, v0.21.0 on 2026-09-17 and v0.22.0 on 2026-10-31. All of them sit below 1.0, and in that numbering scheme a leading zero means nothing in the public interface is promised to hold still across a minor bump. That matters more here than it would for a small utility, because the client mirrors an API surface that is itself being reorganised. The repository was pushed to on 2026-11-01, so commits are landing between releases rather than only at tag time, and the gap between what you read and what you pin is a real gap. Add the community maintained framing, which is how the front page describes the package, and you are looking at a library whose own description is honest about its status.

PHP 8.2 is the floor, and a blocked discovery plugin leaves you with no HTTP client

Install is one Composer command, and then there is a second instruction that trips people up:

bash
composer require openai-php/client

The front page asks you to make sure the php-http/discovery Composer plugin is allowed to run, or to install a client by hand if your project does not already have one integrated:

bash
composer require guzzlehttp/guzzle

That is the whole reason for the second command. The package does not ship an HTTP client of its own, and the documented default for the factory's HTTP step is a client found through PSR-18 discovery. On a locked down machine or a restricted build environment where the plugin cannot run, the library is installed and still unable to make a request until you add Guzzle yourself. The stated language requirement is PHP 8.2 or newer.

withBaseUri exists because the Services section carries Azure

The one static helper on the front page, OpenAI::client with a key, is enough for the common case:

php
$yourApiKey = getenv('YOUR_API_KEY');
$client = OpenAI::client($yourApiKey);

$response = $client->responses()->create([
    'model' => 'gpt-4o',
    'input' => 'Hello!',
]);

echo $response->outputText; // Hello! How can I assist you today?

Everything else goes through a factory rather than the constructor. The documented chain includes withApiKey, withOrganization and withProject, both defaulting to null, withBaseUri, whose stated default is api.openai.com/v1, withHttpClient, withHttpHeader for a single extra header, withQueryParam for a single extra query argument, and withStreamHandler for supplying your own send behaviour. An organization, a project and an overridable base URI only make sense as a set, and the table of contents ends with a Services section whose only entry is Azure.

Seven deprecated resources and one legacy resource sit beside the live twenty

The table of contents is the clearest picture of the API's own churn, because it names twenty-nine current resources and then keeps eight older ones in the same list. Current: Models, Responses, Conversations, Conversations Items, Containers, Containers Files, Skills, Skills Versions, Agents, Agents Environments, Agents Environments Templates, Agents Environments Files, Agents Sessions, Agents Sessions Events, Vaults, Vaults Credentials, Chat, Audio, Embeddings, Files, FineTuning, Decisions, Moderations, Images, Vector Stores, Vector Stores Files, Vector Stores File Batches, Batches, and Realtime Ephemeral Keys. Then Completions is labelled legacy, and Assistants, Thread, Thread Messages, Thread Runs, Thread Runs Steps, FineTunes and Edits are each labelled deprecated. The table of contents gives the label itself as the signal.

models()->delete() reaches fine-tuned models only

The Models resource is the small one, with three methods, and the third one carries its own limitation in a single sentence: delete a fine-tuned model. The example deletes curie:ft-acmeco-2021-03-03-21-44-20 and reads back a deleted flag of true, which tells you the call targets a fine-tuned model identifier and not one of the base models. The other two are reads. list gives you a list object whose entries carry an id and an object value of model, with gpt-3.5-turbo-instruct used as the sample id. retrieve takes that same style of id and returns the created timestamp, a numeric value in the example, plus ownedBy set to openai. Both reads also expose toArray, so a response object can be flattened into a plain array when you need it.

responses()->create() is where the parameter surface lives

The Responses resource carries the newest shape of the API and the widest parameter set. The documented call passes model, tools and input, where tools holds an array of typed entries such as a web_search_preview tool. The README also says the model can call your own custom code or use built-in tools like web search or file search.

phpstan.neon.dist and phpunit.xml.dist describe a statically checked client

The repository root is short and says more about the project than the marketing copy does. There is composer.json, src/ for the code, tests/ for the suite, phpunit.xml.dist for the test runner configuration, and phpstan.neon.dist for static analysis, which together say the library is type checked and has its tests separated from its implementation. Alongside those sit CHANGELOG.md, CONTRIBUTING.md, LICENSE.md under the MIT license, an art/ directory for project images, and .editorconfig with .gitattributes and .gitignore. The README's table of contents also lists Troubleshooting, Testing and Webhooks sections.

Editorial conclusion

Use it when you want PHP method calls shaped like the API's own resources and you are ready for pre-1.0 movement, and pin your version. Do not adopt it expecting an official or settled surface: the newest tag is v0.22.0, seven resources are already marked deprecated and Completions is labelled legacy, so you are choosing which generation of the API to code against. Before installing, confirm PHP 8.2 or newer and decide in advance how you will supply a PSR-18 HTTP client, since Composer discovery plugins are often blocked on the machines where this kind of code has to run.

Frequently asked questions

Is OpenAI PHP an official OpenAI package?

No. It is described as a community maintained PHP API client for interacting with the OpenAI API, and it links the vendor's own API reference separately rather than presenting itself as a first party release.

What PHP version does OpenAI PHP require?

PHP 8.2 or newer, stated as the requirement on the front page. Installation itself is a single Composer command, composer require openai-php/client.

Why does OpenAI PHP ask me to install Guzzle?

Because it needs a PSR-18 HTTP client and does not bundle one. You are asked to allow the php-http/discovery Composer plugin to run, or install a client yourself with composer require guzzlehttp/guzzle, since the factory's HTTP step defaults to a client found through PSR-18 discovery.

How do I point OpenAI PHP at a different API host?

Through the factory rather than the client helper: withBaseUri carries a default of api.openai.com/v1, and the same chain offers withOrganization and withProject, both defaulting to null. The README's table of contents also lists Azure under Services.

Which OpenAI PHP resources are deprecated?

Assistants, Thread, Thread Messages, Thread Runs, Thread Runs Steps, FineTunes and Edits are all marked deprecated, and Completions is marked legacy. They remain in the table of contents alongside twenty-nine resources that are not so labelled.

Official sources

  1. Issues
  2. License: MIT
  3. openai-php/client on GitHub
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/openai-php-client.svg)](https://hysenlabs.com/projects/openai-php-client)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/openai-php-client.svg)](https://hysenlabs.com/projects/openai-php-client)

Was this useful?