# Remove Replicate (RP-1)

Owner decision, 2026-11-13: KimaAI no longer supports Replicate. Existing Replicate environments are removed silently, without an admin notice. Image generation is checked here and kept only if something uses it.

## Where Replicate is today

| Area            | Files                                                                                                                                                                                                                                                                  |
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Provider        | `app/Ai/Providers/Replicate/` (client, `Models` and `Predictions` endpoints), `app/Ai/Providers/Factory.php`                                                                                                                                                           |
| Payload mapping | `app/Ai/AiService.php` (key renames and response handling for Replicate)                                                                                                                                                                                               |
| Model registry  | `AiModels::replicateModels()` and the provider lists in `app/Ai/AiModels.php`                                                                                                                                                                                          |
| Settings        | the provider option in `app/Admin/config/aiServices.php`; the reasoning and temperature model lists in `app/Admin/config/chatbot.php`; `app/Helper.php`                                                                                                                |
| Docblocks       | `premium/app/FunctionCall/ToolRouter.php`, `app/Ai/Providers/Support/Capability.php`                                                                                                                                                                                   |
| Tests           | `tests/unit/Ai/Providers/Replicate/`, `ReplicateIntegrationTest`, Replicate cases in `ImageIntegrationTest`, `ModelListIntegrationTest`, `FactoryTest`, `EnvResolverTest`, e2e seed helpers and specs, Storybook helpers, `RepeatablePage.test.jsx`, wporg screenshots |
| Docs            | `readme.txt` (installation step 3)                                                                                                                                                                                                                                     |

## Image generation

Image generation (`ImageClientInterface`, `AiService` with generation type `image`, `ImageModel` and its table) has one caller: the premium WP-CLI command `wp kimaai run` with `--type=image` (`premium/app/Cli/KimaAICLI.php`). Because it is used, it stays, for OpenAI only. Only the Replicate image path goes.

## Stored settings

AI environments live in `kimaai_options['aiServices']['aiEnvs']`, each with an `id` and a `provider`. Selections point at a slug `<provider>-<id>`. Migration `Version2026111301`, silent and idempotent:

1. Removes every AI environment whose provider is `replicate`.
2. If the chatbot runs on Replicate, it is **left pinned to the removed Replicate slug, and its global widget is switched off** (`chatbot.appearance.isEnable`; shortcodes still render it). That covers both a selected Replicate environment and "default" or empty, which run on the first environment. An empty provider would fall back to the first remaining environment (`Helper::chatbotEnvSlug()`, `AiService::run()`), and the shortcode and the REST endpoint do not check `isEnable`. The dangling slug cannot be resolved, so every chatbot request fails with a configuration error until the owner selects a new provider. The chatbot's provider field lists the removed slug as "no longer available" (`Helper::chatbotAiEnvOptions()`), so the settings screen does not switch it to the first environment on its own (review round 3). Visitors' messages never reach a provider the owner did not choose (found in review rounds 1 and 2).
3. Clears `aiEnv` and `aiModel` of embedding environments (`embedding.embedEnvs`) that pointed at one.
4. Removes the legacy embedding preset (`aiServices.aiPresets.embedEnv`, kept by `Version2026072901` on installs without an embedding environment) when it pointed at one.

## Items

| Item | Title                                                                                   |
| ---- | --------------------------------------------------------------------------------------- |
| RP-1 | This document                                                                           |
| RP-2 | Provider, registry, settings and payload mapping removed                                |
| RP-3 | Migration: Replicate environments and selections that point at them removed, with tests |
| RP-4 | Tests, Storybook, e2e helpers, readme and screenshots without Replicate                 |
