Wednesday, July 22, 2026
HomeEveryday WordPressArchitecture and a real-world example

Architecture and a real-world example


Before WordPress 7.0, plugins adding AI features had to request and manage an API key to communicate with an AI provider.

This came with several drawbacks in terms of code weight and maintainability. You had to bundle heavy, proprietary SDK libraries into your plugins and write provider-specific cURL requests.

This fragmented scenario has completely changed with the native AI integration introduced in WordPress 7.0. Today, WordPress features a centralized interface for configuring credentials for various AI providers, along with a new PHP API. This new architecture allows you to send commands, instructions, media files, and data structures seamlessly, while the Core handles the requests.

The new architecture offers substantial benefits for both site admins and plugin developers.

Admins no longer need to configure AI settings across multiple plugins. Starting with WordPress 7.0, you simply install and enable your plugin connectors, enter your API keys into the unified Connectors interface, and they become instantly available to all AI-powered plugins on your site. You can easily monitor AI usage, switch your preferred model, or revoke a provider’s access for all plugins with a single click.

For plugin developers, the advantages are even greater, ranging from data security to code portability and a drastic reduction in technical debt.

Ready to start this journey into the new WordPress AI architecture? Let’s dive in.

The three layers of the WordPress AI architecture

Today, your WordPress sites are natively AI-ready. This is not about out-of-the-box AI features, though, but rather the foundation for building AI-powered websites.

The new architecture is structured across three distinct layers:

AI Connector

Before WordPress 7.0, every plugin that added AI features to your site needed its own system to store and manage your API keys. Your credentials had to be hardcoded into the plugin or managed via a custom settings page. In either case, it was far from an ideal solution for handling sensitive data.

The centralized AI Connectors interface in the WordPress admin dashboard.

A unified interface lets you configure all your AI service providers in one central location. This interface brings several major benefits to site management.

From a management and security standpoint, the biggest advantage is that you only need to set up your providers once in the Connectors interface, and you can then forget about them, regardless of how many plugins use them. If you ever need to change your API keys, you won’t have to reconfigure every plugin; you can update them all at once in the Connectors screen.

Centralizing credentials also improves your site’s security by mitigating the risk of exposing sensitive data through third-party plugins that might be poorly coded or untrustworthy.

Another key advantage is code portability. Your plugins no longer need to know which AI provider you use because the new architecture decouples authentication from plugin logic. This means that if you switch AI providers, your plugin will keep working without requiring a single line of code change.

However, the real breakthrough in portability is the ability for site admins to configure multiple connectors simultaneously. When a plugin triggers a request, WordPress automatically selects the most suitable AI Provider and model to generate the response, based on both the specific configuration of the plugin and the capabilities of the available models.

AI Client

While the Connectors screen provides the configuration UI for AI Providers, the AI Client gives developers the operational tool to communicate with AI models.

It is a native software interface that standardizes interaction with artificial intelligence models through the global wp_ai_client_prompt() function and a unified set of PHP methods.

Reduced technical debt

For developers, a major advantage of the new AI architecture is the reduction of technical debt and dependencies. Before WordPress 7.0, adding AI features came at a very high cost in terms of code maintenance. You had to bundle third-party proprietary SDKs (such as the official libraries for OpenAI or Anthropic) and constantly monitor library versions. This resulted in a heavy plugin codebase and opened the door to compatibility errors.

Furthermore, you had to write many lines of code to handle network logic and response parsing. To make things even worse, the code was vendor-specific, so if you decided to switch AI providers, you would have to rewrite your plugin’s entire network architecture.

The AI Client solves this problem at its root by transferring all this heavy work to the WordPress core. Your code becomes completely agnostic to the AI provider; you only need to write your instructions once, and WordPress will translate them into the model’s specific “dialect”.

Intelligent model selection

A powerful feature of the AI Client’s Fluent Interface is the ability to set preferred models through the using_model_preference() method, available via the wp_ai_client_prompt() builder function. This method lets you declare an ordered list of models for your plugin’s specific task. For example, the following code requests text generation targeting 3 preferred models:

$text_result = wp_ai_client_prompt( 'Convert the following transcript into a concise, blog-ready draft.' )
	->using_model_preference(
		'gemini-2.5-flash',
		'claude-3-5-sonnet',
		'gpt-4o'
	)
	->generate_text();

WordPress will check the providers configured on the Connectors screen and scan the list of models defined in the plugin’s code, selecting the first connector that is also available on the site. If none of the models specified in your code are available among the active Connectors, WordPress will ignore the model preference list and fall back to the first compatible model configured on the site.

This mechanism ensures that your plugin will always work, even if the site admin switches to a different AI provider.

AI Provider

An AI Provider is the company that owns, trains, and hosts the Large Language Models (LLMs) we use every day. OpenAI, Google Gemini, and Anthropic are the most common AI providers supported via dedicated connectors in WordPress 7.0, but developers can register additional custom AI Providers.

When your plugin’s code calls the generate_text() method — or any other generation method — WordPress compiles and sends a data payload to the AI Provider via the endpoint established by the Connector. Here is the sequence of operations that takes place behind the scenes:

  • As a first step, the AI Provider receives the input prompt text along with any attached multimedia files (data payload).
  • Once received, it processes the request, applying any system instructions.
  • From there, it generates the output structured as free text or a JSON object.
  • Finally, it sends the output back to WordPress via an HTTP response.

Every provider offers a wide variety of models with different capabilities, speeds, and prices. These range from models specialized purely in text processing to multimodal models that accept media files (audio, images, video) alongside a text prompt, to models engineered for specific tasks, such as image generation or speech-to-text conversion.

Gemini 3 models
Google’s Gemini 3 model family.

Again, the models available to a WordPress site depend on the AI providers the user configures in the Connectors screen. This means your plugin does not dictate which specific provider to use.



Source link

RELATED ARTICLES
Continue to the category

LEAVE A REPLY

Please enter your comment!
Please enter your name here


Most Popular

Recent Comments