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

ActiveLibrary[API Development](/categories/api)

cblink/openai
=============

An OpenAI REST API Client with ChatGPT, GPT-3, Codex, DALL·E.

v0.1.2(3y ago)1886MITPHP

Since Mar 13Pushed 3y ago2 watchersCompare

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

READMEChangelogDependencies (1)Versions (4)Used By (0)

 OpenAI REST API Client
========================

[](#-openai-rest-api-client-)

OpenAI 应用 ChatGPT

安装
--

[](#安装)

```
$ composer require cblink/openai -vvv
```

使用
--

[](#使用)

```
// 传入配置
$config = [
    // openai的apikey
    'api_key' => '',
    // 请求的初始配置
    'guzzle' => [
        // 代理配置，如果没有的话可以不传入,配置参考 https://docs.guzzlephp.org/en/stable/request-options.html#proxy
        'proxy' => [],
    ],
];

$openai = new Cblink\ChatGPT\OpenAI($config);

// 查询可用的模型
$openai->models->lists();

// 创建对话
$openai->chat->create([
    'model' => 'gpt-3.5-turbo',
    'messages' => [
        ['role' => 'user', 'content' => 'hello!'],
    ],
]);

// 创建图片
$openai->image->create([
    'prompt' => 'A cute baby sea otter',
]);

// 未封装的接口请求

// get 请求
$openai->httpGet('v1/files')

// post 请求 ，参数： 路径，请求参数，文件
$openai->httpPost('v1/files', [
    'purpose' => 'fine-tune',
], [
    // 此处传入路径即可
    'file' => '/path/file'
])

// delete请求
$file_id = 'file-XjGxS3KTG0uNmNOK362iJua3';
$openai->httpDelete(sprintf('v1/files/%s', $file_id))
```

Contributing
------------

[](#contributing)

You can contribute in one of three ways:

1. File bug reports using the [issue tracker](https://github.com/cblink/chatgpt/issues).
2. Answer questions or fix bugs on the [issue tracker](https://github.com/cblink/chatgpt/issues).
3. Contribute new features or update the wiki.

*The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.*

License
-------

[](#license)

MIT

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

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 ~0 days

Total

3

Last Release

1161d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8a33f3d22f7c5ba81df984215eda327fe21f224f59a8a8cb404138042ec9f788?d=identicon)[overnic](/maintainers/overnic)

---

Tags

codexGPT-3openaiChatGptPHP ChatGPTChatGPT SDK

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/cblink-openai/health.svg)](https://phpackages.com/packages/cblink-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)[openai-php/symfony

Symfony Bundle for OpenAI

215715.5k3](/packages/openai-php-symfony)[qwen-php/qwen-php-client

robust and community-driven PHP SDK library for seamless integration with the qwen AI API, offering efficient access to advanced AI and data processing capabilities

213.2k1](/packages/qwen-php-qwen-php-client)

PHPackages © 2026

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