fix: update image models, handle upstream errors in HTTP 200

Three issues found in activity logs:

1. Image model IDs stale — FLUX and Seedream removed from OpenRouter.
   Updated to current models: Gemini 2.5/3.1 Flash Image, Gemini 3 Pro
   Image, GPT-5 Image/Mini. Default changed to gemini-2.5-flash-image.

2. openrouter/free router wraps upstream 429 errors in HTTP 200 body
   with error object. Both text and image response parsers now detect
   this pattern and surface a proper RuntimeException.

3. Image request used modalities: ["image"] but Gemini needs
   ["image", "text"]. Updated to include both.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
peptiderepo
2026-04-18 10:47:05 +07:00
parent cf3d97c0c3
commit 862d7e40e6
6 changed files with 63 additions and 45 deletions

View File

@@ -23,52 +23,44 @@ class PRAutoBlogger_Settings_Fields_Extended {
public static function get_image_models(): array {
return [
[
'id' => 'black-forest-labs/flux-2-pro',
'name' => 'FLUX.2 Pro',
'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' => __( 'Good quality, low cost. Recommended.', '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' => __( 'High quality, fast. Recommended.', 'prautoblogger' ),
'description' => __( 'Highest quality Google. Premium.', 'prautoblogger' ),
],
[
'id' => 'black-forest-labs/flux-1.1-pro',
'name' => 'FLUX 1.1 Pro',
'id' => 'openai/gpt-5-image-mini',
'name' => 'GPT-5 Image Mini',
'provider' => 'openrouter',
'cost_per_image' => 0.04,
'cost_per_image' => 0.02,
'capabilities' => [ 'image_generation' ],
'description' => __( 'Previous gen Pro. Slightly pricier.', 'prautoblogger' ),
'description' => __( 'OpenAI budget image model.', 'prautoblogger' ),
],
[
'id' => 'black-forest-labs/flux-1.1-pro-ultra',
'name' => 'FLUX 1.1 Pro Ultra',
'id' => 'openai/gpt-5-image',
'name' => 'GPT-5 Image',
'provider' => 'openrouter',
'cost_per_image' => 0.06,
'cost_per_image' => 0.08,
'capabilities' => [ 'image_generation' ],
'description' => __( 'Highest quality FLUX. Premium.', 'prautoblogger' ),
],
[
'id' => 'bytedance/seedream-3.0',
'name' => 'Seedream 3.0',
'provider' => 'openrouter',
'cost_per_image' => 0.003,
'capabilities' => [ 'image_generation' ],
'description' => __( 'Budget. Good quality, very low cost.', 'prautoblogger' ),
],
[
'id' => 'google/gemini-2.5-flash-preview:image',
'name' => 'Gemini 2.5 Flash Image',
'provider' => 'openrouter',
'cost_per_image' => 0.01,
'capabilities' => [ 'image_generation' ],
'description' => __( 'Google multimodal. Text-in-image.', 'prautoblogger' ),
],
[
'id' => 'openai/gpt-image-1',
'name' => 'GPT Image 1',
'provider' => 'openrouter',
'cost_per_image' => 0.04,
'capabilities' => [ 'image_generation' ],
'description' => __( 'OpenAI. Photorealistic style.', 'prautoblogger' ),
'description' => __( 'OpenAI premium. Photorealistic.', 'prautoblogger' ),
],
[
'id' => 'flux-1-schnell',