---
title: "Overview"
description: "Drive Copilot from PHP – the same providers and credentials as the Panel, available to CLI commands, hooks, and custom workflows."
canonical_url: "https://kirby.tools/docs/copilot/php-classes"
---

# Overview

> Drive Copilot from PHP – the same providers and credentials as the Panel, available to CLI commands, hooks, and custom workflows.

Two classes make up the surface: `Client` for one-call generation, plus the `Provider` transports for OpenAI, Anthropic, Gemini, and Mistral. Sister plugins like [Content Translator](/docs/content-translator) consume `Client` directly.

<note>

Available since v3.8. The PHP API talks to the same providers as the Panel, without going through the Panel proxy.

</note>

## Components

<card-group>
<card icon="i-ri-rocket-2-line" title="Client" to="/docs/copilot/php-classes/client">

The entry point. One method call generates text or structured JSON via your configured provider.

</card>

<card icon="i-ri-plug-line" title="Providers" to="/docs/copilot/php-classes/providers">

One transport per AI provider: OpenAI, Anthropic, Gemini, Mistral. Switch providers via config – your call sites stay the same.

</card>
</card-group>

## Minimal Example

```php
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.

<callout color="info" icon="i-ri-arrow-right-line" to="/docs/copilot/php-classes/client">

Continue with the **Client** reference for instance vs. singleton, error handling, and DI hooks.

</callout>

---

Every page of this site as Markdown: <https://kirby.tools/sitemap.md>
