feat: add OpenRouter image provider for higher-quality image generation

Replaces Cloudflare Workers AI (FLUX.1 schnell) as the default image
provider with OpenRouter, which offers FLUX.2 Pro, Seedream 3.0,
Gemini Flash Image, and GPT Image 1 at comparable or better pricing.

- New provider class (3-file split: provider, pricing, support) reuses
  the existing OpenRouter API key and Cloudflare AI Gateway
- Admin settings: new Image Provider dropdown (openrouter/cloudflare),
  model picker shows all available image models from both providers
- Image pipeline auto-selects the configured provider at construction
- Cost logging now uses actual model name instead of hardcoded flux-1-schnell
- Default model changed to black-forest-labs/flux-2-pro ($0.03/image)
- Unit tests for pricing resolution and provider response parsing

Cost impact: FLUX.2 Pro at $0.03/image vs schnell at $0.0007/image —
~43x more expensive per image, but dramatically better quality. At 2
images/article × 1 article/day = ~$1.80/month. Seedream 3.0 ($0.003)
available as a budget alternative.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
peptiderepo
2026-04-18 09:19:13 +07:00
parent b5e91ba3a6
commit 0a68741945
11 changed files with 852 additions and 44 deletions

View File

@@ -80,22 +80,8 @@ class PRAutoBlogger_Admin_Page {
'generateText' => __( 'Generate Now', 'prautoblogger' ),
'testingText' => __( 'Testing...', 'prautoblogger' ),
'testText' => __( 'Test Connections', 'prautoblogger' ),
// Static Cloudflare image models for the picker (no registry API for these).
// FLUX.1 [dev] removed from Cloudflare Workers AI in April 2026.
'cloudflareModels' => [
[
'id' => 'flux-1-schnell',
'name' => 'FLUX.1 [schnell]',
'provider' => 'cloudflare',
'context_length' => 0,
'input_price_per_m' => 0,
'output_price_per_m' => 0,
'cost_per_image' => 0.0007,
'capabilities' => [ 'cloudflare_image' ],
'deprecated' => false,
'description' => __( 'Fast + cheap (4 steps). Default choice.', 'prautoblogger' ),
],
],
// Image models for the picker — defined in the settings class to keep this file short.
'imageModels' => PRAutoBlogger_Settings_Fields_Extended::get_image_models(),
] );
}