With AI Tools Task Endpoint, you can effortlessly extend AI capabilities from your WordPress website, enhancing user experience with richer features.
Enable Public Endpoint
After OpenAI Tools plugin configured on WordPress site, go to Settings > AI Tools > Public AI Tools Task
, check it and save it.
Example Code
Curl
curl --location --request POST 'https://yourdomain.com/wp-admin/admin-ajax.php' \
--form 'action="ai_tools_task"' \
--form 'model="gpt-3.5-turbo"' \
--form 'model_group="OpenAI"' \
--form 'task="Tell me a joke"' \
--form 'content="Use letter a to z"'
Python
import requests
files = {
"action": (None, "ai_tools_task"),
"model": (None, "gpt-3.5-turbo"),
"model_group": (None, "OpenAI"),
"task": (None, "Tell me a joke"),
"content": (None, "Use letter a to z"),
}
response = requests.post(
"https://yourdomain.com/wp-admin/admin-ajax.php", files=files
)
print(response.text)
Dart
var request = http.MultipartRequest('POST', Uri.parse('https://yourdomain.com/wp-admin/admin-ajax.php'));
request.fields.addAll({
'action': 'ai_tools_task',
'model': 'gpt-3.5-turbo',
'model_group': 'OpenAI',
'task': 'Tell me a joke',
'content': 'Use letter a to z'
});
http.StreamedResponse response = await request.send();
if (response.statusCode == 200) {
print(await response.stream.bytesToString());
}
else {
print(response.reasonPhrase);
}
R
library(httr)
body = list(
'action' = 'ai_tools_task',
'model' = 'gpt-3.5-turbo',
'model_group' = 'OpenAI',
'task' = 'Tell me a joke',
'content' = 'Use letter a to z'
)
res <- VERB("POST", url = "https://yourdomain.com/wp-admin/admin-ajax.php", body = body, encode = 'multipart')
cat(content(res, 'text'))
Example Response
{
"success": true,
"value": "Why was the equal sign so humble?\n\nBecause he knew he wasn't less than or greater than anyone else!"
}