A 3B Llama 3.2 model takes up around 2 GB on disk and runs on a server with 8 GB of RAM without sending a single byte to third parties. Connecting Ollama to WordPress lets you generate meta descriptions, alt text, or drafts from your own infrastructure, at zero cost per token and with data that never leaves the server. This guide covers the entire process: installation, connection architecture, integration via plugin or code, and security settings.
Why Connect Ollama to WordPress
Ollama is an MIT-licensed open source runtime that runs models like Llama 3.2, Mistral, or Gemma locally. Its REST API runs on port 11434 and accepts requests from any application with network access, WordPress included.
For high-volume tasks, the economics are simple: a commercial API charges per token generated, while a local model costs what you already paid for hardware. A thousand meta descriptions a month cost the same as a single one: nothing. That zero cost only holds if your server can actually run the model, and that’s where the requirements come in.
Prerequisites
Ollama installs on Linux, macOS, and Windows, with native Windows support since 2024. A quantized 3B model works well with 8 GB of RAM; 7B and 8B models need 16 GB to perform smoothly. The requirement that stalls the most projects is the network: WordPress must be able to reach port 11434. If WordPress and Ollama share a VPS, localhost is all you need; on shared hosting, a direct connection is impossible and you’ll need a tunnel or a proxy.
Step 1: Install Ollama and Download a Model
On Ubuntu, install with curl -fsSL https://ollama.com/install.sh | sh and download a model with ollama pull llama3.2. The ollama list command confirms the download, and curl http://localhost:11434/api/tags returns the available models. If that call works from the server’s terminal, the foundation is in place.
Choose your model carefully: each one changes the outcome. We’ve compared the models that work best with WordPress in our Ollama model comparison.
Step 2: Define the Connection Architecture
There are three scenarios. If both services share a server, point WordPress to http://localhost:11434 and leave everything else as is. If they run on different machines within the same network, set OLLAMA_ORIGINS to your WordPress domain to allow CORS and point to the internal IP.
If Ollama lives in your office and WordPress in the cloud, a tunnel such as Cloudflare Tunnel bridges the two; ngrok works well for quick tests. Ollama’s API includes no authentication, so port 11434 should never be exposed to the internet unprotected.
Step 3: Connect It With a Plugin
The fastest route is AI Engine, the plugin by Meow Apps, which supports OpenAI-compatible custom endpoints. Ollama exposes a compatible API at http://localhost:11434/v1, so all it takes is adding a provider with that base URL, a dummy key, and the model of your choice. From there, the plugin covers chatbots via shortcode and text generation from the WordPress editor. The full setup takes less than ten minutes.
Step 4: Direct Integration With PHP
If you prefer full control, the WordPress HTTP API handles the connection without any plugins. This snippet, placed in functions.php, registers a shortcode that asks the local model for a meta description:
add_shortcode( 'meta_ia', function () {
$res = wp_remote_post( 'http://localhost:11434/api/generate', [
'timeout' => 120,
'body' => wp_json_encode( [
'model' => 'llama3.2',
'prompt' => 'Metadescripción de 155 caracteres para: ' . get_the_title(),
'stream' => false,
] ),
] );
return json_decode( wp_remote_retrieve_body( $res ), true )['response'] ?? '';
} );
With stream set to false, Ollama returns the entire result in a single JSON object, which is far easier to process from PHP.
Security and Real-World Limits
By default, Ollama listens only on 127.0.0.1; keep that configuration unless you know what you’re doing. If you need to expose it, put nginx in front with basic authentication or use Cloudflare Access. The real limit is the hardware: the model stays loaded in RAM, and a chatbot with sustained traffic can overwhelm a modest server. For repeated queries, store the results with WordPress transients and lighten the load on the model server.
Conclusion
Connecting Ollama to WordPress doesn’t require rewriting your workflow: start with a low-risk use case, such as generating meta descriptions for posts that are already published, and review the results before automating anything visitor-facing. To try it today, install Ollama on your VPS, run ollama pull llama3.2, verify the /api/tags endpoint, and add the provider in AI Engine. If you test another model or use case (summarizing comments, tagging, translation), tell us about it in the comments: the model you choose makes a big difference to the final result.
Don’t have a server to run it on? In our VPS guide we compare providers honestly, and if you’d rather not lift a finger, Deploy Express will have everything set up for you within 24 hours.