| 1 |
<?php |
| 2 |
/** |
| 3 |
* Fal.ai Image Provider Settings |
| 4 |
* |
| 5 |
* @package BotWriter |
| 6 |
*/ |
| 7 |
|
| 8 |
if (!defined('ABSPATH')) { |
| 9 |
exit; |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* Get Fal.ai models configuration |
| 14 |
* Updated: December 2025 with latest models |
| 15 |
*/ |
| 16 |
function botwriter_get_fal_models() { |
| 17 |
if (function_exists('botwriter_get_provider_image_models')) { |
| 18 |
$catalog_models = botwriter_get_provider_image_models('fal'); |
| 19 |
if (!empty($catalog_models)) { |
| 20 |
return $catalog_models; |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
return [ |
| 25 |
// Google Nano Banana (newest!) |
| 26 |
'Google' => [ |
| 27 |
'fal-ai/nano-banana-pro' => '🍌 Nano Banana Pro (newest!)', |
| 28 |
'fal-ai/gemini-3-pro-image-preview' => 'Gemini 3 Pro Image', |
| 29 |
], |
| 30 |
// ByteDance Seedream |
| 31 |
'ByteDance' => [ |
| 32 |
'fal-ai/bytedance/seedream/v4.5/text-to-image' => 'Seedream 4.5 (newest!)', |
| 33 |
'fal-ai/bytedance/seedream/v4/text-to-image' => 'Seedream 4.0', |
| 34 |
], |
| 35 |
// Flux 2.x (Latest) |
| 36 |
'Flux 2.x' => [ |
| 37 |
'fal-ai/flux-2-pro' => 'Flux 2 Pro (best)', |
| 38 |
'fal-ai/flux-2-flex' => 'Flux 2 Flex', |
| 39 |
'fal-ai/flux-2' => 'Flux 2 Dev', |
| 40 |
'fal-ai/flux-2/lora' => 'Flux 2 LoRA', |
| 41 |
], |
| 42 |
// Flux Pro / Kontext |
| 43 |
'Flux Kontext' => [ |
| 44 |
'fal-ai/flux-pro/kontext/max' => 'Flux Kontext Max', |
| 45 |
'fal-ai/flux-pro/kontext' => 'Flux Kontext Pro', |
| 46 |
'fal-ai/flux-kontext-lora' => 'Flux Kontext LoRA', |
| 47 |
], |
| 48 |
// Flux 1.x |
| 49 |
'Flux 1.x' => [ |
| 50 |
'fal-ai/flux-pro/v1.1' => 'Flux Pro v1.1', |
| 51 |
'fal-ai/flux/dev' => 'Flux Dev', |
| 52 |
'fal-ai/flux/schnell' => 'Flux Schnell (ultra fast)', |
| 53 |
], |
| 54 |
// Recraft |
| 55 |
'Recraft' => [ |
| 56 |
'fal-ai/recraft/v3/text-to-image' => 'Recraft V3 (SOTA)', |
| 57 |
], |
| 58 |
// Qwen Image |
| 59 |
'Qwen' => [ |
| 60 |
'fal-ai/qwen-image' => 'Qwen Image (best text)', |
| 61 |
], |
| 62 |
// Other Notable |
| 63 |
'Other' => [ |
| 64 |
'fal-ai/z-image/turbo' => 'Z-Image Turbo (super fast)', |
| 65 |
'fal-ai/piflow' => 'PiFlow (fast, quality)', |
| 66 |
'fal-ai/flux-realism' => 'Flux Realism', |
| 67 |
'fal-ai/flux-lora' => 'Flux LoRA', |
| 68 |
'imagineart/imagineart-1.5-preview/text-to-image' => 'ImagineArt 1.5', |
| 69 |
'bria/fibo/generate' => 'Bria Fibo (enterprise)', |
| 70 |
], |
| 71 |
]; |
| 72 |
} |
| 73 |
|
| 74 |
/** |
| 75 |
* Get Fal.ai provider info |
| 76 |
*/ |
| 77 |
function botwriter_get_fal_info() { |
| 78 |
return [ |
| 79 |
'name' => 'Fal.ai', |
| 80 |
'description' => __('Fast, reliable inference for Flux and other cutting-edge image models. Known for excellent quality and speed.', 'botwriter'), |
| 81 |
'website' => 'https://fal.ai', |
| 82 |
'api_url' => 'https://fal.ai/dashboard/keys', |
| 83 |
'docs_url' => 'https://docs.fal.ai/', |
| 84 |
'pricing_url' => 'https://fal.ai/pricing', |
| 85 |
'free_credits' => __('Free credits on signup for testing', 'botwriter'), |
| 86 |
'pricing_summary' => [ |
| 87 |
'🍌 Nano Banana Pro' => '~$0.02/image', |
| 88 |
'Seedream 4.5' => '~$0.03/image', |
| 89 |
'Flux 2 Pro' => '~$0.05/image', |
| 90 |
'Flux Pro v1.1' => '~$0.04/image', |
| 91 |
'Flux Schnell' => '~$0.003/image (ultra cheap!)', |
| 92 |
'Recraft V3' => '~$0.04/image', |
| 93 |
'Z-Image Turbo' => '~$0.002/image', |
| 94 |
], |
| 95 |
'features' => [ |
| 96 |
__('Hosts the best Flux models', 'botwriter'), |
| 97 |
__('Very fast generation (seconds)', 'botwriter'), |
| 98 |
__('Excellent image quality', 'botwriter'), |
| 99 |
__('LoRA support for custom styles', 'botwriter'), |
| 100 |
__('Competitive pricing', 'botwriter'), |
| 101 |
__('Video generation also available', 'botwriter'), |
| 102 |
], |
| 103 |
'pros' => [ |
| 104 |
__('Best Flux hosting', 'botwriter'), |
| 105 |
__('Fast inference', 'botwriter'), |
| 106 |
__('Great documentation', 'botwriter'), |
| 107 |
__('Flexible pricing', 'botwriter'), |
| 108 |
], |
| 109 |
'cons' => [ |
| 110 |
__('Smaller model selection', 'botwriter'), |
| 111 |
__('Newer platform', 'botwriter'), |
| 112 |
], |
| 113 |
]; |
| 114 |
} |
| 115 |
|
| 116 |
/** |
| 117 |
* Render Fal.ai settings tab content |
| 118 |
*/ |
| 119 |
function botwriter_render_fal_settings($settings, $is_active) { |
| 120 |
$info = botwriter_get_fal_info(); |
| 121 |
$models = botwriter_get_fal_models(); |
| 122 |
?> |
| 123 |
<div class="provider-config-section"> |
| 124 |
<div class="provider-config-card"> |
| 125 |
<h4><?php esc_html_e('API Configuration', 'botwriter'); ?></h4> |
| 126 |
<div class="form-row"> |
| 127 |
<label><?php esc_html_e('API Key:', 'botwriter'); ?></label> |
| 128 |
<div class="api-key-wrapper"> |
| 129 |
<input type="password" name="botwriter_fal_api_key" class="form-control api-key-input" |
| 130 |
value="<?php echo esc_attr(botwriter_decrypt_api_key(get_option('botwriter_fal_api_key'))); ?>" |
| 131 |
placeholder="..."> |
| 132 |
<button type="button" class="button toggle-api-key"><?php esc_html_e('Show', 'botwriter'); ?></button> |
| 133 |
<button type="button" class="button button-secondary test-api-key" data-provider="fal"> |
| 134 |
<span class="dashicons dashicons-yes-alt"></span> <?php esc_html_e('Test API Key', 'botwriter'); ?> |
| 135 |
</button> |
| 136 |
<span class="test-api-result"></span> |
| 137 |
</div> |
| 138 |
<p class="description"><?php esc_html_e('Get your API key from the Fal.ai dashboard', 'botwriter'); ?></p> |
| 139 |
<?php botwriter_api_key_transmission_notice(); ?> |
| 140 |
</div> |
| 141 |
<div class="form-row"> |
| 142 |
<label><?php esc_html_e('Model:', 'botwriter'); ?></label> |
| 143 |
<select name="botwriter_fal_model" class="form-select" style="width: 100%; max-width: 400px;"> |
| 144 |
<?php foreach ($models as $group => $group_models): ?> |
| 145 |
<optgroup label="<?php echo esc_attr($group); ?>"> |
| 146 |
<?php foreach ($group_models as $id => $name): ?> |
| 147 |
<option value="<?php echo esc_attr($id); ?>" <?php selected($settings['botwriter_fal_model'], $id); ?>><?php echo esc_html($name); ?></option> |
| 148 |
<?php endforeach; ?> |
| 149 |
</optgroup> |
| 150 |
<?php endforeach; ?> |
| 151 |
</select> |
| 152 |
</div> |
| 153 |
</div> |
| 154 |
|
| 155 |
<div class="provider-info-card"> |
| 156 |
<h4><span class="dashicons dashicons-info-outline"></span> <?php esc_html_e('How to Get Your API Key', 'botwriter'); ?></h4> |
| 157 |
<ol class="setup-steps"> |
| 158 |
<li><?php esc_html_e('Go to', 'botwriter'); ?> <a href="https://fal.ai/login" target="_blank">fal.ai</a> <?php esc_html_e('and sign up', 'botwriter'); ?></li> |
| 159 |
<li><?php esc_html_e('Navigate to', 'botwriter'); ?> <a href="https://fal.ai/dashboard/keys" target="_blank"><?php esc_html_e('Dashboard → API Keys', 'botwriter'); ?></a></li> |
| 160 |
<li><?php esc_html_e('Click "Create Key"', 'botwriter'); ?></li> |
| 161 |
<li><?php esc_html_e('Copy and paste the key above', 'botwriter'); ?></li> |
| 162 |
<li><?php esc_html_e('Add credits at', 'botwriter'); ?> <a href="https://fal.ai/dashboard/billing" target="_blank"><?php esc_html_e('Billing', 'botwriter'); ?></a></li> |
| 163 |
</ol> |
| 164 |
<div class="info-tip"> |
| 165 |
<span class="dashicons dashicons-awards"></span> |
| 166 |
<p><?php esc_html_e('Flux Schnell is incredibly cheap - great for testing and high-volume use!', 'botwriter'); ?></p> |
| 167 |
</div> |
| 168 |
</div> |
| 169 |
|
| 170 |
<div class="provider-pricing-card"> |
| 171 |
<h4><span class="dashicons dashicons-money-alt"></span> <?php esc_html_e('Pricing Overview', 'botwriter'); ?></h4> |
| 172 |
|
| 173 |
<div class="pricing-highlight"> |
| 174 |
<span class="free-credits-badge"><?php esc_html_e('Free Credits', 'botwriter'); ?></span> |
| 175 |
<p><?php echo esc_html($info['free_credits']); ?></p> |
| 176 |
</div> |
| 177 |
|
| 178 |
<table class="pricing-table"> |
| 179 |
<thead> |
| 180 |
<tr> |
| 181 |
<th><?php esc_html_e('Model', 'botwriter'); ?></th> |
| 182 |
<th><?php esc_html_e('Price', 'botwriter'); ?></th> |
| 183 |
</tr> |
| 184 |
</thead> |
| 185 |
<tbody> |
| 186 |
<?php foreach ($info['pricing_summary'] as $model => $price): ?> |
| 187 |
<tr> |
| 188 |
<td><code><?php echo esc_html($model); ?></code></td> |
| 189 |
<td><?php echo esc_html($price); ?></td> |
| 190 |
</tr> |
| 191 |
<?php endforeach; ?> |
| 192 |
</tbody> |
| 193 |
</table> |
| 194 |
|
| 195 |
<div class="cost-saving-tip"> |
| 196 |
<span class="dashicons dashicons-lightbulb"></span> |
| 197 |
<strong><?php esc_html_e('Budget Tip:', 'botwriter'); ?></strong> |
| 198 |
<?php esc_html_e('Flux Schnell at $0.003/image means 333 images per $1!', 'botwriter'); ?> |
| 199 |
</div> |
| 200 |
|
| 201 |
<p class="pricing-note"> |
| 202 |
<a href="<?php echo esc_url($info['pricing_url']); ?>" target="_blank" class="button button-secondary"> |
| 203 |
<span class="dashicons dashicons-external"></span> <?php esc_html_e('View Full Pricing', 'botwriter'); ?> |
| 204 |
</a> |
| 205 |
</p> |
| 206 |
</div> |
| 207 |
|
| 208 |
<div class="provider-features-card"> |
| 209 |
<h4><span class="dashicons dashicons-star-filled"></span> <?php esc_html_e('Features & Benefits', 'botwriter'); ?></h4> |
| 210 |
<ul class="features-list"> |
| 211 |
<?php foreach ($info['features'] as $feature): ?> |
| 212 |
<li><span class="dashicons dashicons-yes-alt"></span> <?php echo esc_html($feature); ?></li> |
| 213 |
<?php endforeach; ?> |
| 214 |
</ul> |
| 215 |
|
| 216 |
<div class="pros-cons"> |
| 217 |
<div class="pros"> |
| 218 |
<h5><?php esc_html_e('Pros', 'botwriter'); ?></h5> |
| 219 |
<ul> |
| 220 |
<?php foreach ($info['pros'] as $pro): ?> |
| 221 |
<li><span class="dashicons dashicons-plus-alt2"></span> <?php echo esc_html($pro); ?></li> |
| 222 |
<?php endforeach; ?> |
| 223 |
</ul> |
| 224 |
</div> |
| 225 |
<div class="cons"> |
| 226 |
<h5><?php esc_html_e('Cons', 'botwriter'); ?></h5> |
| 227 |
<ul> |
| 228 |
<?php foreach ($info['cons'] as $con): ?> |
| 229 |
<li><span class="dashicons dashicons-minus"></span> <?php echo esc_html($con); ?></li> |
| 230 |
<?php endforeach; ?> |
| 231 |
</ul> |
| 232 |
</div> |
| 233 |
</div> |
| 234 |
</div> |
| 235 |
|
| 236 |
<div class="provider-links-card"> |
| 237 |
<h4><span class="dashicons dashicons-admin-links"></span> <?php esc_html_e('Useful Links', 'botwriter'); ?></h4> |
| 238 |
<div class="links-grid"> |
| 239 |
<a href="<?php echo esc_url($info['api_url']); ?>" target="_blank" class="link-item"> |
| 240 |
<span class="dashicons dashicons-admin-network"></span> |
| 241 |
<?php esc_html_e('Get API Key', 'botwriter'); ?> |
| 242 |
</a> |
| 243 |
<a href="<?php echo esc_url($info['docs_url']); ?>" target="_blank" class="link-item"> |
| 244 |
<span class="dashicons dashicons-book"></span> |
| 245 |
<?php esc_html_e('Documentation', 'botwriter'); ?> |
| 246 |
</a> |
| 247 |
<a href="https://fal.ai/models" target="_blank" class="link-item"> |
| 248 |
<span class="dashicons dashicons-images-alt2"></span> |
| 249 |
<?php esc_html_e('All Models', 'botwriter'); ?> |
| 250 |
</a> |
| 251 |
<a href="https://status.fal.ai/" target="_blank" class="link-item"> |
| 252 |
<span class="dashicons dashicons-heart"></span> |
| 253 |
<?php esc_html_e('Status', 'botwriter'); ?> |
| 254 |
</a> |
| 255 |
</div> |
| 256 |
</div> |
| 257 |
</div> |
| 258 |
<?php |
| 259 |
} |
| 260 |
|