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.
temperaturecontrols randomness;max_tokenslimits 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
- 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. - 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.
- 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
jobpost. - 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_tokensat 1024, long postings were cut off mid-array and failed to parse. We raised it to 2048. - Randomness.
temperatureis 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
| Challenge | What to do |
|---|---|
| The answer is not guaranteed | Ask for structured output, validate it, handle failures |
| Cost and rate limits | Batch work, cache results, process in the background |
| Latency | Never block a page load; use cron or a queue |
| Keys and secrets | Use core Connectors or environment config, not options in plain text |
| Privacy | Every request sends your content to a third party; decide what may leave the site |
| Prompt injection | User content can contain instructions; treat it as data, check permissions in code |
| Vendor lock-in | Keep 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
| Area | Example |
|---|---|
| Editor | Suggest titles, summaries, alt text |
| Content operations | Classify, tag, translate, extract fields |
| SEO | Generate and review metadata |
| Support | Triage incoming messages, draft answers |
| Search | Q&A over site content |
| Administration | Agents 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
- Abilities API: how a plugin declares what AI may do
- MCP for WordPress: how external agents reach those abilities
- AI & WordPress
- RAG: grounding answers in your own content
- Automation: LLMs inside workflows
- Agentic Engineering services