A large language model is not a feature you install. It is an external service your code talks to, and WordPress now has a native way to do that. This page covers what an LLM actually does, the three ways it meets WordPress, and what broke for us when we put one to real work.

What an LLM is

  • A text predictor. The model continues text token by token. It does not look things up; it produces the most likely continuation of what you sent.
  • Context window. Everything the model knows about your task must fit into one request: instructions, data, previous messages. Nothing persists between calls unless you send it again.
  • Messages. A request is a list of messages: system (rules), user (task), assistant (previous answers).
  • Parameters. temperature controls randomness; max_tokens limits the answer length.

For a WordPress developer this means one thing: an LLM is an unreliable but powerful function. Your job is to give it the right input and verify the output.

How it works with WordPress

There are three ways a WordPress site and an LLM meet.

flowchart LR
    subgraph WP["WordPress"]
        PLUGIN["Plugin code"]
        AIC["Core AI Client<br/>wp_ai_client_prompt()"]
        CONN["Connectors<br/>provider credentials"]
        ABIL["Abilities API<br/>what is allowed"]
    end
    LLM["LLM provider"]
    AGENT["External agent<br/>Claude, Cursor, CI"]

    PLUGIN -->|1. via core| AIC --> CONN --> LLM
    PLUGIN -->|2. direct HTTP| LLM
    AGENT -->|3. MCP| ABIL --> PLUGIN
  1. Through core: AI Client and Connectors. WordPress core ships wp_ai_client_prompt() and a Connectors registry. Provider credentials are configured once; a plugin asks for a result without storing keys or writing HTTP calls. Our 4WP SEO Helper wraps the core AI Client this way.
  2. Directly from a plugin. The plugin calls a provider API itself. Our 4WP AI Assistant has its own provider layer (Groq and OpenRouter, OpenAI-compatible chat completions). More control, more responsibility: keys, retries, limits.
  3. From the outside in. An agent works with the site instead of the site calling a model. The plugin declares what can be done through the Abilities API, and the agent reaches it through MCP.

Real case: skills from job posts

We use an LLM to turn WordPress job posts into structured data for our market analysis.

  • Input: the content of a job post.
  • Output: JSON with skills, requirements, recommendations and methodology.
  • Storage: two dedicated tables instead of postmeta, so counting is a plain SQL GROUP BY.
  • Result: 74 vacancies processed with openai/gpt-oss-120b.

What we had to fix:

  • Truncated JSON. With max_tokens at 1024, long postings were cut off mid-array and failed to parse. We raised it to 2048.
  • Randomness. temperature is set to 0.1: for extraction we want the same answer every time.
  • Retries. Requests go through a retry wrapper; a provider error is a normal event, not an exception.
  • Messy values. The model returns “REST API” and “REST APIs” as different skills. Extraction needs a normalization layer after it.

Challenges

ChallengeWhat to do
The answer is not guaranteedAsk for structured output, validate it, handle failures
Cost and rate limitsBatch work, cache results, process in the background
LatencyNever block a page load; use cron or a queue
Keys and secretsUse core Connectors or environment config, not options in plain text
PrivacyEvery request sends your content to a third party; decide what may leave the site
Prompt injectionUser content can contain instructions; treat it as data, check permissions in code
Vendor lock-inKeep a provider abstraction; core AI Client already gives you one

Opportunities

  • Turn unstructured content into data: posts, forms, tickets, job posts.
  • Give editors drafts instead of empty fields: titles, excerpts, alt text, meta descriptions.
  • Let agents operate the site within declared, permission-checked abilities.
  • Answer questions grounded in your own content with RAG.

Where it is used

AreaExample
EditorSuggest titles, summaries, alt text
Content operationsClassify, tag, translate, extract fields
SEOGenerate and review metadata
SupportTriage incoming messages, draft answers
SearchQ&A over site content
AdministrationAgents performing tasks through abilities

What a specialist should be able to do

  • Choose between core AI Client, a direct provider call and an agent workflow.
  • Design structured output and handle invalid responses.
  • Keep LLM calls out of the request path.
  • Define what data may leave the site.
  • Expose site actions through abilities with proper permission checks.

FAQ

Do I need a plugin to use an LLM in WordPress?
Core now ships an AI Client and Connectors. A plugin still decides what to ask and what to do with the answer.

Which provider should I use?
Start with what core Connectors support. Keep your code provider-agnostic so you can switch.

Can an LLM write to my database?
Only through your code. Validate the output first, and let agents act only through abilities with permission checks.

Is LLM output safe to publish as is?
No. Treat it as a draft: review it, escape it, and never trust it as HTML.

Why not call the API on every page view?
It is slow, costs money per request and can fail. Generate once, store the result, reuse it.

Related