PHPackages                             wordpress/ai-provider-for-openai - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. wordpress/ai-provider-for-openai

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wordpress/ai-provider-for-openai
================================

AI Provider for OpenAI for the PHP AI Client SDK. Works as both a Composer package and WordPress plugin.

1.0.2(2mo ago)10168↑100%7[4 issues](https://github.com/WordPress/ai-provider-for-openai/issues)[3 PRs](https://github.com/WordPress/ai-provider-for-openai/pulls)GPL-2.0-or-laterPHPPHP &gt;=7.4

Since Feb 12Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/WordPress/ai-provider-for-openai)[ Packagist](https://packagist.org/packages/wordpress/ai-provider-for-openai)[ Docs](https://github.com/WordPress/ai-provider-for-openai)[ RSS](/packages/wordpress-ai-provider-for-openai/feed)WikiDiscussions trunk Synced 1mo ago

READMEChangelog (3)Dependencies (12)Versions (13)Used By (0)

AI Provider for OpenAI
======================

[](#ai-provider-for-openai)

An AI Provider for OpenAI for the [PHP AI Client](https://github.com/WordPress/php-ai-client) SDK. Works as both a Composer package and a WordPress plugin.

Requirements
------------

[](#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](https://github.com/WordPress/php-ai-client) package must be installed

Installation
------------

[](#installation)

### As a Composer Package

[](#as-a-composer-package)

```
composer require wordpress/ai-provider-for-openai
```

### As a WordPress Plugin

[](#as-a-wordpress-plugin)

1. Download the plugin files
2. Upload to `/wp-content/plugins/ai-provider-for-openai/`
3. Ensure the PHP AI Client plugin is installed and activated
4. Activate the plugin through the WordPress admin

Usage
-----

[](#usage)

### With WordPress

[](#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

[](#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
----------------

[](#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](https://platform.openai.com/docs/models) for the full list of available models.

Configuration
-------------

[](#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
-------

[](#license)

GPL-2.0-or-later

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance77

Regular maintenance activity

Popularity25

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 53.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~10 days

Total

3

Last Release

75d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a60abe9a2c42fe5cf2117b88aac2eab186f0ea3c969f1f4a29d4a09d831153b8?d=identicon)[felixarntz](/maintainers/felixarntz)

---

Top Contributors

[![felixarntz](https://avatars.githubusercontent.com/u/3531426?v=4)](https://github.com/felixarntz "felixarntz (16 commits)")[![JasonTheAdams](https://avatars.githubusercontent.com/u/2024145?v=4)](https://github.com/JasonTheAdams "JasonTheAdams (6 commits)")[![jeffpaul](https://avatars.githubusercontent.com/u/2818133?v=4)](https://github.com/jeffpaul "jeffpaul (5 commits)")[![shaunandrews](https://avatars.githubusercontent.com/u/191598?v=4)](https://github.com/shaunandrews "shaunandrews (2 commits)")[![Jameswlepage](https://avatars.githubusercontent.com/u/36246732?v=4)](https://github.com/Jameswlepage "Jameswlepage (1 commits)")

---

Tags

wordpressaiopenaillmgpt

###  Code Quality

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/wordpress-ai-provider-for-openai/health.svg)

```
[![Health](https://phpackages.com/badges/wordpress-ai-provider-for-openai/health.svg)](https://phpackages.com/packages/wordpress-ai-provider-for-openai)
```

###  Alternatives

[soukicz/llm

LLM client with support for cache, tools and async requests

445.6k](/packages/soukicz-llm)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
