The WordPress AI Client is a provider-agnostic API for WordPress code to call generative AI models via a consistent interface. Plugins and Core can use it to provide AI driven features for users, while users maintain full autonomy in choosing which AI provider(s) they want to rely on and how they configure them. This changeset merges the technical foundation for the WordPress AI Client into Core. This foundation was originally implemented in the https://github.com/WordPress/wp-ai-client package, which will be sunset going forward. The underlying https://github.com/WordPress/php-ai-client package is bundled with this changeset and will remain a separate library maintained by the WordPress project, for WordPress Core and the PHP ecosystem. No AI providers are bundled out of the box. Without explicit configuration and explicit calling code, WordPress will not send prompts or data to any external service. Site owners will be able to install plugins to enable usage of specific AI providers, built on top of this foundation. This is the first changeset of two that are most relevant for the AI Client feature. The subsequent change will introduce a configuration screen for different AI providers, where users can install provider plugins, configure their credentials, and enable the canonical WordPress AI plugin. Together, this infrastructure and UI will enable the WordPress ecosystem to build AI features in a seamless and interoperable way. Original merge proposal: https://make.wordpress.org/core/2026/02/03/proposal-for-merging-wp-ai-client-into-wordpress-7-0/ Props jason_the_adams, flixos90, desrosj, dkotter, jorgefilipecosta, peterwilsoncc, johnbillion, jorbin, swissspidy, isotropic. See #64591. Built from https://develop.svn.wordpress.org/trunk@61700 git-svn-id: http://core.svn.wordpress.org/trunk@61008 1a063a9b-81f0-0310-95a4-ce76da25c4cd
35 lines
1.7 KiB
PHP
35 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
* WordPress AI Client API.
|
|
*
|
|
* @package WordPress
|
|
* @subpackage AI
|
|
* @since 7.0.0
|
|
*/
|
|
|
|
use WordPress\AiClient\AiClient;
|
|
|
|
/**
|
|
* Creates a new AI prompt builder using the default provider registry.
|
|
*
|
|
* This is the main entry point for generating AI content in WordPress. It returns
|
|
* a fluent builder that can be used to configure and execute AI prompts.
|
|
*
|
|
* The prompt can be provided as a simple string for basic text prompts, or as more
|
|
* complex types for advanced use cases like multi-modal content or conversation history.
|
|
*
|
|
* @since 7.0.0
|
|
*
|
|
* @param string|MessagePart|Message|array|list<string|MessagePart|array>|list<Message>|null $prompt Optional. Initial prompt content.
|
|
* A string for simple text prompts,
|
|
* a MessagePart or Message object for
|
|
* structured content, an array for a
|
|
* message array shape, or a list of
|
|
* parts or messages for multi-turn
|
|
* conversations. Default null.
|
|
* @return WP_AI_Client_Prompt_Builder The prompt builder instance.
|
|
*/
|
|
function wp_ai_client_prompt( $prompt = null ) {
|
|
return new WP_AI_Client_Prompt_Builder( AiClient::defaultRegistry(), $prompt );
|
|
}
|