This document provides instructions for testing the AI plugin's REST API endpoints using curl.
- WordPress site running (e.g.,
https://wordpress-ai.test) - Administrator account credentials
- curl installed
-
Create an Application Password:
- Log into WordPress admin
- Go to Users → Your Profile
- Scroll to "Application Passwords"
- Create a new application password (name it "Testing" or similar)
- Copy the generated password (you'll only see it once)
-
Make the request:
curl -X POST "https://wordpress-ai.test/wp-json/wp-abilities/v1/abilities/ai/excerpt-generation/run" \
-u "your-username:application-password" \
-H "Content-Type: application/json" \
-d '{
"input": {
"content": "This is a sample article about artificial intelligence and machine learning. AI has revolutionized many industries including healthcare, finance, and transportation. Machine learning algorithms can now process vast amounts of data to identify patterns and make predictions that were previously impossible."
}
}'-
Get a nonce:
- Log into WordPress admin in your browser
- Open browser DevTools → Console
- Run:
wpApiSettings.nonce(if available)
-
Get your session cookie:
- Open DevTools → Application/Storage → Cookies
- Copy the
wordpress_logged_in_[hash]cookie value
-
Make the request:
curl -X POST "https://wordpress-ai.test/wp-json/wp-abilities/v1/abilities/ai/excerpt-generation/run" \
-H "Content-Type: application/json" \
-H "X-WP-Nonce: YOUR_NONCE_HERE" \
-H "Cookie: wordpress_logged_in_[hash]=YOUR_COOKIE_VALUE_HERE" \
-d '{
"input": {
"content": "This is a sample article about artificial intelligence and machine learning. AI has revolutionized many industries including healthcare, finance, and transportation. Machine learning algorithms can now process vast amounts of data to identify patterns and make predictions that were previously impossible."
}
}'Endpoint: POST /wp-json/wp-abilities/v1/abilities/ai/excerpt-generation/run
Request Body:
{
"input": {
"content": "This is a sample article about artificial intelligence and machine learning. AI has revolutionized many industries including healthcare, finance, and transportation. Machine learning algorithms can now process vast amounts of data to identify patterns and make predictions that were previously impossible."
}
}Full curl command (using Application Password):
curl -X POST "https://wordpress-ai.test/wp-json/wp-abilities/v1/abilities/ai/excerpt-generation/run" \
-u "admin:xxxx xxxx xxxx xxxx xxxx xxxx" \
-H "Content-Type: application/json" \
-d '{
"input": {
"content": "This is a sample article about artificial intelligence and machine learning. AI has revolutionized many industries including healthcare, finance, and transportation. Machine learning algorithms can now process vast amounts of data to identify patterns and make predictions that were previously impossible."
}
}'Expected Response:
{
"excerpts": [
"This article explores how artificial intelligence and machine learning have transformed industries like healthcare, finance, and transportation. These technologies enable algorithms to analyze massive datasets, uncovering patterns and generating predictions that were once beyond human capability.",
"...",
"..."
]
}Endpoint: POST /wp-json/wp-abilities/v1/abilities/ai/title-generation/run
Request Body:
{
"input": {
"content": "Your article content here...",
"candidates": 3
}
}Full curl command:
curl -X POST "https://wordpress-ai.test/wp-json/wp-abilities/v1/abilities/ai/title-generation/run" \
-u "admin:xxxx xxxx xxxx xxxx xxxx xxxx" \
-H "Content-Type: application/json" \
-d '{
"input": {
"content": "Your article content here...",
"candidates": 3
}
}'- Cause: Invalid or missing authentication
- Solution: Verify your Application Password or nonce/cookie are correct
- Cause: Using GET instead of POST
- Solution: Ensure you're using
-X POSTin curl
- Cause: Invalid input format
- Solution: Ensure the request body has
"input"as the top-level key, and the JSON is valid
- Cause: Ability not registered
- Solution: Ensure the plugin is activated and the ability is registered
- Create a new POST request
- URL:
https://wordpress-ai.test/wp-json/wp-abilities/v1/abilities/ai/excerpt-generation/run - Authorization:
- Type: Basic Auth
- Username: Your WordPress username
- Password: Application Password (not your regular password)
- Headers:
Content-Type: application/json
- Body:
- Select "raw" and "JSON"
- Paste the JSON with
inputwrapper