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

ActiveLibrary[API Development](/categories/api)

gzdsx/openai
============

PHP SDK for OpenAi

1.2.2(2y ago)033MITPHPPHP &gt;=7.0

Since Jun 4Pushed 2y ago1 watchersCompare

[ Source](https://github.com/gzdsx/openai)[ Packagist](https://packagist.org/packages/gzdsx/openai)[ Docs](https://github.com/gzdsx/openai)[ RSS](/packages/gzdsx-openai/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

PHP SDK for OpenAi
==================

[](#php-sdk-for-openai)

### Installation

[](#installation)

```
composer require gzdsx/openai

```

### 默认配置：

[](#默认配置)

```
OpenAiClient.init('YOUR_OPEN_AI_KEY','YOUR_OPEN_AI_ORG_ID');
```

如可以放在Laravel的AppServiceProvider的boot里

### 接口调用

[](#接口调用)

```
$config = new OpenAiRequestConfig();
$config->model = 'text-davinci-003';
$config->prompt = 'Hello Ai';
$config->temperature = 0;
$config->top_p = 1;
$config->n = 1;
$config->max_tokens = 1024;
$config->stream = false;
$config->stop = ["Human:", " AI:"];
$config->echo = true;

$client = new OpenAiClient();
$response = $client->completions($config);
if ($response->success()) {
    //成功调用,返回结果
    return $response->toArray();
}else{
    //返回错误信息
    return $response->error;
}
```

其他接口调用查看类OpenAiClient

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

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

1076d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/516a1402ec250146a1a792db0bba95db62c233305e7267193a8f0567be3d495f?d=identicon)[贵州大师兄](/maintainers/%E8%B4%B5%E5%B7%9E%E5%A4%A7%E5%B8%88%E5%85%84)

---

Top Contributors

[![xy113](https://avatars.githubusercontent.com/u/13481027?v=4)](https://github.com/xy113 "xy113 (8 commits)")

---

Tags

openaiOpenAi Sdk

### Embed Badge

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

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

###  Alternatives

[openai-php/client

OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API

5.8k22.6M232](/packages/openai-php-client)[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[openai-php/symfony

Symfony Bundle for OpenAI

215715.5k3](/packages/openai-php-symfony)[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.

47073.9k5](/packages/deepseek-php-deepseek-php-client)[deepseek-php/deepseek-laravel

A seamless Laravel integration for the Deepseek PHP client, enabling effortless interaction with the Deepseek API in your Laravel applications.

40234.9k1](/packages/deepseek-php-deepseek-laravel)

PHPackages © 2026

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