WP Agent AI
WP Agent AI — Intelligent content assistant for the WordPress Gutenberg block editor
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/devmohsin/wp-agent-ai/archive/refs/heads/main.zipAn intelligent content assistant for the WordPress Gutenberg block editor. Generate structured, publication-ready content using AI — directly inside the editor.
What It Does
WP Agent AI adds an AI Content Generator block to the Gutenberg block inserter. A user describes what they want in plain English, selects a content type and tone, clicks Generate, and the AI returns fully editable WordPress core blocks — headings, paragraphs, buttons, lists, and quotes — inserted directly into the editor at the exact position of the generator block.
Supported content types:
- Hero Section
- Feature List
- FAQ
- Testimonials
- Call to Action
- Paragraph
Requirements
| Requirement | Minimum Version |
|---|---|
| WordPress | 6.3 |
| PHP | 8.0 |
| OpenRouter API Key | Required (see Configuration) |
Installation
- Upload the
wp-agent-aifolder to/wp-content/plugins/ - Activate the plugin through Plugins → Installed Plugins in the WordPress admin
- Navigate to WP Agent AI → Settings to configure your API key
- Insert the AI Content Generator block anywhere in the Gutenberg editor
Building Assets (Development)
npm install
npm run build
For active development with file watching:
npm run start
Configuration
API Key
- Sign up at openrouter.ai and generate an API key
- Go to WordPress Admin → WP Agent AI → Settings
- Paste your API key into the OpenRouter API Key field
- Click Test Connection to verify the key is valid
- Save settings
The API key is encrypted before being stored in the database. It is never exposed in the browser, in JavaScript files, or in REST API responses.
Model Selection
Select the AI model to use for content generation from the Model dropdown. Available options: GPT-4o, GPT-4o-mini, Claude Sonnet, Gemini Flash, DeepSeek Chat v3.
Cost guidance:
- Use GPT-4o or Claude Sonnet for hero sections and calls to action
- Use GPT-4o-mini or DeepSeek for feature lists, FAQs, and paragraphs
Usage
- Open any post or page in the Gutenberg editor
- Click the + block inserter and search for AI Content Generator
- Insert the block at the position where you want the content to appear
- Type a description of what you want to generate
- Select Content Type, Tone, and Length
- Click Generate
- The AI-generated content is inserted immediately as fully editable native WordPress blocks (headings, paragraphs, buttons, etc.) at the block's position — the generator block removes itself
- Click Regenerate to try again with the same prompt, or use the Refine input to give specific improvement instructions before regenerating
- Click Start Over to reset the prompt and start fresh
Security
- API key is AES-256 encrypted at rest — never stored in plain text
- All REST endpoints require a valid WordPress nonce
- All REST endpoints require the
edit_postscapability — guests and subscribers are blocked - All user inputs are sanitised server-side before the API call
- All AI-generated content is passed through
wp_kses_post()before being returned - Rate limiting enforced per user (10 requests/60 seconds) and globally (daily spend cap)
Known Limitations
- Requires an active internet connection to reach the OpenRouter API
- Generation speed depends on the selected model and OpenRouter server load (typically 3–10 seconds)
- The plugin does not support streaming responses in the current version
- Content history / undo beyond the editor's native undo stack is not implemented in v1.0.0
- On shared hosting with a 30-second PHP execution limit,
set_time_limit(120)is called per request — this works on most hosts but may not be permitted on all configurations
Changelog
1.0.0
- Initial release
- AI Content Generator block
- OpenRouter API integration with model selection
- Admin settings page with encrypted API key storage and test connection
- Full error handling for all failure scenarios
- Rate limiting and daily spend cap
License
GPL-2.0-or-later — see GNU GPL v2