fixik/openai-client 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

CI Packagist Version Total Downloads Coverage License

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

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-11