AI Router
Capability-based AI provider routing for WordPress 7.0
Works with WordPress 7.0-RC2, tested using WordPress AI. Tested text generation and image generation, using two separate Azure OpenAI deployments (gpt-4.1 for text, gpt-image-1 for images).
Route AI requests to different provider configurations based on capability. Configure multiple instances of the same AI provider (e.g., GPT-4o for text, gpt-image-1 for images) and let AI Router automatically select the right one.
Why AI Router?
Section titled “Why AI Router?”WordPress 7.0’s AI Client SDK only allows one configuration per provider type. AI Router solves this by enabling:
- Multiple configurations of the same provider (e.g., separate Azure OpenAI deployments)
- Capability-based routing — text generation to GPT-4, images to DALL-E
- Default fallback — set a default for unmatched capabilities
- Automatic selection — no code changes needed in plugins using the AI SDK
Supported Providers
Section titled “Supported Providers”AI Router works with any AI provider registered with the WordPress 7 AI Client SDK. Providers are discovered dynamically at runtime via ProviderDiscovery.
Tested providers:
- OpenAI
- Azure OpenAI
- Anthropic
- Ollama
Other providers (Google AI, Cohere, etc.) will work automatically when installed — no code changes required.
Requirements
Section titled “Requirements”- WordPress 7.0+
- PHP 8.3+
- Underlying AI provider plugin(s) installed (e.g.,
ai-provider-for-openai)
Installation
Section titled “Installation”From GitHub Release
Section titled “From GitHub Release”- Download
ai-router.zipfrom Releases - Upload via Plugins → Add New → Upload Plugin
- Activate the plugin
From Source
Section titled “From Source”cd wp-content/pluginsgit clone https://github.com/soderlind/ai-router.gitcd ai-routercomposer install --no-devnpm install && npm run buildAutomatic Updates
Section titled “Automatic Updates”The plugin includes a GitHub updater — updates are delivered automatically when new releases are published.
Configuration
Section titled “Configuration”- Go to Settings → Connectors in WordPress admin
- In the AI Router section, click Add Configuration
- Select a provider and configure its settings (API key, model, endpoint)
- Assign capabilities to the configuration
- Optionally set one configuration as default
Capability Mapping
Section titled “Capability Mapping”Map specific capabilities to specific configurations:
text_generation → GPT-4 Configimage_generation → DALL-E Configchat_history → GPT-4 ConfigUnmapped capabilities fall back to the default configuration.
See docs/ for detailed routing logic and architecture.
Development
Section titled “Development”Build Assets
Section titled “Build Assets”npm installnpm run build # Production buildnpm run start # Watch modeRun Tests
Section titled “Run Tests”# PHP tests (PHPUnit + Brain Monkey)composer installcomposer test
# JavaScript tests (Vitest)npm run test:jsnpm run test:js:watchChangelog
Section titled “Changelog”See CHANGELOG.md for version history.
License
Section titled “License”GPL-2.0-or-later — see LICENSE for details.
Author
Section titled “Author”📦 Source: soderlind/ai-router · Edit on GitHub