massrimcp/openai-sdk 问题修复 & 功能扩展

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

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

massrimcp/openai-sdk

最新稳定版本:0.1.1

Composer 安装命令:

composer require massrimcp/openai-sdk

包简介

Open Ai SDK

README 文档

README

A modern PHP SDK for interacting with the OpenAI API, including support for Chat, Completions, and more. Built for PHP 8+ with a focus on developer experience, type safety, and extensibility.

Features

  • Simple and intuitive API for OpenAI endpoints
  • Support for Chat, Completions, and other OpenAI features
  • DTOs for request/response payloads
  • Extensible and testable client architecture
  • PSR-7/PSR-18 compatible HTTP client support

Installation

Install via Composer:

composer require your-vendor/php-sdk

Usage

use YourVendor\OpenAiSdk\OpenAiSdk;

$client = new OpenAiClient('your-api-key');

$response = $client->chat()->create([
    'model' => 'gpt-4',
    'messages' => [
        ['role' => 'user', 'content' => 'Hello!'],
    ],
]);

print_r($response);

Chat API Example

$chatClient = $client->chat();
$result = $chatClient->create([
    'model' => 'gpt-4',
    'messages' => [
        ['role' => 'user', 'content' => 'Tell me a joke.'],
    ],
]);
echo $result['choices'][0]['message']['content'];

Testing

Run tests with PHPUnit:

vendor/bin/phpunit

Requirements

  • PHP 8.0 or higher
  • Composer
  • PSR-7/PSR-18 compatible HTTP client (e.g., Guzzle)

Contributing

Contributions are welcome! Please open issues or submit pull requests.

License

This project is licensed under the MIT License.

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固