fixik/openai-client
最新稳定版本:v1.0.0
Composer 安装命令:
composer require fixik/openai-client
包简介
A PHP client for the OpenAI API with chat, embeddings, images, fine-tuning, Laravel support
README 文档
README
A powerful PHP client for the OpenAI API with support for:
- Chat
- Embeddings
- Images
- Fine-tuning
Installation
composer require fixik/openai-client
Publish config (Laravel):
php artisan vendor:publish --provider="Fixik\OpenAI\Laravel\OpenAIServiceProvider"
Add to .env:
OPENAI_API_KEY=your_key
Usage Example PHP
use Fixik\OpenAI\OpenAIClient; $apiKey = 'YOUR_OPENAI_API_KEY_HERE'; $openaiClient = new OpenAIClient($apiKey); $message = "Write a haiku about modern PHP development."; $openaiClient->chat()->send('gpt-3.5-turbo', $message); $openaiClient->embeddings()->create('gpt-3.5-turbo', $message); $openaiClient->fineTune()->create([ 'model' => 'gpt-3.5-turbo', 'training_file' => 'file-id', ]); $openaiClient->fineTune()->retrieve($jobId); $openaiClient->images()->generate($message);
Usage Example Laravel
$message = "Write a haiku about modern PHP development."; OpenAI::chat()->send('gpt-3.5-turbo', $message); OpenAI::embeddings()->create('gpt-3.5-turbo', $message); OpenAI::fineTune()->create([ 'model' => 'gpt-3.5-turbo', 'training_file' => 'file-id', ]); OpenAI::fineTune()->retrieve($jobId); OpenAI::images()->generate($message);
Testing
Run Pest:
./vendor/bin/pest
Static Analyzers
Run PHPStan:
./vendor/bin/phpstan analyse src --level=max
Run Psalm:
./vendor/bin/psalm --no-cache
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-11