Introducing the WordPress AI Client SDK


The first tagged release of the WordPress AI Client SDK (wordpress/wp-ai-client 0.1.0) is now available. This package provides a WordPress‑native AI client that lets plugins and themes talk to multiple generative AI providers through a single, consistent API, as part of the AI Building Blocks for WordPress initiative. 

Built on top of the PHP AI Client SDK, the WordPress AI Client SDK adapts that lower‑level library to WordPress conventions: it uses the WordPress HTTP API under the hood, integrates with WP Admin for credentials, and follows WordPress coding standards. In the next release, it will furthermore integrate with the Abilities API.

What the WordPress AI Client SDK does

The SDK is designed to make “call an AI model from a plugin” a first‑class, repeatable pattern:

  • A fluent Prompt Builder API (AI_Client::prompt()) tailored for WordPress developers, built directly on the PHP AI Client.
  • A WP Admin “AI Credentials” settings screen where site administrators can configure provider API keys in one place.
  • Automatic wiring of those credentials into the underlying PHP AI Client whenever your code executes a prompt.
  • A PSR‑compatible HTTP client implementation backed by wp_remote_request(), so the underlying SDK uses the WordPress way of handling HTTP requests.

Combined, this gives plugins and themes a uniform way to work with different AI providers and model families without reinventing credential management or HTTP integrations.

Version 0.1.0 is the initial “developer‑ready” release of the SDK and includes the above features. Upcoming releases will expand on these capabilities, providing an Abilities API integration, REST API endpoints, and a client-side JavaScript/TypeScript based Prompt Builder API equivalent to the server-side one.

Installation and first prompt

To add the SDK to a plugin:

  1. Require the package via Composer:
composer require wordpress/wp-ai-client
  1. Initialize the client from your plugin on init:
use WordPress\AI_Client\AI_Client;

add_action( 'init', array( AI_Client::class, 'init' ) );
  1. In WP Admin, go to Settings → AI Credentials and enter the API keys for the providers you want to use. 
  2. Start prompting from your plugin code:
use WordPress\AI_Client\AI_Client;

$summary = AI_Client::prompt( 'Summarize the history of the printing press.' )
	->using_temperature( 0.1 )
	->generate_text();

Automatic model selection and using specific models

With the above snippet, the SDK will automatically choose a suitable model for the given prompt and configuration. This makes your plugin provider-agnostic, which is a recommended pattern to be able to run on most WordPress sites: Mosts sites likely will only configure specific AI model providers (e.g. Anthropic, Google, OpenAI), and this means your plugin will only be able to use models from the configured provider. If you don’t specify a model, the SDK will automatically pick one that supports all the capabilities you need. It will then pick up the configured credentials and route the request through the appropriate provider client.

If you have specific models that you would like to use, the recommended way is to provide a preference list of these models:

use WordPress\AI_Client\AI_Client;

$summary = AI_Client::prompt( 'Summarize the history of the printing press.' )
	->using_temperature( 0.1 )
	->using_model_preference(
		'claude-sonnet-4-5',
		'gemini-3-pro-preview',
		'gpt-5.1'
	)
	->generate_text();

The SDK will then use the first model from the list where the provider is configured on the WordPress site, unless none of these models can be used. In that case it will choose another suitable model, as mentioned before.

It is also possible to enforce use of a single specific model. However, this means sites that don’t have the provider for that model configured will not be able to use the respective AI feature. Therefore, for maximum compatibility and reach you are encouraged to use one of the more flexible approaches outlined. If you still want to allow using only a single specific model, you should include logic to first check whether the model can be used and make the respective feature conditionally available:

use WordPress\AI_Client\AI_Client;
use WordPress\AiClient\ProviderImplementations\Anthropic\AnthropicProvider as Anthropic;

$prompt = AI_Client::prompt( 'Summarize the history of the printing press.' )
	->using_temperature( 0.1 )
	->using_model( Anthropic::model( 'claude-sonnet-4-5' ) );

if ( $prompt->is_supported_for_text_generation() ) {
	// Expose the feature, call `$prompt->generate_text()` etc.
} else {
	// Fallback: Hide feature or show setup instructions.
}

The is_supported_for_text_generation() method used above (or the equivalent methods for other AI capabilities such as image generation) is generally recommended around specific AI feature implementations. This way you ensure only features that can actually work on the WordPress site are shown to the user. If the result of the method is negative, you can either fall back to a non-AI variant of the feature, show a message informing the user how they can get access to the feature, or simply hide the feature completely.

How it fits into the AI Building Blocks

The AI Client SDK is one of the core AI building blocks alongside the Abilities API and the MCP Adapter:

  • Abilities API: describes what WordPress can do in a unified, machine‑readable way. Now a core API, as of v6.9!
  • MCP Adapter: exposes those abilities to external AI tools via the Model Context Protocol.
  • WordPress AI Client SDK: makes it straightforward for plugins and themes to call upstream AI providers from within WordPress itself.

Future iterations will build on this 0.1.0 foundation with additional surfaces such as REST and client‑side APIs, so that both server‑side code and JavaScript applications in the WordPress admin can share the same AI client infrastructure.

For more details and examples, see the wordpress/wp-ai-client repository README and contributing documentation.