Overview
Drive Copilot from PHP – the same provider stack the Panel uses, available to CLI commands, hooks, and custom workflows.
Generate AI content from PHP – CLI commands, hooks, custom controllers, sister plugins like Content Translator. The same provider stack the Panel uses, exposed as a public API.
Available since v3.8. The Panel proxy is unchanged – this PHP API gives you direct access to the same provider transports.
Components
Minimal Example
use JohannSchopplich\Copilot\AI\Client;
$response = Client::instance()->generateObject(
messages: [
['role' => 'system', 'content' => 'You return JSON only.'],
['role' => 'user', 'content' => 'List three primary colors.'],
],
schema: [
'type' => 'object',
'properties' => [
'colors' => ['type' => 'array', 'items' => ['type' => 'string']],
],
'required' => ['colors'],
'additionalProperties' => false,
],
);
print_r($response['colors']);
The provider is selected from johannschopplich.copilot.provider. Switch providers without touching this code.