Note: This is a learning post covering the WP AI Client is based on Rich Tabor’s blog post. This post will be updated as the feature evolves.
The WP AI Client, shipping with WordPress 7.0, provides a single, provider-agnostic API for calling generative AI models directly from PHP or JavaScript. Think of it the same way WordPress standardized database access with $wpdb, configure once, use everywhere across any plugin.
By default, WP AI Client ships no providers and makes no AI calls. It is purely the shared infrastructure layer that plugins can build on.
Setup
Step 1: Install WordPress 7.0 (currently in beta) and at least one AI provider plugin.
Available providers on WordPress.org:
Community providers are also emerging for Grok and OpenRouter.
Step 2: Define your API key as a constant or environment variable. For example, when using Anthropic:
<code>define( 'ANTHROPIC_API_KEY', 'your-api-key-here' );
Step 3: Verify the client is available before using it in your plugin. This ensures your plugin degrades gracefully when no provider is configured.
if ( function_exists( 'wp_ai_client_prompt' ) ) {
// Show the AI feature.
} else {
// Show setup instructions.
}
An admin UI for managing providers is currently in development and will simplify this process once released.
Using the API
In PHP, the wp_ai_client_prompt() function is the main entry point. Chain methods to build your request.
$text = wp_ai_client_prompt( 'Summarize this post.' )
->using_system_instruction( 'You write concise summaries. Return plain text only.' )
->generate_text();
In JavaScript, the client works through the Abilities API using @wordpress/abilities.
import '@wordpress/core-abilities';
import { executeAbility } from '@wordpress/abilities';
const result = await executeAbility(
'ai-content-helpers/generate-excerpt',
{ post_id: 123 }
);
REST and JavaScript execution permissions are controlled per ability via each ability’s permission_callback.
Use Case Examples
Auto-generating Alt Text
This example generates alt text for images at upload time. The with_file() method attaches the image so the model can analyze it, and using_model_preference() sets preferred models in priority order.
$image_file = get_attached_file( $attachment_id );
$mime_type = get_post_mime_type( $attachment_id );
$alt_text = wp_ai_client_prompt( 'Generate alt text for this image.' )
->using_system_instruction(
'You are an accessibility expert that generates alt text for website images. '
. 'Keep it under 125 characters. Describe visible content objectively. '
. 'Do not start with "Image of" or "Photo of". Return plain text only.'
)
->with_file( $image_file, $mime_type )
->using_model_preference( 'claude-sonnet-4-6', 'gpt-5.1' )
->generate_text();
Auto-generating Excerpts
This example generates a meaningful post excerpt using structured JSON output. The as_json_response() method tells the model to return data matching a defined schema — giving you a predictable object instead of free-form text.
$content = wp_strip_all_tags( $post->post_content );
$schema = array(
'type' => 'object',
'properties' => array(
'excerpt' => array(
'type' => 'string',
'description' => 'A 1-2 sentence summary of the post.',
),
),
'required' => array( 'excerpt' ),
);
$json = wp_ai_client_prompt( "Write an excerpt for this post:\n\n" . $content )
->using_system_instruction(
'You generate post excerpts for WordPress. '
. 'Write 1-2 sentences. Be specific about what the content covers. '
. 'Preserve the source tone. Avoid generic filler and cliches.'
)
->as_json_response( $schema )
->generate_text();
Wrapping Up
The WP AI Client represents a foundational shift in how AI will be integrated across the WordPress ecosystem, from a fragmented, plugin-specific approach to a unified, shared layer. WordPress 7.0 is scheduled for release on April 9, 2026.
Useful Resources
- Proposal for Merging WP AI Client into WordPress 7.0 (Make WordPress Core)
- Introducing the WordPress Abilities API (WordPress Developer Blog)
- WP AI Content Kit — working example plugin by Rich Tabor
- AI Experiments Plugin — deeper abilities examples from the WordPress project WordPress 7.0 Beta 1 announcement
- PHP AI Client — the underlying PHP library WP AI Client is built on