Adding AI Features to a WordPress Site: Plugins vs. a Custom API Integration
WordPress developers keep hearing the same request from clients: “Can we add AI to the site?” Usually the request is vague. Sometimes it means a chatbot. Sometimes it means automatic summaries for blog posts, or alt text for a media library that has been neglected for years.
The good news is that most of these features are achievable without rebuilding a theme. The real decision is whether to use an existing plugin or connect to an AI model API yourself. This guide walks through four common features, the two implementation routes, and the privacy and cost questions that should be settled before anything goes live.
Four AI features that make sense on WordPress
1. A chat assistant
A chat assistant can answer questions about opening hours, shipping, services or documentation. The useful versions are grounded in the site’s own content: pages, FAQs and product data. A generic chatbot that only knows what its underlying model learned during training will happily invent a return policy.
2. Post summaries
A short summary at the top of a long article helps readers decide whether to keep reading, and it can be reused for meta descriptions and social posts. Summaries can be generated when a post is saved and stored in a custom field, so the model is called once per edit rather than on every page view.
3. Image alt text
Many media libraries are full of images with empty alt attributes. Vision-capable models can draft descriptive alt text in bulk. This improves accessibility and gives search engines more context, but a person should review drafts for product images and anything showing people, because models sometimes guess at details they cannot actually see.
4. Multilingual content
AI translation can produce first drafts of pages in other languages, which fits well alongside established multilingual plugins. Treat the output as a draft for a fluent reviewer, especially for legal pages, checkout flows and anything brand-sensitive.
Route one: use a plugin
There are now many plugins that add AI chat, content generation or alt text to WordPress. For a simple brochure site or a blog, this is usually the fastest path.
Advantages: quick setup, an admin interface for non-technical editors, and updates handled by the plugin author.
Things to check before installing:
- Which AI provider the plugin sends data to, and whether you can choose.
- Whether it stores conversations or content on its own servers.
- How it handles API keys. Keys should never be exposed in front-end JavaScript.
- Whether it limits usage, so a bot or a traffic spike cannot run up a large bill.
- How actively it is maintained, and how it behaves alongside your caching and security plugins.
Route two: build a custom integration
For agencies, theme developers and sites with specific requirements, calling a model API directly from a small custom plugin gives far more control. You decide what content is sent, how responses are cached, and which model handles each task.
A minimal pattern is to keep the endpoint and key in wp-config.php, call the API from server-side PHP, and cache the result in post meta:
// wp-config.php
define( ‘AI_API_BASE’, ‘your-gateway-base-url’ );
define( ‘AI_API_KEY’, ‘your-key-here’ );
// In your plugin
function mytheme_ai_summary( $post_id ) {
$cached = get_post_meta( $post_id, ‘_ai_summary’, true );
if ( $cached ) {
return $cached;
}
$content = wp_strip_all_tags( get_post_field( ‘post_content’, $post_id ) );
$response = wp_remote_post( AI_API_BASE . ‘/chat/completions’, array(
‘timeout’ => 30,
‘headers’ => array(
‘Authorization’ => ‘Bearer ‘ . AI_API_KEY,
‘Content-Type’ => ‘application/json’,
),
‘body’ => wp_json_encode( array(
‘model’ => ‘your-chosen-model’,
‘messages’ => array(
array( ‘role’ => ‘system’, ‘content’ => ‘Summarize this article in two sentences.’ ),
array( ‘role’ => ‘user’, ‘content’ => mb_substr( $content, 0, 8000 ) ),
),
) ),
) );
if ( is_wp_error( $response ) ) {
return ”;
}
$data = json_decode( wp_remote_retrieve_body( $response ), true );
$summary = $data[‘choices’][0][‘message’][‘content’] ?? ”;
if ( $summary ) {
update_post_meta( $post_id, ‘_ai_summary’, $summary );
}
return $summary;
}
Because this request uses the widely adopted OpenAI-compatible chat format, the same code can work with many providers by changing only the base URL and model name. Some developers point it at a gateway such as OpenLux, which uses one API key for models from several providers, bills pay-as-you-go with no monthly fee, and shows the usage and cost of each request in its console. That makes it practical to use a small, fast model for summaries and alt text while reserving a more capable one for the chat assistant.
Advantages: full control over data, caching and model choice, with no dependency on a third-party plugin’s roadmap.
Trade-offs: you maintain the code, handle errors and timeouts, and keep up with API changes.
Privacy: decide what leaves the site
Whichever route you choose, write down what data is sent to the AI provider. For summaries and alt text, that is usually published content, which carries little risk. Chat assistants are different: visitors may type names, order numbers, email addresses or health details.
- Tell visitors they are talking to an automated assistant, and point them to your privacy policy.
- Avoid sending logged-in user data unless the feature truly needs it.
- Check the provider’s data retention and model training policies.
- Strip obvious personal data before sending, where possible.
- If the site serves visitors in the EU, review the feature with whoever handles GDPR compliance.
Cost control: build limits in from day one
AI features are billed by usage, so costs grow with traffic and with how much text each request contains. A few habits keep them predictable:
- Cache aggressively. Generate summaries and alt text once and store them. Never call the API on every page load.
- Trim the input. Send the relevant section of content, not the whole page with navigation and footer.
- Rate-limit the chat. Cap messages per visitor per hour and block obvious bots.
- Match the model to the task. Short, structured tasks rarely need the largest model.
- Review usage weekly. A sudden jump often means a loop, a bot or a misconfigured cron job.
- Set a spending limit with your provider if it supports one.
Which route should you pick?
For a small business site that needs a chat widget and nothing else, a reputable plugin is usually enough. For agencies managing many client sites, theme developers who want AI features built into their products, or sites that handle sensitive data, a lightweight custom integration is often worth the extra effort.
Either way, start with one feature, measure whether visitors actually use it, and expand from there. The best AI feature on a WordPress site is the one that quietly saves someone time, not the one that announces itself the loudest.