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 An API or Application Programming Interface is a software intermediary that allows programs to interact with each other and share data in limited, clearly defined ways., as part of the AI Building Blocks for WordPress initiative.ย
Built on top of the PHP AI Client SDK A platform-agnostic library providing unified access to LLMs and embedding models from any major AI provider. Developed collaboratively with the PHP community. The WordPress AI Client SDK is the WordPress-specific package that adds REST API endpoints, API key management, and integrations through `AI_Client::prompt()`., the WordPress AI Client SDK adapts that lowerโlevel library to WordPress conventions: it uses the WordPress HTTP HTTP is an acronym for Hyper Text Transfer Protocol. HTTP is the underlying protocol used by the World Wide Web and this protocol defines how messages are formatted and transmitted, and what actions Web servers and browsers should take in response to various commands. API under the hood, integrates with WP Admin for credentials, and follows WordPress coding standards The Accessibility, PHP, JavaScript, CSS, HTML, etc. coding standards as published in the WordPress Coding Standards Handbook.
May also refer to The collection of PHP_CodeSniffer rules (sniffs) used to format and validate PHP code developed for WordPress according to the PHP 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 plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-partyโ a firstโclass, repeatable pattern:
- A fluent Prompt Builder API (
AI_Client::prompt()) tailored for WordPress developers, built directly on the PHP PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML. https://www.php.net/manual/en/preface.php. AI Client.
- A WP Admin โAI Credentialsโ settings screen where site administrators can configure provider An AI service offering models for generation, embeddings, or other capabilities (e.g., Anthropic, Google, OpenAI). 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 A core WordPress API (introduced in 6.9) that creates a central registry of capabilities, making WordPress functions discoverable and accessible to AI agents, automation tools, and developers. Transforms WordPress from isolated functions into a unified system. integration, REST API The REST API is an acronym for the RESTful Application Program Interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data. It is how the front end of an application (think โphone appโ or โwebsiteโ) can communicate with the data store (think โdatabaseโ or โfile systemโ) https://developer.wordpress.org/rest-api/. endpoints, and a client-side JavaScript JavaScript or JS is an object-oriented computer programming language commonly used to create interactive effects within web browsers. WordPress makes extensive use of JS for a better user experience. While PHP is executed on the server, JS executes within a userโs browser. https://www.javascript.com/./TypeScript based Prompt Builder API equivalent to the server-side one.
Installation and first prompt
To add the SDK to a plugin:
- Require the package via Composer:
composer require wordpress/wp-ai-client
- Initialize the client from your plugin on init:
use WordPress\AI_Client\AI_Client;
add_action( 'init', array( AI_Client::class, 'init' ) );
- In WP Admin, go to Settings โ AI Credentials and enter the API keys for the providers you want to use.ย
- 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 Software design that works with multiple service providers without being tied to one. Recommended for WordPress AI integrations., 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 Core is the set of software required to run WordPress. The Core Development Team builds WordPress. AI building blocks alongside the Abilities API and the MCP Adapter Translates WordPress abilities into Model Context Protocol format, allowing AI assistants like Claude and ChatGPT to discover and invoke WordPress capabilities as tools, resources, and prompts.:
- 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.