by Felix Arntz on WordPress.org
Makes AI centrally available in WordPress, whether via PHP, REST API, JavaScript, or WP-CLI - for any provider.

The AI Services settings screen where users can paste their AI service credentials
This WordPress plugin introduces central infrastructure which allows other plugins to make use of AI capabilities. It exposes APIs that can be used in various contexts, whether you need to use AI capabilities in server-side or client-side code. Furthermore, the APIs are agnostic of the AI service – whether that’s Anthropic, Google, or OpenAI, to only name a few, you can use any of them in the same way. You can also register your own implementation of another service, if it is not supported out of the box.
The plugin does intentionally not come with specific AI driven features built-in, except for an AI Playground screen to explore AI capabilities as well as a settings screen to configure AI service credentials. The purpose of this plugin is to facilitate use of AI by other plugins. As such, it is a perfect use-case for plugin dependencies.
Here’s a (non-comprehensive) feature list:
Disclaimer: The AI Services plugin is still in its early stages, with a limited feature set and more being added. A crucial part of refining the plugin is shaping the APIs to make them easy to use and cover the different generative AI capabilities that the AI services offer in a uniform way. That’s why your feedback is much appreciated!
While the plugin APIs allow registering custom AI services, the plugin comes with a few popular AI services built-in. These AI services rely on the respective third party API. Their use is optional and it is up to you to choose which third party service you would like to use or whether you would like to use multiple.
The use of the third party AI services is subject to the respective terms of service. The following third party services are supported out of the box:
Generate the answer to a prompt in PHP code:
use Felix_Arntz\AI_Services\Services\API\Enums\AI_Capability;
use Felix_Arntz\AI_Services\Services\API\Helpers;
if ( ai_services()->has_available_services() ) {
$service = ai_services()->get_available_service();
try {
$candidates = $service
->get_model(
array(
'feature' => 'my-test-feature',
'capabilities' => array( AI_Capability::TEXT_GENERATION ),
)
)
->generate_text( 'What can I do with WordPress?' );
$text = Helpers::get_text_from_contents(
Helpers::get_candidate_contents( $candidates )
);
echo $text;
} catch ( Exception $e ) {
// Handle the exception.
}
}
Generate the answer to a prompt in JavaScript code:
const helpers = aiServices.ai.helpers;
const { hasAvailableServices, getAvailableService } = wp.data.select( 'ai-services/ai' );
if ( hasAvailableServices() ) {
const service = getAvailableService();
try {
const candidates = await service.generateText(
'What can I do with WordPress?',
{ feature: 'my-test-feature' }
);
const text = helpers.getTextFromContents(
helpers.getCandidateContents( candidates )
);
console.log( text );
} catch ( error ) {
// Handle the error.
}
}
Generate the answer to a prompt using WP-CLI:
wp ai-services generate-text "What can I do with WordPress?" --feature=my-test-feature
You can also use a specific AI service, if you have a preference, for example the google service.
Generate the answer to a prompt using a specific AI service, in PHP code:
use Felix_Arntz\AI_Services\Services\API\Enums\AI_Capability;
use Felix_Arntz\AI_Services\Services\API\Helpers;
if ( ai_services()->is_service_available( 'google' ) ) {
$service = ai_services()->get_available_service( 'google' );
try {
$candidates = $service
->get_model(
array(
'feature' => 'my-test-feature',
'capabilities' => array( AI_Capability::TEXT_GENERATION ),
)
)
->generate_text( 'What can I do with WordPress?' );
$text = Helpers::get_text_from_contents(
Helpers::get_candidate_contents( $candidates )
);
echo $text;
} catch ( Exception $e ) {
// Handle the exception.
}
}
Refer to the plugin documentation for granular examples including explainers.
For complete examples such as entire plugins built on top of the AI Services infrastructure, please see the examples directory on GitHub.