wordpress/ai-provider-for-openai
最新稳定版本:1.0.2
Composer 安装命令:
composer require wordpress/ai-provider-for-openai
包简介
AI Provider for OpenAI for the PHP AI Client SDK. Works as both a Composer package and WordPress plugin.
关键字:
README 文档
README
An AI Provider for OpenAI for the PHP AI Client SDK. Works as both a Composer package and a WordPress plugin.
Requirements
- PHP 7.4 or higher
- When using with WordPress, requires WordPress 7.0 or higher
- If using an older WordPress release, the wordpress/php-ai-client package must be installed
Installation
As a Composer Package
composer require wordpress/ai-provider-for-openai
As a WordPress Plugin
- Download the plugin files
- Upload to
/wp-content/plugins/ai-provider-for-openai/ - Ensure the PHP AI Client plugin is installed and activated
- Activate the plugin through the WordPress admin
Usage
With WordPress
The provider automatically registers itself with the PHP AI Client on the init hook. Simply ensure both plugins are active and configure your API key:
// Set your OpenAI API key (or use the OPENAI_API_KEY environment variable) putenv('OPENAI_API_KEY=your-api-key'); // Use the provider $result = AiClient::prompt('Hello, world!') ->usingProvider('openai') ->generateTextResult();
As a Standalone Package
use WordPress\AiClient\AiClient; use WordPress\OpenAiAiProvider\Provider\OpenAiProvider; // Register the provider $registry = AiClient::defaultRegistry(); $registry->registerProvider(OpenAiProvider::class); // Set your API key putenv('OPENAI_API_KEY=your-api-key'); // Generate text $result = AiClient::prompt('Explain quantum computing') ->usingProvider('openai') ->generateTextResult(); echo $result->toText();
Supported Models
Available models are dynamically discovered from the OpenAI API. This includes GPT models for text generation, DALL-E and GPT Image models for image generation, and TTS models for text-to-speech. See the OpenAI documentation for the full list of available models.
Configuration
The provider uses the OPENAI_API_KEY environment variable for authentication. You can set this in your environment or via PHP:
putenv('OPENAI_API_KEY=your-api-key');
License
GPL-2.0-or-later
统计信息
- 总下载量: 268
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2026-02-21