ASHISH KANAJARIYA0%Preparing your experience
Skip to content

WordPress AI Client and Connectors: A Complete Guide to AI in WordPress 7.0

Laptop on a desk representing the WordPress AI Client and Connectors in WordPress 7.0

Artificial intelligence has been arriving in WordPress one plugin at a time for years. Each plugin brought its own settings page, its own API key field and its own way of talking to a model. With WordPress 7.0, that changed. The WordPress AI Client and the new Connectors screen give the whole ecosystem one shared, provider-agnostic foundation for AI features. In this guide you will learn what the WordPress AI Client is, how Connectors store and share credentials, how to switch AI on for your own site, and how developers can build a real feature on top of it with only a few lines of PHP.

Whether you run a small blog, manage client sites at an agency, or build plugins for a living, understanding this layer now will save you a lot of time later. It is quickly becoming the standard way WordPress plugins add AI capabilities.

What Is the WordPress AI Client?

The WordPress AI Client is a provider-agnostic PHP interface that ships inside WordPress core starting with version 7.0, which was released on May 20, 2026. Instead of each plugin bundling its own SDK for a particular AI company, plugins call one WordPress function and let the site owner decide which provider actually answers the request.

Under the hood, the AI Client has two layers:

  • The PHP AI Client library – a shared, framework-independent package that standardises how software talks to AI services (text, images, speech and more).
  • A WordPress wrapper – a set of WordPress-flavoured functions and classes that follow familiar conventions: snake_case method names, WP_Error return values, and integration with the WordPress HTTP API and hooks.

The entry point for developers is a single function, wp_ai_client_prompt(). It does not send a request immediately. Instead, it returns a WP_AI_Client_Prompt_Builder object, a fluent builder you configure step by step before asking it to generate a result. That design keeps simple tasks short and complex tasks readable.

Why a shared AI layer matters

Before 7.0, a site with three AI-powered plugins might have needed three separate API keys entered in three separate places, each with different security handling. A shared layer brings real benefits for everyone involved:

  • Site owners configure a provider once and every compatible plugin can use it.
  • Agencies can standardise how AI credentials are stored across many client sites.
  • Plugin developers no longer need to build credential screens, key validation or provider-specific request code.
  • Users get freedom of choice: switching providers does not require switching plugins.

It is also worth being clear about what the AI Client is not. It is not an “AI writes your posts” button, and installing WordPress 7.0 does not, by itself, send anything to an AI service. Core provides the plumbing; features appear only when you connect a provider and use a plugin that calls the client.

How the AI Client Fits with the Abilities API and MCP

WordPress is building its AI foundation in layers, and it helps to see where each piece sits:

Building blockIntroducedWhat it does
Abilities APIWordPress 6.9A central registry of permission-checked actions that plugins, themes and core expose.
MCP AdapterOfficial package / pluginExposes registered abilities to external AI agents through the Model Context Protocol.
AI ClientWordPress 7.0Lets WordPress itself call an AI model through a single, provider-agnostic PHP API.
ConnectorsWordPress 7.0Stores and manages credentials for external services, starting with AI providers.

Think of it as two directions of traffic. The Abilities API and MCP Adapter let outside AI agents act on your site in a controlled way. The AI Client lets your site reach out to an AI model. Together they make WordPress a capable participant in AI-assisted workflows rather than just a place where AI-generated text gets pasted.

Understanding the Connectors Screen

The second half of the story is Connectors. In WordPress 7.0 you will find a new screen at Settings › Connectors. It is designed as a central hub for integrations with external services. AI providers are the first and most visible use, but the underlying Connectors API was designed for external services in general, so expect it to grow over future releases.

Out of the box, the screen offers connectors for three major AI providers: Anthropic, Google and OpenAI. An important detail is that WordPress core does not bundle the provider implementations themselves. Each provider lives in its own plugin on WordPress.org, and the Connectors screen helps you install the one you need and then asks for your API key. This keeps core lean and leaves room for more providers to join the ecosystem.

How Connectors find your API key

The Connectors API looks for credentials in a clear, predictable order:

  1. An environment variable, for example ANTHROPIC_API_KEY, set on the server.
  2. A PHP constant, for example defined in wp-config.php.
  3. A database setting, which is what gets saved when you paste a key into the Connectors screen. These options follow the pattern connectors_ai_{id}_api_key.

This order is very friendly to professional hosting setups. Teams that manage secrets through their host or deployment pipeline can provide keys as environment variables, while a solo site owner can simply paste a key into the admin screen. Keys saved through the screen are masked in the interface, and because a connector key is a site-wide setting that installed plugins can use, many developers recommend the environment variable or constant route for production sites. It keeps secrets out of database exports and backups, which is a good habit regardless of AI.

How to Set Up the WordPress AI Client on Your Site

Getting started takes only a few minutes. Here is a practical checklist that works for most sites.

Step 1: Update to WordPress 7.0 or later

The AI Client and Connectors require WordPress 7.0 or newer. As always, take a full backup before a major update and test on a staging copy if your site is business-critical. If you want a quick, disposable test environment, WordPress Playground and Studio are excellent for trying new core features without touching production. It is also a good moment to confirm you are on a modern PHP version; our guide to the best PHP version for WordPress explains the options.

Step 2: Choose and connect a provider

Open Settings › Connectors, pick the provider you want, install its provider plugin when prompted, and add your API key. Each provider has its own pricing, model range and data-handling terms, so read them and choose the one that best suits your project. You can connect more than one provider if different plugins or tasks benefit from different models.

Step 3: Store keys the production-friendly way

For live sites, consider defining the key as a constant in wp-config.php or as a server environment variable instead of saving it in the database:

// wp-config.php – keep real keys out of version control.
define( 'ANTHROPIC_API_KEY', 'your-key-here' );

Make sure wp-config.php is never committed to a public repository, and rotate keys if a team member leaves or a key is ever exposed. Setting a monthly spending limit in your provider dashboard is another simple safeguard that gives you peace of mind.

Step 4: Add AI features

Once a provider is connected, any plugin built on the AI Client can use it. The Connectors screen also points to the official AI Experiments plugin from the WordPress AI team, which demonstrates features such as generating titles, excerpts and image alt text. It is a great way to see the AI Client in action before writing any code.

Code editor on a laptop screen showing a PHP integration with the WordPress AI Client

Using wp_ai_client_prompt(): A Developer Walkthrough

Now for the fun part. The builder pattern makes AI calls read almost like a sentence. The simplest possible request looks like this:

$text = wp_ai_client_prompt( 'Explain object caching in two sentences.' )
    ->generate_text();

if ( is_wp_error( $text ) ) {
    return; // Log or display a friendly message.
}

echo wp_kses_post( $text );

Notice the WordPress conventions: failures come back as a WP_Error, and output is escaped before it is printed. Treat AI output exactly like any other untrusted input.

Configuring the prompt

The builder offers chainable methods to shape the request. Commonly used ones include:

  • with_text() – adds the prompt text when you start with an empty builder.
  • using_system_instruction() – sets the role or style the model should follow.
  • using_temperature() – controls how creative or deterministic the answer is.
  • using_model_preference() – expresses which models you would prefer, while still letting the site owner’s configuration decide.
  • as_json_response() – asks for structured JSON that matches a schema you provide.
$summary = wp_ai_client_prompt()
    ->with_text( $post_content )
    ->using_system_instruction( 'Summarise this article in 40 words for a meta description.' )
    ->using_temperature( 0.3 )
    ->generate_text();

Generating more than text

The AI Client is multimodal. Alongside generate_text() there is generate_image(), and the underlying API also covers speech and video generation where a connected provider supports them. If you need token usage or other metadata, methods such as generate_text_result() return a full result object instead of a plain string.

Feature detection: build gracefully

Because the site owner chooses the provider, your plugin should never assume a capability exists. The builder includes helpers such as is_supported_for_text_generation() and is_supported_for_image_generation(). Use them to decide whether to show an AI button at all:

if ( ! function_exists( 'wp_ai_client_prompt' ) ) {
    return; // WordPress older than 7.0.
}

$builder = wp_ai_client_prompt()->with_text( 'test' );

if ( $builder->is_supported_for_text_generation() ) {
    // Safe to show the AI feature in the UI.
}

This pattern means your plugin keeps working on every site: AI-enhanced where a provider is configured, and perfectly usable everywhere else.

Example: An “Suggest an Excerpt” Helper

Let us combine these ideas into a small, practical feature: a REST endpoint that suggests an excerpt for a post. The editor (or a custom button) can call it, and the author decides whether to use the suggestion.

add_action( 'rest_api_init', function () {
    register_rest_route( 'myplugin/v1', '/suggest-excerpt/(?P<id>\\d+)', array(
        'methods'             => 'POST',
        'permission_callback' => function ( $request ) {
            return current_user_can( 'edit_post', (int) $request['id'] );
        },
        'callback'            => function ( $request ) {
            $post = get_post( (int) $request['id'] );
            if ( ! $post ) {
                return new WP_Error( 'not_found', 'Post not found.', array( 'status' => 404 ) );
            }

            $excerpt = wp_ai_client_prompt()
                ->with_text( wp_strip_all_tags( $post->post_content ) )
                ->using_system_instruction( 'Write a friendly 30-word excerpt. Plain text only.' )
                ->using_temperature( 0.4 )
                ->generate_text();

            if ( is_wp_error( $excerpt ) ) {
                return $excerpt;
            }

            return array( 'excerpt' => sanitize_text_field( $excerpt ) );
        },
    ) );
} );

A few details make this example production-ready:

  • The permission callback ensures only people who can edit the post can trigger a request. Every AI call uses your paid API quota, so never expose prompt endpoints to anonymous visitors.
  • The content is stripped of tags before it is sent, which keeps prompts smaller and cheaper.
  • The response is sanitised before being returned, and errors are passed back as proper REST errors.
  • The human stays in control: the endpoint suggests, the author approves.

Security, Privacy and Cost Best Practices

AI features are powerful, and a little planning keeps them safe and affordable. These practices work well on sites of any size.

Control who can trigger AI requests

Always pair AI features with capability checks such as current_user_can(). For extra control, the AI Client also provides a filter, wp_ai_client_prevent_prompt, that lets site owners or developers stop specific prompts from running. This is useful for agencies who want a global policy, for example disabling AI on a regulated client site.

Be transparent about data

When content is sent to an AI provider, it leaves your server. Update your privacy policy to describe which features use AI and which provider processes the data. Avoid sending personal data such as customer emails or order details unless you have a clear legal basis and your provider agreement covers it.

Keep costs predictable

  • Cache AI results in post meta or transients so the same content is never processed twice.
  • Run bulk jobs in the background instead of on page load; our guide to WordPress cron jobs and Action Scheduler shows how.
  • Use lower temperatures and concise system instructions for predictable, shorter answers.
  • Set usage alerts and spending caps in your provider account.

Keep a human in the loop

AI suggestions are a starting point. Review generated titles, excerpts and alt text before publishing, especially for factual or regulated content. Good alt text, for example, should describe the image in context, which also supports the accessibility practices covered in our WCAG 2.2 checklist for WordPress.

Practical Use Cases for Site Owners and Agencies

With one shared AI layer, a range of helpful workflows becomes easy to build or adopt:

  • Editorial helpers: title ideas, excerpt drafts, and meta description suggestions that editors refine.
  • Accessibility support: first-draft alt text for large media libraries, reviewed by a person.
  • Content operations: tagging and categorisation suggestions for big archives.
  • Customer-facing features: product description drafts for stores, or FAQ suggestions from support content.
  • Internal tooling: summarising long form submissions or support tickets for busy teams.

For agencies, the biggest win is consistency. You can document one approach to credentials, one policy for which features are enabled, and one set of plugins that respect the site owner’s provider choice. If you also optimise for AI-driven search, our article on AEO in WordPress pairs nicely with this guide.

Migrating an Existing AI Plugin to the WordPress AI Client

If you maintain a plugin that already talks to an AI provider directly, moving to the AI Client is a smooth, incremental process:

  1. Wrap your current calls behind a small internal function so the rest of your code does not care how the request is made.
  2. Detect the AI Client with function_exists( 'wp_ai_client_prompt' ) and use it when available.
  3. Fall back gracefully to your existing integration on older WordPress versions during the transition.
  4. Retire your own key field once most users are on 7.0 or later, pointing them to Settings › Connectors instead.
  5. Document the change in your changelog so site owners know where their credentials now live.

The result is less code to maintain, fewer support questions about API keys, and a plugin that works with whichever provider your users prefer.

Frequently Asked Questions

Does WordPress 7.0 send my content to AI automatically?

No. Core ships the AI Client and the Connectors screen, but no provider is bundled. Nothing is sent anywhere until you connect a provider and use a plugin or feature that calls the client.

Which AI providers are supported?

The Connectors screen in WordPress 7.0 offers Anthropic, Google and OpenAI, each through its own provider plugin. Because the architecture is provider-agnostic, additional providers can be added by the community.

Is the AI Client the same as the Abilities API?

They are complementary. The Abilities API (WordPress 6.9) describes what your site can do so agents can call it. The AI Client (WordPress 7.0) lets your site call an AI model. Many modern AI features use both.

Can I use the AI Client on a site running an older WordPress version?

The wp_ai_client_prompt() function exists only in WordPress 7.0 and later. Plugins should check for it with function_exists() and offer a fallback or hide AI features on older versions.

Conclusion

The WordPress AI Client and Connectors are a thoughtful foundation rather than a flashy feature, and that is exactly why they matter. Site owners get one place to manage AI providers, developers get a clean and well-documented API, and the whole ecosystem gains a shared standard that respects user choice. Start by connecting a provider on a staging site, try the AI Experiments plugin, and then build one small, human-reviewed feature like the excerpt helper above. You will be ready for the AI-assisted future of WordPress, on your own terms.

References and Further Reading

Images: Ales Nesetril and Arnold Francisca on Unsplash.

Leave a Reply

Your email address will not be published. Required fields are marked *