AI Provider for Google for the WordPress AI Client.
A Google AI (Gemini) provider for the PHP AI Client SDK. Works as both a Composer package and a WordPress plugin.
composer require wordpress/ai-provider-for-google
/wp-content/plugins/ai-provider-for-google/The provider automatically registers itself with the PHP AI Client on the init hook. Simply ensure both plugins are active and configure your API key:
// Set your Google API key (or use the GOOGLE_API_KEY environment variable)
putenv('GOOGLE_API_KEY=your-api-key');
// Use the provider
$result = AiClient::prompt('Hello, world!')
->usingProvider('google')
->generateTextResult();
use WordPress\AiClient\AiClient;
use WordPress\GoogleAiProvider\Provider\GoogleProvider;
// Register the provider
$registry = AiClient::defaultRegistry();
$registry->registerProvider(GoogleProvider::class);
// Set your API key
putenv('GOOGLE_API_KEY=your-api-key');
// Generate text
$result = AiClient::prompt('Explain quantum computing')
->usingProvider('google')
->generateTextResult();
echo $result->toText();
Available models are dynamically discovered from the Google AI API. This includes Gemini models for text generation (with multimodal input support) and Imagen models for image generation. See the Google AI documentation for the full list of available models.
The provider uses the GOOGLE_API_KEY environment variable for authentication. You can set this in your environment or via PHP:
putenv('GOOGLE_API_KEY=your-api-key');
GPL-2.0-or-later
We use cookies to analyze traffic and improve your experience. You can accept or reject analytics cookies.