Global Configuration

Configure AI providers, API keys, models, and global defaults for the Kirby Copilot plugin.

Configure Kirby Copilot globally in your config.php file. This sets default configuration properties that apply to all plugin instances, including AI provider settings, generation parameters, and default behavior for view buttons and sections.

AI Provider Configuration

Kirby Copilot supports multiple AI providers. You must configure at least one provider with valid credentials for the plugin to function.

OpenAI

GPT-5 and GPT-5 Mini models for content generation.

Google

Gemini models. Recommended for blocks and layout generation. Free tier available!

Anthropic

Claude models for nuanced content generation.

Mistral

European AI models with custom base URL support.

For generating Blocks and Layouts or other structured data, we recommend Google Gemini models. Create a new Google API key and add it to the configuration along with the AI model such as Gemini 3 Flash. Usage is currently free!

Basic Provider Setup

All provider configurations are nested under the johannschopplich.copilot key:

config.php
return [
    'johannschopplich.copilot' => [
        'provider' => 'google', // Choose your primary provider
        'providers' => [
            'google' => [
                'apiKey' => 'YOUR_API_KEY',
                // Model for content generation
                'model' => 'gemini-3-pro-preview',
                // Model for writer field inline suggestions
                'completionModel' => 'gemini-3-flash-preview'
            ]
        ]
    ]
];

Each provider supports two model configurations:

  • model – Used for content generation (text, blocks, layouts).
  • completionModel – Used for inline suggestions in writer fields (should be fast and lightweight).

Provider Examples

return [
    'johannschopplich.copilot' => [
        'provider' => 'openai',
        'providers' => [
            'openai' => [
                'apiKey' => env('OPENAI_API_KEY'),
                'model' => 'gpt-5-mini'
            ]
        ]
    ]
];

Default Models

If you do not specify a model or completionModel, Kirby Copilot uses sensible defaults for each provider:

ProviderGeneration Model (model)Completion Model (completionModel)
OpenAIgpt-5.2gpt-5-nano
Googlegemini-3-pro-previewgemini-3-flash-preview
Anthropicclaude-sonnet-4-5-20250929claude-haiku-4-5-20251001
Mistralmistral-large-latestmistral-small-latest
The completionModel is used for inline suggestions in writer fields. It should be a fast, lightweight model optimized for quick inline suggestions.

AI Generation Settings

systemPrompt String

Global system prompt that defines how the AI should structure and approach content generation. This can be overridden by view button props or section configuration.

Kirby Copilot ships with a well-crafted default system prompt that handles response formatting for different field types (text, markdown, rich-text) and preserves formatting when working with selected text. In most cases, the default works out of the box and customization is not necessary.

Learn more about the default system prompt and when to customize it.

excludedBlocks Array

Specify block types to exclude from structured data generation in blocks and layout fields. This is useful for custom block types for which AI generation is not desired.

Default: [] (no blocks excluded)

config.php
return [
    'johannschopplich.copilot' => [
        'excludedBlocks' => ['custom-form', 'widget', 'advertisement'],
    ]
];

reasoningEffort String

Controls the depth of reasoning applied during content generation. This property works with all reasoning-capable models across providers (GPT-5, Gemini 3, Claude 4).

Default: low
Options: none, low, medium, high

config.php
return [
    'johannschopplich.copilot' => [
        'reasoningEffort' => 'medium'
    ]
];
Modern AI models are designed as reasoning models with different underlying architectures. The model manages creativity internally based on the reasoning effort level, making manual temperature configuration obsolete.

completion Array | Boolean

Controls inline suggestions in writer fields. Inline suggestions are enabled by default for all writer fields.

Default: ['debounce' => 1000]

To disable inline suggestions globally:

config.php
return [
    'johannschopplich.copilot' => [
        'completion' => false
    ]
];

To customize the debounce timing (minimum 500ms):

config.php
return [
    'johannschopplich.copilot' => [
        'completion' => [
            'debounce' => 1500 // Wait 1.5 seconds after typing stops
        ]
    ]
];
Learn more about inline suggestions behavior and keyboard shortcuts.

promptTemplates Array

Define prompt templates that appear for all Panel users. Config-defined templates are read-only and displayed alongside user-created templates.

Default: [] (uses built-in defaults)

return [
    'johannschopplich.copilot' => [
        'promptTemplates' => [
            [
                'label' => 'Apply House Style',
                'prompt' => 'Format the text according to our editorial style: artist names in bold, album titles in italics, use curly quotation marks.'
            ],
            [
                'label' => 'Add Spotify Links',
                'prompt' => 'Find all album titles in the text and wrap them in Markdown links to their Spotify pages.'
            ]
        ]
    ]
];
When config templates are defined, they replace the built-in default templates. Existing user templates saved in local storage are preserved and remain editable.
Learn more about prompt templates and how they appear in the Panel.

baseUrl String

Custom base URL for the AI provider API. This property is configured per provider alongside apiKey and model. Useful when using proxy services, custom API endpoints, or self-hosted AI services like llama.cpp.

Default: Provider-specific default URL

config.php
return [
    'johannschopplich.copilot' => [
        'provider' => 'openai',
        'providers' => [
            'openai' => [
                'apiKey' => env('OPENAI_API_KEY'),
                'model' => 'llama-3.2-3b-instruct',
                'baseUrl' => 'https://llama.example.com/v1'
            ]
        ]
    ]
];

Global Defaults

You can set global defaults that apply to both view buttons and sections. These can be overridden in individual blueprints.

Available Global Defaults

For detailed descriptions of each property, see the View Button & Section Configuration page. The following properties can be set globally:

systemPrompt
String
Default system prompt that controls how the AI structures and formats generated content across all view buttons and fields.
userPrompt
String
Default user prompt that appears when generation dialogs open.
logLevel
String
Default logging level for debugging AI generation. Options: error, warn, info, debug.

Basic Global Configuration

config.php
return [
    'johannschopplich.copilot' => [
        'provider' => 'google', // Primary provider
        'providers' => [
            'google' => [
                'apiKey' => env('GOOGLE_API_KEY'),
                'model' => 'gemini-3-pro-preview'
            ]
        ],

        // Global Defaults
        'logLevel' => 'info',
        'excludedBlocks' => ['custom-form']
    ]
];

Security Improved in v3

Starting with v3, all AI provider requests are routed through a server-side proxy. Your API keys are no longer exposed in browser network requests, protecting them from Panel users.

This is a significant security improvement over v2, where API keys were visible in client-side network requests. No additional configuration is required – the proxy is enabled automatically.

We still recommend following these best practices:

  • Use environment variables for API keys.
  • Create separate API keys for each project/client.
  • Set usage limits on your AI provider accounts.
  • Monitor API usage regularly.
config.php
return [
    'johannschopplich.copilot' => [
        'providers' => [
            'openai' => [
                'apiKey' => env('OPENAI_API_KEY'), // Use environment variables
            ]
        ]
    ]
];

Dynamic API Keys since v3.1.0

For advanced use cases, you can provide a closure that resolves the API key dynamically at runtime. The closure receives the Kirby instance as its first argument, allowing user-specific or context-dependent API keys.

config.php
return [
    'johannschopplich.copilot' => [
        'providers' => [
            'openai' => [
                'apiKey' => function (\Kirby\Cms\App $kirby) {
                    // Example: Return different keys based on user role
                    $user = $kirby->user();

                    if ($user?->role()->name() === 'admin') {
                        return env('OPENAI_API_KEY_ADMIN');
                    }

                    return env('OPENAI_API_KEY_USER');
                }
            ]
        ]
    ]
];

This is useful for scenarios like:

  • Different API keys or rate limits per user role.
  • Fetching keys from external services or databases.
  • Multi-tenant setups with client-specific credentials.

Configuration Precedence

Global configuration serves as the foundation, with more specific configurations overriding global defaults:

  1. Global configuration (in config.php)
  2. Section configuration (in blueprint sections) & view button props (in blueprint buttons)
config.php
return [
    'johannschopplich.copilot' => [
        'logLevel' => 'warn',
        'systemPrompt' => 'Global prompt…'
    ]
];
Blueprint Override
sections:
  copilot:
    type: copilot
    field: content
    logLevel: debug # Overrides global
    # systemPrompt inherited from global

buttons:
  copilot:
    logLevel: debug # Overrides both global

Complete Configuration Example

config.php
return [
    'johannschopplich.copilot' => [
        'provider' => 'google', // Primary provider
        'providers' => [
            'google' => [
                'apiKey' => env('GOOGLE_API_KEY'),
                'model' => 'gemini-3-pro-preview',
                'completionModel' => 'gemini-3-flash-preview'
            ],
            'openai' => [
                'apiKey' => env('OPENAI_API_KEY'),
                'model' => 'gpt-5-mini',
                'completionModel' => 'gpt-5-nano'
            ]
        ],

        // Generation settings
        'reasoningEffort' => 'low',
        'completion' => [
            'debounce' => 1000
        ],

        // Global defaults
        'excludedBlocks' => [
            'contact-form',
            'newsletter-signup',
            'advertisement'
        ]
    ]
];