mralaminahamed / ai-provider-for-opencode-zen
AI Provider for OpenCode Zen — an independent OpenCode Zen integration for the WordPress AI Client.
Package info
github.com/mralaminahamed/ai-provider-for-opencode-zen
Type:wordpress-plugin
pkg:composer/mralaminahamed/ai-provider-for-opencode-zen
Fund package maintenance!
Requires
- php: >=7.4
- ext-json: *
- wordpress/wp-ai-client: ^0.4
Requires (Dev)
- brain/monkey: ^2.7
- dealerdirect/phpcodesniffer-composer-installer: ^1.2
- php-stubs/wordpress-stubs: ^6.0
- phpcompatibility/phpcompatibility-wp: ^2.1.8
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.1.30
- phpunit/phpunit: ^9.6
- szepeviktor/phpstan-wordpress: ^2.0
- wp-coding-standards/wpcs: ^3.3.0
This package is auto-updated.
Last update: 2026-06-16 03:59:57 UTC
README
An independent, third-party OpenCode Zen provider for the WordPress PHP AI Client SDK. Works as both a Composer package and a WordPress plugin. Not affiliated with, endorsed by, or sponsored by OpenCode Zen.
Requirements
- PHP 7.4 or higher
- WordPress 7.0 or higher (AI Client SDK is included in WordPress core)
- On older WordPress releases, the WordPress AI Client plugin must be installed separately
Installation
As a WordPress Plugin
- Download the plugin zip
- Go to Plugins > Add New > Upload Plugin in your WordPress admin
- Upload and activate
As a Composer Package
composer require mralaminahamed/ai-provider-for-opencode-zen
Configuration
WordPress Admin
Go to Settings > OpenCode Zen to configure:
| Setting | Description | Default |
|---|---|---|
| API Key | Your OpenCode Zen API key | — |
| Default Model | Model used when none is specified | First available |
| Temperature | Output randomness (0.0–2.0) | 1.0 |
| Max Tokens | Maximum response length | 2048 |
| Top P | Nucleus sampling threshold (0.0–1.0) | 1.0 |
| Presence Penalty | Penalise repeated topics (-2.0–2.0) | 0.0 |
| Frequency Penalty | Penalise repeated tokens (-2.0–2.0) | 0.0 |
Environment Variable
OPENCODE_ZEN_API_KEY takes priority over the database setting:
export OPENCODE_ZEN_API_KEY=your-api-key
Get your API key at opencode.ai/zen/settings/api-keys.
Usage
With WordPress (automatic)
The provider registers itself on the init hook. No manual setup required beyond entering your API key.
use WordPress\AiClient\AiClient; $result = AiClient::prompt('Explain quantum computing') ->usingProvider('opencode-zen') ->generateTextResult(); echo $result->toText();
As a Standalone Composer Package
use WordPress\AiClient\AiClient; use AlAminAhamed\OpenCodeZenAiProvider\Provider\OpenCodeZenProvider; $registry = AiClient::defaultRegistry(); $registry->registerProvider(OpenCodeZenProvider::class); putenv('OPENCODE_ZEN_API_KEY=your-api-key'); $result = AiClient::prompt('Explain quantum computing') ->usingProvider('opencode-zen') ->generateTextResult(); echo $result->toText();
Supported Models
Models are discovered dynamically from the OpenCode Zen API (cached for 1 hour). The fallback list includes 41 models:
- GPT 5.x — GPT 5.5, GPT 5.4, GPT 5.3 Codex, GPT 5.2, GPT 5.1, GPT 5, and variants
- Claude 4.x — Opus 4.7/4.6/4.5/4.1, Sonnet 4.6/4.5/4, Haiku 4.5, and Claude 3.5 Haiku
- Gemini 3.x — Gemini 3.5 Flash, 3.1 Pro, 3 Flash
- Other — Qwen, MiniMax M2, GLM 5.1, Kimi K2, Grok, DeepSeek, Nemotron
Architecture
includes/
Provider/
OpenCodeZenProvider.php # Registers provider ID "opencode-zen"
OpenCodeZenTextGenerationModel.php # OpenAI-compatible text generation
Metadata/
OpenCodeZenModelMetadataDirectory.php # API model discovery + transient cache
Settings/
OpenCodeZenSettings.php # WP admin settings page (logic only)
templates/
admin/
settings-page.php # <form> wrapper
section-general.php # Section description
field-model.php # Model <select>
field-temperature.php # Temperature <input>
field-max-tokens.php # Max tokens <input>
field-top-p.php # Top P <input>
field-presence-penalty.php # Presence penalty <input>
field-frequency-penalty.php # Frequency penalty <input>
Settings page: options-general.php?page=opencode-zen-settings
Option key: opencode_zen_settings
Development
# Install dependencies composer install # Run tests composer test # Lint composer phpcs # Auto-fix lint issues composer phpcbf # Static analysis composer phpstan # Build release zip composer release
The release script runs composer install --no-dev --optimize-autoloader so only the plugin's own classmap is in the vendor directory — the AI Client SDK is excluded entirely (it is provided by WordPress 7.0+ at runtime).
License
GPL-2.0-or-later