AI Editor Assistant
A secure, server-side AI assistant for the WordPress block editor. Rewrite, summarize, expand, and tone-shift content from a Gutenberg sidebar - with proper API key handling, per-user rate limiting, and a usage log. No client-side keys, no SaaS lock-in.
by Dan Lapteacru · github.com/danlapteacru/gutenberg-ai-assistant · website
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/danlapteacru/gutenberg-ai-assistant/archive/refs/heads/main.zipReadme
AI Editor Assistant
A WordPress plugin that adds an AI-powered writing assistant to the Gutenberg editor. It runs all API calls server-side so your Anthropic key is never sent to the browser, handles per-user rate limiting to keep costs predictable, and logs every request for auditing. The sidebar lets authors rewrite, summarize, expand, or shift the tone of selected blocks without leaving the editor.
Features
- AI writing actions — rewrite, summarize, expand, and tone-shift selected block content directly from the editor sidebar.
- Server-side API calls — all requests to the Anthropic API are made from PHP; the API key never reaches the client.
- Key resolution chain — the plugin checks
AI_EDITOR_ASSISTANT_ANTHROPIC_KEYconstant, then theAI_EDITOR_ASSISTANT_ANTHROPIC_KEYenvironment variable, then the value saved on the Settings page. - Per-user rate limiting — configurable request cap per user to prevent runaway costs.
- Usage logging — every API call is recorded with user, token count, and timestamp. No prompt content is stored.
- Gutenberg sidebar — a dedicated sidebar panel registered via
@wordpress/pluginsso it feels native to the editor. - Capability checks — only users with the
edit_postscapability can access the assistant.
Installation
Composer (recommended)
composer require danlapteacru/ai-editor-assistant
Manual
- Download the latest release from GitHub.
- Upload the
ai-editor-assistantfolder towp-content/plugins/. - Run
composer install --no-devinside the plugin directory. - Run
npm install && npm run buildto compile the JavaScript assets. - Activate the plugin in Plugins > Installed Plugins.
Configuration
The plugin resolves the Anthropic API key in this order:
- PHP constant (highest priority)
- Environment variable
- Settings page value (lowest priority)
To use a constant, add this to wp-config.php:
define('AI_EDITOR_ASSISTANT_ANTHROPIC_KEY', 'sk-ant-...');
Alternatively, set the AI_EDITOR_ASSISTANT_ANTHROPIC_KEY environment variable on your server, or enter the key on the Settings > AI Editor Assistant page in the WordPress admin.
Security Notes
- The API key is resolved and used on the server only. It is never exposed to the browser or included in any REST response.
- All REST endpoints require the
edit_postscapability, so subscribers and unauthenticated visitors cannot trigger API calls. - Per-user rate limiting prevents any single account from generating excessive requests.
- Prompt and completion content is never written to the database. The usage log records only metadata: user ID, token counts, model, and timestamp.
Cost Control
- View per-user and aggregate usage under Tools > AI Usage Log in the WordPress admin.
- Rate limits and maximum token counts are configurable to cap spending.
- The default model is
claude-sonnet-4-6. Override it with theai_editor_assistant_modelfilter.
Extending
Filters
| Filter | Description | Default |
|---|---|---|
ai_editor_assistant_model |
Override the Anthropic model used for requests | claude-sonnet-4-6 |
Actions
- The activation hook creates the usage-log database table automatically on plugin activation.
Development Setup
Requires PHP 8.1+, Node 20+, and Composer.
# Install PHP dependencies
composer install
# Install JS dependencies and build assets
npm install
npm run build
# Start the dev watcher (hot reload)
npm run start
# Run PHPCS
vendor/bin/phpcs
# Run PHPUnit
vendor/bin/phpunit
Requirements
- WordPress 6.4+
- PHP 8.1+
- Node 20+ (for building JS assets)
License
GPL-2.0-or-later. See LICENSE for details.