Skip to content

WordPress 7.0 AI Client: How We Built AI Page Assembly into Elayne

By Jasper Frumau Elayne

WordPress 7.0 ships a native AI layer — and we have been running experiments with it against our own Elayne block theme. This post is a technical breakdown of what we built and why it matters. If you are a developer, you will want to read every section. If you are an SME considering a new site build, skip to “What You Actually See” — because what is coming to Elayne is genuinely useful.

What Is the WordPress AI Client?

WordPress 7.0 introduces WordPress\AiClient\AiClient — a provider-agnostic abstraction layer that lets any plugin talk to AI models without hard-coding API keys or writing provider-specific integrations.

The fluent API looks like this:

wp_ai_client_prompt( $prompt )
    ->using_system_instruction( $system )
    ->as_json_response( $schema )
    ->using_model_preference(
        'mistral-large-latest',
        'claude-sonnet-4-6',
        'gpt-4.1',
        'gemini-2.0-flash'
    )
    ->generate_text();

One chain. Provider-agnostic. The model preference list is a cascade: if Mistral is not configured, the client falls through to Claude, then OpenAI, then Gemini — whichever provider is available and has credentials. The same plugin code works in any environment regardless of which AI provider you have set up.

WordPress 7.0 ships built-in connectors for OpenAI, Claude, and Gemini in Settings → Connectors. Mistral is not in that UI, but it can be added via a Composer package — more on that below.

What We Built

Our plugin (elayne-ai-test) wires three things together:

  1. The Elayne pattern registry — all your pre-built page sections (hero, features, testimonials, CTAs, and more)
  2. The WordPress AI Client — to send prompts and receive structured JSON back
  3. The Abilities API — a new WP 7.0 feature that exposes plugin capabilities to AI agents

The result: an admin describes a page in plain English, the AI selects the right Elayne patterns in the right order, and a draft page is created — assembled from your existing patterns, ready to open in the block editor.

The Technical Breakdown

Pattern Introspection

The first step is knowing what patterns are available. The plugin reads directly from WordPress’s WP_Block_Patterns_Registry — the same registry Gutenberg reads when you browse patterns in the block editor:

function elayne_ai_get_patterns(): array {
    $all = WP_Block_Patterns_Registry::get_instance()->get_all_registered();

    foreach ( $all as $p ) {
        if ( empty( $p['slug'] ) || ! str_starts_with( $p['slug'], 'elayne/' ) ) {
            continue;
        }
        $patterns[] = [
            'slug'       => $p['slug'],
            'title'      => $p['title'] ?? '',
            'categories' => $p['categories'] ?? [],
            'keywords'   => $p['keywords'] ?? [],
        ];
    }

    return $patterns;
}

The AI always sees the live, current catalog — not a hardcoded list that drifts out of sync when patterns are added or removed.

Allowlist Validation

Before any pattern slug touches wp_insert_post, it goes through two checks:

// 1. Format check — must match elayne/[a-z0-9-]+
if ( ! preg_match( '/^elayne\/[a-z0-9-]+$/', $slug ) ) {
    continue;
}

// 2. Registry check — must be actually registered
if ( ! in_array( $slug, $registered_slugs, true ) ) {
    continue;
}

The AI cannot hallucinate a pattern into existence. If it returns elayne/fictional-section, both checks fail and the slug is silently dropped. If no valid slugs survive, the function returns a WP_Error instead of creating an empty page. Page assembly is always safe, even when the model confabulates.

The Abilities API

The Abilities API is one of the more forward-looking parts of WordPress 7.0. wp_register_ability() lets plugins expose discrete capabilities to AI agents — think of it as WordPress’s version of tool-calling.

We register two abilities:

  • elayne/list-patterns — returns the current Elayne pattern catalog, optionally filtered by category (hero, features, cta, and others). Any AI agent can call this to discover what is available before making decisions.
  • elayne/create-page — takes a title and an ordered list of pattern slugs, runs them through the allowlist validator, and creates a draft page. Exposed via REST, guarded by the publish_pages capability.
wp_register_ability(
    'elayne/create-page',
    [
        'label'               => 'Create Page from Elayne Patterns',
        'category'            => 'content',
        'input_schema'        => [
            'type'       => 'object',
            'properties' => [
                'title'    => [ 'type' => 'string' ],
                'patterns' => [ 'type' => 'array', 'items' => [ 'type' => 'string' ] ],
                'status'   => [ 'type' => 'string', 'enum' => [ 'draft', 'publish' ] ],
            ],
            'required' => [ 'title', 'patterns' ],
        ],
        'execute_callback'    => fn( $params ) => elayne_ai_create_page( ... ),
        'permission_callback' => fn() => current_user_can( 'publish_pages' ),
        'meta'                => [ 'show_in_rest' => true ],
    ]
);

The practical implication: in the future, an AI assistant embedded in WordPress could call elayne/list-patterns autonomously, decide which sections fit a brief, then call elayne/create-page without a human clicking through a form. The groundwork is already there.

Mistral via Composer

Our model preference cascade starts with Mistral. WordPress 7.0’s built-in connector UI supports OpenAI, Claude, and Gemini — but not Mistral. To add it, we use the saarnilauri/ai-provider-for-mistral Composer package and register the provider manually during init:

add_action(
    'init',
    function () {
        $registry = \WordPress\AiClient\AiClient::defaultRegistry();
        $registry->registerProvider(
            \AiProviderForMistral\Provider\ProviderForMistral::class
        );
    },
    5  // priority 5 — runs before AI Client is first used
);

The Composer distribution of the package excludes the plugin bootstrap file, so manual registration is required. The API key lives in .env as MISTRAL_API_KEY. Mistral does not appear in Settings → Connectors — it uses Composer autoloading instead of the built-in connector UI.

The AI Prompt Chain

The system instruction defines strict assembly rules for the AI: use between 3 and 7 patterns, only use slugs from the provided catalog, always start with a hero pattern if one fits, always end with a CTA or contact pattern, and avoid placing two consecutive grid or card patterns back to back.

The user’s description is the prompt. The full Elayne pattern catalog — slug, title, categories — is appended as context. The AI returns structured JSON validated against a schema:

{
  "title": "Luxury Spa Homepage",
  "patterns": [
    "elayne/hero-two-tone",
    "elayne/feature-grid",
    "elayne/testimonial-card",
    "elayne/cta-newsletter"
  ],
  "reasoning": "Hero sets the brand tone, features highlight services, testimonials build trust, newsletter CTA drives repeat bookings."
}

Malformed output, unexpected types, or empty pattern lists all produce a clean error — no fatal crashes, no partially assembled pages. The model preference cascade we use:

PriorityModelProvider
1mistral-large-latestComposer + MISTRAL_API_KEY
2mistral-small-latestComposer + MISTRAL_API_KEY
3claude-sonnet-4-6Settings → Connectors
4claude-opus-4-6Settings → Connectors
5claude-haiku-4-5Settings → Connectors
6gpt-4.1Settings → Connectors
7gemini-2.0-flashSettings → Connectors

What You Actually See

The admin interface lives under Tools → Elayne AI Test. A status panel at the top shows at a glance whether each component is online: WP AI Client, Abilities API, Mistral provider, and how many Elayne patterns are currently registered.

Below that is a single text area. Type something like:

A homepage for a luxury spa with hero, team, testimonials and booking CTA

Submit, wait a few seconds, and a success notice appears with a link to the new draft page, the list of patterns that were used, and the AI’s reasoning for its choices. Open the draft in the block editor and everything is already laid out — hero at the top, content sections in the middle, CTA at the bottom — ready to fill in with real content rather than built from scratch.

For SMEs, the workflow changes from picking sections one by one in the editor to describing what you need and reviewing a structured draft. The heavy lifting is done before you open the editor.

What Is Coming Next

This is a demo running on a WordPress 7.0 beta environment. The goal is to ship AI page assembly as a production feature in Elayne — so that starting a new page goes from a blank canvas to a structured draft in seconds.

WordPress 7.0 is currently in beta. The AI Client API is stable enough to build against, but the Abilities API is still evolving. We are tracking upstream changes and will update the Elayne integration as the API stabilises before general release.

If you are planning a new website build and want to hear about early access to Elayne’s AI page builder when it ships, get in touch. If you are a developer interested in the WP 7.0 AI Client and want to talk through the integration, reach out — we are happy to walk through it.

Demo Plugin Code: https://github.com/imagewize/elayne-ai-demo
WordPress 7.0 Beta Details: https://wordpress.org/news/2026/02/wordpress-7-0-beta-1/

Leave a Reply