PHPackages                             friendsofhyperf/openai-client - 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. friendsofhyperf/openai-client

ActiveLibrary

friendsofhyperf/openai-client
=============================

The openai client component for Hyperf.

v3.1.76(5mo ago)63.8k↓50%1[1 issues](https://github.com/friendsofhyperf/openai-client/issues)MITPHP

Since Dec 28Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/friendsofhyperf/openai-client)[ Packagist](https://packagist.org/packages/friendsofhyperf/openai-client)[ Docs](https://github.com/friendsofhyperf/openai-client)[ Fund](https://hdj.me/sponsors/)[ GitHub Sponsors](https://github.com/huangdijia)[ RSS](/packages/friendsofhyperf-openai-client/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (47)Used By (0)

Hyperf OpenAI Client
====================

[](#hyperf-openai-client)

[![Latest Test](https://github.com/friendsofhyperf/openai-client/workflows/tests/badge.svg)](https://github.com/friendsofhyperf/openai-client/actions)[![Latest Version on Packagist](https://camo.githubusercontent.com/cbcfb42e73112d41d43829f0dc7c9ed0c1d94a247a7213e3eb03deabea8b7094/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f667269656e64736f666879706572662f6f70656e61692d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/friendsofhyperf/openai-client)[![Total Downloads](https://camo.githubusercontent.com/61cdef85a955eb1606e698693c22603f4ad6a8ee9ec603845723fbea41a45c9f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f667269656e64736f666879706572662f6f70656e61692d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/friendsofhyperf/openai-client)[![GitHub license](https://camo.githubusercontent.com/add64dac76febd5d54afeebcce592a02c78c7b7ccea2fc2b51197551a24eda1c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f667269656e64736f666879706572662f6f70656e61692d636c69656e74)](https://github.com/friendsofhyperf/openai-client)

---

**OpenAI PHP** for Laravel is a supercharged community PHP API client that allows you to interact with the [Open AI API](https://beta.openai.com/docs/api-reference/introduction).

> **Note:** This repository contains the integration code of the **OpenAI PHP** for Hyperf. If you want to use the **OpenAI PHP** client in a framework-agnostic way, take a look at the [openai-php/client](https://github.com/openai-php/client) repository.

Get Started
-----------

[](#get-started)

> **Requires [PHP 8.1+](https://php.net/releases/)**

First, install OpenAI via the [Composer](https://getcomposer.org/) package manager:

```
composer require friendsofhyperf/openai-client
```

Next, publish the configuration file:

```
php bin/hyperf.php vendor:publish friendsofhyperf/openai-client
```

This will create a `config/autoload/openai.php` configuration file in your project, which you can modify to your needs using environment variables:

```
OPENAI_API_KEY=sk-...
```

Finally, you may use the `OpenAI\Client` instance from container to access the OpenAI API:

```
use OpenAI\Client;

$result = di(OpenAI\Client::class)->completions()->create([
    'model' => 'text-davinci-003',
    'prompt' => 'PHP is',
]);

echo $result['choices'][0]['text']; // an open-source, widely-used, server-side scripting language.
```

Azure
-----

[](#azure)

In order to use the Azure OpenAI Service, it is necessary to construct the client manually using the factory.

```
$client = OpenAI::factory()
    ->withBaseUri('{your-resource-name}.openai.azure.com/openai/deployments/{deployment-id}')
    ->withHttpHeader('api-key', '{your-api-key}')
    ->withQueryParam('api-version', '{version}')
    ->make();
```

To use Azure, you must deploy a model, identified by the {deployment-id}, which is already incorporated into the API calls. As a result, you do not have to provide the model during the calls since it is included in the BaseUri.

Therefore, a basic sample completion call would be:

```
$result = $client->completions()->create([
    'prompt' => 'PHP is'
]);
```

Usage
-----

[](#usage)

For usage examples, take a look at the [openai-php/client](https://github.com/openai-php/client) repository.

Contact
-------

[](#contact)

- [Twitter](https://twitter.com/huangdijia)
- [Gmail](mailto:huangdijia@gmail.com)

License
-------

[](#license)

OpenAI PHP for Hyperf is an open-sourced software licensed under the **[MIT license](https://opensource.org/licenses/MIT)**.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance68

Regular maintenance activity

Popularity28

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 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

Every ~24 days

Recently: every ~2 days

Total

46

Last Release

164d ago

Major Versions

v0.5.1 → v3.0.02023-06-12

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8337659?v=4)[Deeka Wong](/maintainers/huangdijia)[@huangdijia](https://github.com/huangdijia)

---

Top Contributors

[![huangdijia](https://avatars.githubusercontent.com/u/8337659?v=4)](https://github.com/huangdijia "huangdijia (30 commits)")

---

Tags

openaihyperfv3.1

### Embed Badge

![Health badge](/badges/friendsofhyperf-openai-client/health.svg)

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

###  Alternatives

[mineadmin/mineadmin

Quickly build a background management system for web applications

1.2k2.0k](/packages/mineadmin-mineadmin)[hyperf/odin

425.9k](/packages/hyperf-odin)[friendsofhyperf/sentry

The sentry component for Hyperf.

1864.6k](/packages/friendsofhyperf-sentry)[friendsofhyperf/lock

The lock component for Hyperf.

1447.4k](/packages/friendsofhyperf-lock)

PHPackages © 2026

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