yven / openai-php-client
OpenAI client is a community-maintained PHP API client that allows you to interact with OpenAI like API, supports php7.4+.
Installs: 25
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/yven/openai-php-client
Requires
- php: ^7.4.0
- godruoyi/php-snowflake: ^2.0
- guzzlehttp/guzzle: ^7.0
- guzzlehttp/psr7: ^2.7
Requires (Dev)
- mockery/mockery: ^1.6
- nunomaduro/collision: ^5.11
- phpunit/phpunit: ^9.6
- symfony/var-dumper: ^5.4
README
openai-php-client is a community-maintained PHP API client that allows you to interact with OpenAI like API, supports php7.4+.
Install
composer require yven/openai-php-client
Usage
$apiKeys = "sk-xxx..."; $service = \OpenAI\Client::build(\OpenAI\constant\LLM::QWEN_ALI, $apiKeys); // HTTP 请求 $data = $service->query("你好,请问你可以做什么?")->send(); echo $data->getContent(); // SSE 请求 $data = $service->query("你好,请问你可以做什么?")->stream(); $content = ''; /** @var \OpenAI\response\Response $item */ foreach ($data as $item) { $content .= $item->getContent(); } echo $content;
Develop
支持模型:
| 厂商 | 模型类型 | 模型名称 |
|---|---|---|
| DeepSeek | 普通模型 | deepseek-chat |
| DeepSeek | 推理模型 | deepseek-reasoner |
| 通义千问 | 普通模型 | qwen-plus |
| 通义千问 | 视觉模型 | qwen-vl-plus |
| 通义千问 | 长文本模型 | qwen-long |
| 通义千问 | 推理模型 | qwq-plus |
| 通义千问 | Qwen3 | qwen3-32b |