---
title: "AI Strategy Override"
description: "Force AI translation for a single CLI run without changing global config."
canonical_url: "https://kirby.tools/docs/content-translator/cli-automation/ai-strategy"
---

# AI Strategy Override

> Force AI translation for a single CLI run without changing global config.

The fourth parameter on `translateContent()` overrides the configured strategy for one call. Drop in a `CopilotAIStrategy` to translate a page through Copilot AI even when DeepL is the global default.

<code-collapse>

```php [site/commands/translate-page-ai.php]
use JohannSchopplich\ContentTranslator\Translation\Strategies\CopilotAIStrategy;
use Kirby\CLI\CLI;

return [
    'description' => 'Translates a page using AI, overriding the configured strategy.',
    'args' => [
        'language' => [
            'description' => 'The target language to translate the content to.',
            'defaultValue' => 'de'
        ]
    ],
    'command' => static function (CLI $cli): void {
        $kirby = $cli->kirby();
        $defaultLanguage = $kirby->defaultLanguage()->code();
        $targetLanguage = $cli->arg('language');

        $siteChildren = $kirby->site()->children();
        $titles = array_map('strval', $siteChildren->pluck('title'));
        $input = $cli->radio(
            'Which page should be translated?',
            $titles
        );
        $response = $input->prompt();
        $cli->success('Selected page: ' . $response);

        $page = $siteChildren->findBy('title', $response);
        if ($page === null) {
            $cli->error('Page "' . $response . '" not found.');
            return;
        }

        $strategy = new CopilotAIStrategy();

        $translator = $page->translator();
        $translator->copyContent($targetLanguage, $defaultLanguage);
        $translator->translateContent($targetLanguage, $targetLanguage, $defaultLanguage, $strategy);
        $translator->translateTitle($targetLanguage, $targetLanguage, $defaultLanguage);
        // $translator->translateSlug($targetLanguage, $targetLanguage, $defaultLanguage);

        $cli->success('Successfully translated ' . $page->id() . ' via AI');
    }
];
```

</code-collapse>

```bash
kirby translate-page-ai de
```

Pass a custom prompt to the strategy constructor for domain-specific runs:

```php
$strategy = new CopilotAIStrategy(
    systemPrompt: 'You are a medical translator. Preserve clinical terminology.',
);
```

<callout color="info" icon="i-ri-arrow-right-line" to="/docs/content-translator/php-classes/strategies">

For the full strategy interface and built-in implementations, see **Strategies**.

</callout>

---

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