Wires out the Cloudflare Workers AI image provider across the plugin: - class-image-pipeline.php: drop 'cloudflare' dispatch branch; Runware becomes the unrecognised-provider fallback - class-image-model-registry.php: remove flux-1-schnell/cloudflare row; update provider-enum docblocks (runware|openrouter only) - class-settings-fields-extended.php: remove three CF fields (cloudflare_ai_token, cloudflare_account_id, cf_image_via_gateway); drop Cloudflare mention from model-picker + NSFW retry descriptions - class-admin-page.php: remove prautoblogger_cloudflare_ai_token from the encrypted-options list - interface-image-provider.php: retarget preamble @see at Runware + OpenRouter; update get_provider_name() example - class-image-nsfw-blocked.php: generalise preamble (Runware + OpenRouter can raise this) Also cleans stale CF Workers AI mentions in: class-ajax-handlers.php, interface-model-registry.php, class-image-nsfw-retry.php, class-open-router-image-pricing.php, prautoblogger.php. The Cloudflare AI Gateway path (in class-open-router-config.php, class-settings-fields.php 'prautoblogger_ai_gateway_base_url', class-open-router-request-builder.php cache headers) is intentionally untouched — it fronts OpenRouter and is unrelated to the CF Workers AI image provider.
112 lines
4.0 KiB
PHP
112 lines
4.0 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* Static registry of available image generation models.
|
|
*
|
|
* What: Returns a hardcoded list of image models for the admin model picker.
|
|
* No API discovery — updated manually when providers add/remove models.
|
|
* Who calls it: PRAutoBlogger_Admin_Page (model picker UI + save-time provider
|
|
* derivation) and PRAutoBlogger_Image_Pipeline (provider lookup).
|
|
* Dependencies: None.
|
|
*
|
|
* @see admin/class-settings-fields-extended.php — Image settings reference this registry.
|
|
* @see core/class-image-pipeline.php — Derives provider from picked model.
|
|
* @see providers/class-runware-image-provider.php — Runware FLUX backend.
|
|
*/
|
|
class PRAutoBlogger_Image_Model_Registry {
|
|
|
|
/**
|
|
* Get all available image generation models.
|
|
*
|
|
* Each entry contains:
|
|
* - id: Model identifier used in API calls.
|
|
* - name: Human-readable display name.
|
|
* - provider: 'runware' | 'openrouter'.
|
|
* - cost_per_image: Estimated USD cost per generation.
|
|
* - capabilities: Array of capability tags.
|
|
* - description: Short description for the admin UI.
|
|
*
|
|
* Ordered cheapest-to-most-expensive within each provider, with the
|
|
* recommended default (Runware schnell) at the top.
|
|
*
|
|
* @return array<int, array<string, mixed>>
|
|
*/
|
|
public static function get_models(): array {
|
|
return [
|
|
[
|
|
'id' => 'runware:100@1',
|
|
'name' => 'FLUX.1 schnell (Runware)',
|
|
'provider' => 'runware',
|
|
'cost_per_image' => 0.0006,
|
|
'capabilities' => [ 'image_generation' ],
|
|
'description' => __( 'Default. Fast, very cheap, comic-friendly fidelity.', 'prautoblogger' ),
|
|
],
|
|
[
|
|
'id' => 'runware:101@1',
|
|
'name' => 'FLUX.1 dev (Runware)',
|
|
'provider' => 'runware',
|
|
'cost_per_image' => 0.02,
|
|
'capabilities' => [ 'image_generation' ],
|
|
'description' => __( 'Higher fidelity FLUX. ~30x schnell cost.', 'prautoblogger' ),
|
|
],
|
|
[
|
|
'id' => 'google/gemini-2.5-flash-image',
|
|
'name' => 'Gemini 2.5 Flash Image (Nano Banana)',
|
|
'provider' => 'openrouter',
|
|
'cost_per_image' => 0.005,
|
|
'capabilities' => [ 'image_generation' ],
|
|
'description' => __( 'Mid-tier quality, proven.', 'prautoblogger' ),
|
|
],
|
|
[
|
|
'id' => 'google/gemini-3.1-flash-image-preview',
|
|
'name' => 'Gemini 3.1 Flash Image (Nano Banana 2)',
|
|
'provider' => 'openrouter',
|
|
'cost_per_image' => 0.008,
|
|
'capabilities' => [ 'image_generation' ],
|
|
'description' => __( 'Latest Google. Better quality.', 'prautoblogger' ),
|
|
],
|
|
[
|
|
'id' => 'google/gemini-3-pro-image-preview',
|
|
'name' => 'Gemini 3 Pro Image (Nano Banana Pro)',
|
|
'provider' => 'openrouter',
|
|
'cost_per_image' => 0.03,
|
|
'capabilities' => [ 'image_generation' ],
|
|
'description' => __( 'Highest quality Google. Premium.', 'prautoblogger' ),
|
|
],
|
|
[
|
|
'id' => 'openai/gpt-5-image-mini',
|
|
'name' => 'GPT-5 Image Mini',
|
|
'provider' => 'openrouter',
|
|
'cost_per_image' => 0.02,
|
|
'capabilities' => [ 'image_generation' ],
|
|
'description' => __( 'OpenAI budget image model.', 'prautoblogger' ),
|
|
],
|
|
[
|
|
'id' => 'openai/gpt-5-image',
|
|
'name' => 'GPT-5 Image',
|
|
'provider' => 'openrouter',
|
|
'cost_per_image' => 0.08,
|
|
'capabilities' => [ 'image_generation' ],
|
|
'description' => __( 'OpenAI premium. Photorealistic.', 'prautoblogger' ),
|
|
],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Return the provider id for a known model, or empty string if the
|
|
* model id is not in the registry.
|
|
*
|
|
* @param string $model_id Model slug from the admin UI.
|
|
* @return string Provider id ('runware' | 'openrouter' | '').
|
|
*/
|
|
public static function provider_for( string $model_id ): string {
|
|
foreach ( self::get_models() as $model ) {
|
|
if ( ( $model['id'] ?? '' ) === $model_id ) {
|
|
return (string) ( $model['provider'] ?? '' );
|
|
}
|
|
}
|
|
return '';
|
|
}
|
|
}
|