Connect WordPress 7.0 AI to your own Ollama server — no API key, no cloud, no cost.
WordPress 7.0 ships with a native AI integration layer. The problem? It only comes with connectors for cloud providers that require an API key. This plugin bridges that gap, wiring the new WordPress AI Client directly to your local (or self-hosted) Ollama instance.
Run Llama 3, Mistral, Gemma, Phi, Qwen — any model Ollama supports — and use it to power WordPress AI features without sending a single token to the cloud.
| Feature | Details |
|---|---|
| Zero API key | Ollama uses its own local auth; no credentials needed |
| Dynamic model list | Auto-discovers every model installed in Ollama via /v1/models |
| OpenAI-compatible | Uses Ollama's /v1/chat/completions endpoint |
| wp-admin UI | Custom connector card under Settings → Connectors |
| Runtime diagnostics | Card shows connection status and available models live |
| Flexible base URL | Option → constant → env var → sensible default |
| WP AI preferred models | Injects your default model at the top of the preference list |
| GPL-2.0-or-later | Free as in freedom |
| Requirement | Minimum |
|---|---|
| WordPress | 7.0 (AI Client API introduced) |
| PHP | 7.4 |
| Ollama | Any recent release with OpenAI-compatible endpoint |
WordPress 7.0 is required. This plugin depends on
WordPress\AiClient, thewp_connectors_inithook, and@wordpress/connectors— all introduced in WP 7.0.
# Clone directly into your wp-content/plugins directory
cd /path/to/wordpress/wp-content/plugins
git clone https://github.com/roddyka/api-provider-for-ollama.git roddyka-local-ai-connector-for-ollama
Then activate it from Plugins → Installed Plugins in wp-admin.
- Download the
.zipfrom Releases - In wp-admin go to Plugins → Add New → Upload Plugin
- Choose the zip, install and activate
- Install Ollama → ollama.com/download
- Pull a model (example):
ollama pull llama3
- Verify Ollama is running at
http://127.0.0.1:11434 - Activate this plugin in WordPress
- Go to Settings → Connectors and open the Ollama Local card
- The card will auto-detect your running models — pick a default and save
That's it. WordPress AI features (Block Editor AI, AI assistants, etc.) will now use your local Ollama instance.
The base URL is resolved in this priority order:
| Source | Example |
|---|---|
| wp-admin Connector card | Saved to wp_options |
| PHP constant | define('OLLAMA_API_BASE_URL', 'http://my-server:11434'); |
| Environment variable | OLLAMA_API_BASE_URL=http://my-server:11434 |
| Built-in default | http://127.0.0.1:11434/v1 |
The plugin automatically appends /v1 if you omit it.
If Ollama runs on a different machine or Docker container, just set the base URL to that host. Make sure the Ollama port (default 11434) is accessible from your WordPress server.
roddyka-local-ai-connector-for-ollama.php ← entry point, hooks, REST endpoint, settings
src/
autoload.php ← lightweight PSR-4 autoloader (no Composer needed)
Provider/
OllamaProvider.php ← extends AbstractApiProvider; registers with WP AI Client
Models/
OllamaTextGenerationModel.php ← OpenAI-compatible chat completions
Metadata/
OllamaModelMetadataDirectory.php ← dynamic model discovery via /v1/models
Support/
OllamaConfig.php ← centralised URL / model config with priority chain
assets/
connector-card.js ← React UI for the wp-admin Connectors screen
WordPress AI Client (core)
│
├─ asks registry for available providers
│
└─ OllamaProvider (this plugin)
│
├─ OllamaModelMetadataDirectory → GET /v1/models
└─ OllamaTextGenerationModel → POST /v1/chat/completions
Contributions are welcome and encouraged! Here's how to get started:
git clone https://github.com/roddyka/api-provider-for-ollama.git
cd api-provider-for-ollama- PHP 7.4+ with
phpin your PATH - A local WordPress 7.0 install (e.g. wp-env, LocalWP, or plain LAMP/MAMP)
- Ollama running locally
Symlink or copy the plugin folder into wp-content/plugins/roddyka-local-ai-connector-for-ollama/ and activate.
The codebase is intentionally small and dependency-free (no Composer). Key extension points:
| Want to… | Look at… |
|---|---|
| Add image/multimodal support | OllamaModelMetadataDirectory — extend $textCapabilities |
| Support streaming responses | OllamaTextGenerationModel — override request handling |
| Add vision/embedding models | New model class extending the base |
| Improve the admin UI | assets/connector-card.js (plain React via wp.element) |
| Add more config options | OllamaConfig.php + roddyka-local-ai-connector-for-ollama.php REST callback |
- Keep PRs focused on one thing
- Describe what and why in the PR description
- If it's a new feature, open an issue first to discuss
Open an issue with:
- WordPress version
- PHP version
- Ollama version & model(s) in use
- Steps to reproduce
- Streaming response support
- Image / multimodal model support (LLaVA, Moondream)
- Embedding model support
- WordPress.org plugin directory submission
- Unit test suite (PHPUnit)
- GitHub Actions CI
Q: Does this work with Ollama on Docker / a remote server?
A: Yes. Set the base URL in the connector card or via the OLLAMA_API_BASE_URL constant/env var.
Q: Does it conflict with other AI providers (OpenAI, Anthropic)?
A: No. It registers as a separate provider (ollama-local) alongside any other connectors.
Q: What models are supported?
A: Any text generation model you have pulled in Ollama. The plugin discovers them automatically.
Q: I see "unreachable" in the card — what do I do?
A: Make sure ollama serve is running and accessible from the WordPress server. Try curl http://127.0.0.1:11434/v1/models.
GPL-2.0-or-later — free and open source.
Example:
define('OLLAMA_API_BASE_URL', 'http://127.0.0.1:11434/v1');use WordPress\AiClient\AiClient;
$result = AiClient::prompt('Say hello in Portuguese.')
->usingProvider('ollama-local')
->generateTextResult();
echo $result->toText();- This first version focuses on text generation.
- The provider relies on Ollama's OpenAI-compatible APIs (
/v1/modelsand/v1/chat/completions). - The Connectors screen lists this provider as keyless (
authentication: none), which is the normal setup for local Ollama. - The current WordPress Connectors UI only supports built-in auth fields (
api_keyornone), so custom fields like base URL/model are not first-class form inputs there yet.