---
title: "GeminiProvider"
description: "Recommended for blocks and layouts – Gemini handles deeply nested JSON schemas more reliably than other providers."
canonical_url: "https://kirby.tools/docs/copilot/php-classes/providers/gemini"
---

# GeminiProvider

> Recommended for blocks and layouts – Gemini handles deeply nested JSON schemas more reliably than other providers.

Use Google Gemini through Google's OpenAI-compatible endpoint. Configuration mirrors [`OpenAIProvider`](/docs/copilot/php-classes/providers/openai) – only the default base URL and model differ.

```php
final class GeminiProvider extends OpenAIProvider
{
    public const DEFAULT_BASE_URL = 'https://generativelanguage.googleapis.com/v1beta/openai';
}
```

When no `model` is configured, the provider falls back to `gemini-3.1-pro-preview`.

<callout color="info" icon="i-ri-external-link-line" to="https://ai.google.dev/gemini-api/docs/openai">

See Google's documentation on the **OpenAI compatibility layer** for the full feature support matrix.

</callout>

## Configuration

```php [config.php]
return [
    'johannschopplich.copilot' => [
        'provider' => 'google',
        'providers' => [
            'google' => [
                'apiKey' => env('GOOGLE_API_KEY'),
                'model' => 'gemini-3.1-pro-preview',
                'completionModel' => 'gemini-3.5-flash',
            ],
        ],
    ],
];
```

<tip>

Gemini handles deeply nested JSON schemas more reliably than other providers – the recommended choice for blocks and layout generation. The free tier on AI Studio is generous enough for development and small projects.

</tip>

<note>

Despite extending `OpenAIProvider`, the `apiKey` config path is `providers.google.apiKey` (driven by `ProviderName::Google`'s string value `'google'`).

</note>

---

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