| 1 |
<?php |
| 2 |
/** |
| 3 |
* Replicate Image Provider Settings |
| 4 |
* |
| 5 |
* @package BotWriter |
| 6 |
*/ |
| 7 |
|
| 8 |
if (!defined('ABSPATH')) { |
| 9 |
exit; |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* Get Replicate models configuration |
| 14 |
* Updated: December 2025 with latest models |
| 15 |
*/ |
| 16 |
function botwriter_get_replicate_models() { |
| 17 |
return [ |
| 18 |
// Google - Latest Imagen & Nano Banana |
| 19 |
'Google' => [ |
| 20 |
'google/nano-banana-pro' => '🍌 Nano Banana Pro (newest!)', |
| 21 |
'google/imagen-4' => 'Imagen 4 (flagship)', |
| 22 |
'google/imagen-4-fast' => 'Imagen 4 Fast', |
| 23 |
'google/imagen-4-ultra' => 'Imagen 4 Ultra (best quality)', |
| 24 |
'google/imagen-3' => 'Imagen 3', |
| 25 |
'google/imagen-3-fast' => 'Imagen 3 Fast', |
| 26 |
], |
| 27 |
// ByteDance - Seedream Series |
| 28 |
'ByteDance' => [ |
| 29 |
'bytedance/seedream-4.5' => 'Seedream 4.5 (newest!)', |
| 30 |
'bytedance/seedream-4' => 'Seedream 4 (4K, 15M+ runs)', |
| 31 |
'bytedance/seedream-3' => 'Seedream 3 (best overall)', |
| 32 |
], |
| 33 |
// Black Forest Labs - Flux 2.x & 1.x |
| 34 |
'Flux 2.x' => [ |
| 35 |
'black-forest-labs/flux-2-pro' => 'Flux 2 Pro (8 references)', |
| 36 |
'black-forest-labs/flux-2-flex' => 'Flux 2 Flex (10 references)', |
| 37 |
'black-forest-labs/flux-2-dev' => 'Flux 2 Dev', |
| 38 |
'black-forest-labs/flux-kontext-max' => 'Flux Kontext Max', |
| 39 |
'black-forest-labs/flux-kontext-pro' => 'Flux Kontext Pro', |
| 40 |
], |
| 41 |
'Flux 1.x' => [ |
| 42 |
'black-forest-labs/flux-1.1-pro' => 'Flux 1.1 Pro', |
| 43 |
'black-forest-labs/flux-1.1-pro-ultra' => 'Flux 1.1 Pro Ultra (4MP)', |
| 44 |
'black-forest-labs/flux-dev' => 'Flux Dev', |
| 45 |
'black-forest-labs/flux-schnell' => 'Flux Schnell (ultra fast)', |
| 46 |
], |
| 47 |
// Ideogram - Best for text in images |
| 48 |
'Ideogram' => [ |
| 49 |
'ideogram-ai/ideogram-v3-quality' => 'Ideogram V3 Quality (best text)', |
| 50 |
'ideogram-ai/ideogram-v3-turbo' => 'Ideogram V3 Turbo', |
| 51 |
'ideogram-ai/ideogram-v3-balanced' => 'Ideogram V3 Balanced', |
| 52 |
'ideogram-ai/ideogram-v2' => 'Ideogram V2', |
| 53 |
'ideogram-ai/ideogram-v2-turbo' => 'Ideogram V2 Turbo', |
| 54 |
], |
| 55 |
// Alibaba Qwen |
| 56 |
'Qwen' => [ |
| 57 |
'qwen/qwen-image' => 'Qwen Image (best text rendering)', |
| 58 |
], |
| 59 |
// Recraft & Others |
| 60 |
'Recraft' => [ |
| 61 |
'recraft-ai/recraft-v3' => 'Recraft V3 (SOTA benchmark)', |
| 62 |
'recraft-ai/recraft-v3-svg' => 'Recraft V3 SVG (vector output)', |
| 63 |
], |
| 64 |
// Stability AI |
| 65 |
'Stability AI' => [ |
| 66 |
'stability-ai/stable-diffusion-3.5-large' => 'SD 3.5 Large', |
| 67 |
'stability-ai/stable-diffusion-3.5-large-turbo' => 'SD 3.5 Large Turbo', |
| 68 |
'stability-ai/stable-diffusion-3.5-medium' => 'SD 3.5 Medium', |
| 69 |
'stability-ai/sdxl' => 'SDXL', |
| 70 |
], |
| 71 |
// Other Notable Models |
| 72 |
'Other' => [ |
| 73 |
'luma/photon' => 'Luma Photon', |
| 74 |
'luma/photon-flash' => 'Luma Photon Flash', |
| 75 |
'minimax/image-01' => 'Minimax Image 01', |
| 76 |
'leonardoai/lucid-origin' => 'Leonardo Lucid Origin', |
| 77 |
'tencent/hunyuan-image-3' => 'Tencent Hunyuan Image 3', |
| 78 |
'prunaai/flux-fast' => 'Pruna Flux Fast (fastest)', |
| 79 |
], |
| 80 |
]; |
| 81 |
} |
| 82 |
|
| 83 |
/** |
| 84 |
* Get Replicate provider info |
| 85 |
*/ |
| 86 |
function botwriter_get_replicate_info() { |
| 87 |
return [ |
| 88 |
'name' => 'Replicate', |
| 89 |
'description' => __('Run open-source machine learning models with a simple API. Thousands of models available, pay per second of compute.', 'botwriter'), |
| 90 |
'website' => 'https://replicate.com', |
| 91 |
'api_url' => 'https://replicate.com/account/api-tokens', |
| 92 |
'docs_url' => 'https://replicate.com/docs', |
| 93 |
'pricing_url' => 'https://replicate.com/pricing', |
| 94 |
'free_credits' => __('Free credits to get started on signup', 'botwriter'), |
| 95 |
'pricing_summary' => [ |
| 96 |
'🍌 Nano Banana Pro' => '~$0.02/image', |
| 97 |
'Imagen 4 Fast' => '~$0.02/image', |
| 98 |
'Seedream 4' => '~$0.03/image', |
| 99 |
'Flux 2 Pro' => '~$0.05/image', |
| 100 |
'Flux 1.1 Pro' => '$0.04/image', |
| 101 |
'Flux Schnell' => '$0.003/image (1000 for $3!)', |
| 102 |
'Ideogram V3 Quality' => '$0.08/image', |
| 103 |
'Recraft V3' => '$0.04/image', |
| 104 |
], |
| 105 |
'features' => [ |
| 106 |
__('Thousands of open-source models', 'botwriter'), |
| 107 |
__('Pay per second of compute', 'botwriter'), |
| 108 |
__('Run custom models', 'botwriter'), |
| 109 |
__('Fine-tuning available', 'botwriter'), |
| 110 |
__('Video, audio, and more', 'botwriter'), |
| 111 |
__('Community-contributed models', 'botwriter'), |
| 112 |
], |
| 113 |
'pros' => [ |
| 114 |
__('Huge model selection', 'botwriter'), |
| 115 |
__('Custom model support', 'botwriter'), |
| 116 |
__('Simple API', 'botwriter'), |
| 117 |
__('Pay only for compute used', 'botwriter'), |
| 118 |
], |
| 119 |
'cons' => [ |
| 120 |
__('Cold starts can be slow', 'botwriter'), |
| 121 |
__('Variable pricing', 'botwriter'), |
| 122 |
], |
| 123 |
]; |
| 124 |
} |
| 125 |
|
| 126 |
/** |
| 127 |
* Render Replicate settings tab content |
| 128 |
*/ |
| 129 |
function botwriter_render_replicate_settings($settings, $is_active) { |
| 130 |
$info = botwriter_get_replicate_info(); |
| 131 |
$models = botwriter_get_replicate_models(); |
| 132 |
?> |
| 133 |
<div class="provider-config-section"> |
| 134 |
<div class="provider-config-card"> |
| 135 |
<h4><?php esc_html_e('API Configuration', 'botwriter'); ?></h4> |
| 136 |
<div class="form-row"> |
| 137 |
<label><?php esc_html_e('API Token:', 'botwriter'); ?></label> |
| 138 |
<div class="api-key-wrapper"> |
| 139 |
<input type="password" name="botwriter_replicate_api_key" class="form-control api-key-input" |
| 140 |
value="<?php echo esc_attr(botwriter_decrypt_api_key(get_option('botwriter_replicate_api_key'))); ?>" |
| 141 |
placeholder="r8_..."> |
| 142 |
<button type="button" class="button toggle-api-key"><?php esc_html_e('Show', 'botwriter'); ?></button> |
| 143 |
<button type="button" class="button button-secondary test-api-key" data-provider="replicate"> |
| 144 |
<span class="dashicons dashicons-yes-alt"></span> <?php esc_html_e('Test API Key', 'botwriter'); ?> |
| 145 |
</button> |
| 146 |
<span class="test-api-result"></span> |
| 147 |
</div> |
| 148 |
<p class="description"><?php esc_html_e('Your Replicate API token starts with "r8_"', 'botwriter'); ?></p> |
| 149 |
</div> |
| 150 |
<div class="form-row"> |
| 151 |
<label><?php esc_html_e('Model:', 'botwriter'); ?></label> |
| 152 |
<select name="botwriter_replicate_model" class="form-select" style="width: 100%; max-width: 400px;"> |
| 153 |
<?php foreach ($models as $group => $group_models): ?> |
| 154 |
<optgroup label="<?php echo esc_attr($group); ?>"> |
| 155 |
<?php foreach ($group_models as $id => $name): ?> |
| 156 |
<option value="<?php echo esc_attr($id); ?>" <?php selected($settings['botwriter_replicate_model'], $id); ?>><?php echo esc_html($name); ?></option> |
| 157 |
<?php endforeach; ?> |
| 158 |
</optgroup> |
| 159 |
<?php endforeach; ?> |
| 160 |
</select> |
| 161 |
<p class="description"><?php esc_html_e('Explore all models at', 'botwriter'); ?> <a href="https://replicate.com/explore" target="_blank">replicate.com/explore</a></p> |
| 162 |
</div> |
| 163 |
</div> |
| 164 |
|
| 165 |
<div class="provider-info-card"> |
| 166 |
<h4><span class="dashicons dashicons-info-outline"></span> <?php esc_html_e('How to Get Your API Token', 'botwriter'); ?></h4> |
| 167 |
<ol class="setup-steps"> |
| 168 |
<li><?php esc_html_e('Go to', 'botwriter'); ?> <a href="https://replicate.com/" target="_blank">replicate.com</a> <?php esc_html_e('and sign up (GitHub recommended)', 'botwriter'); ?></li> |
| 169 |
<li><?php esc_html_e('Navigate to', 'botwriter'); ?> <a href="https://replicate.com/account/api-tokens" target="_blank"><?php esc_html_e('Account → API Tokens', 'botwriter'); ?></a></li> |
| 170 |
<li><?php esc_html_e('Copy your API token (starts with "r8_")', 'botwriter'); ?></li> |
| 171 |
<li><?php esc_html_e('Paste it above', 'botwriter'); ?></li> |
| 172 |
</ol> |
| 173 |
<div class="info-tip"> |
| 174 |
<span class="dashicons dashicons-lightbulb"></span> |
| 175 |
<p><?php esc_html_e('Replicate hosts thousands of models - explore the collection to find the perfect one for your needs!', 'botwriter'); ?></p> |
| 176 |
</div> |
| 177 |
</div> |
| 178 |
|
| 179 |
<div class="provider-pricing-card"> |
| 180 |
<h4><span class="dashicons dashicons-money-alt"></span> <?php esc_html_e('Pricing Overview', 'botwriter'); ?></h4> |
| 181 |
|
| 182 |
<div class="pricing-highlight"> |
| 183 |
<span class="free-credits-badge"><?php esc_html_e('Free Credits', 'botwriter'); ?></span> |
| 184 |
<p><?php echo esc_html($info['free_credits']); ?></p> |
| 185 |
</div> |
| 186 |
|
| 187 |
<table class="pricing-table"> |
| 188 |
<thead> |
| 189 |
<tr> |
| 190 |
<th><?php esc_html_e('Model', 'botwriter'); ?></th> |
| 191 |
<th><?php esc_html_e('Price', 'botwriter'); ?></th> |
| 192 |
</tr> |
| 193 |
</thead> |
| 194 |
<tbody> |
| 195 |
<?php foreach ($info['pricing_summary'] as $model => $price): ?> |
| 196 |
<tr> |
| 197 |
<td><code><?php echo esc_html($model); ?></code></td> |
| 198 |
<td><?php echo esc_html($price); ?></td> |
| 199 |
</tr> |
| 200 |
<?php endforeach; ?> |
| 201 |
</tbody> |
| 202 |
</table> |
| 203 |
|
| 204 |
<div class="cost-saving-tip"> |
| 205 |
<span class="dashicons dashicons-info"></span> |
| 206 |
<strong><?php esc_html_e('Note:', 'botwriter'); ?></strong> |
| 207 |
<?php esc_html_e('Replicate charges by compute time. Prices shown are estimates for typical images.', 'botwriter'); ?> |
| 208 |
</div> |
| 209 |
|
| 210 |
<p class="pricing-note"> |
| 211 |
<a href="<?php echo esc_url($info['pricing_url']); ?>" target="_blank" class="button button-secondary"> |
| 212 |
<span class="dashicons dashicons-external"></span> <?php esc_html_e('View Full Pricing', 'botwriter'); ?> |
| 213 |
</a> |
| 214 |
</p> |
| 215 |
</div> |
| 216 |
|
| 217 |
<div class="provider-features-card"> |
| 218 |
<h4><span class="dashicons dashicons-star-filled"></span> <?php esc_html_e('Features & Benefits', 'botwriter'); ?></h4> |
| 219 |
<ul class="features-list"> |
| 220 |
<?php foreach ($info['features'] as $feature): ?> |
| 221 |
<li><span class="dashicons dashicons-yes-alt"></span> <?php echo esc_html($feature); ?></li> |
| 222 |
<?php endforeach; ?> |
| 223 |
</ul> |
| 224 |
|
| 225 |
<div class="pros-cons"> |
| 226 |
<div class="pros"> |
| 227 |
<h5><?php esc_html_e('Pros', 'botwriter'); ?></h5> |
| 228 |
<ul> |
| 229 |
<?php foreach ($info['pros'] as $pro): ?> |
| 230 |
<li><span class="dashicons dashicons-plus-alt2"></span> <?php echo esc_html($pro); ?></li> |
| 231 |
<?php endforeach; ?> |
| 232 |
</ul> |
| 233 |
</div> |
| 234 |
<div class="cons"> |
| 235 |
<h5><?php esc_html_e('Cons', 'botwriter'); ?></h5> |
| 236 |
<ul> |
| 237 |
<?php foreach ($info['cons'] as $con): ?> |
| 238 |
<li><span class="dashicons dashicons-minus"></span> <?php echo esc_html($con); ?></li> |
| 239 |
<?php endforeach; ?> |
| 240 |
</ul> |
| 241 |
</div> |
| 242 |
</div> |
| 243 |
</div> |
| 244 |
|
| 245 |
<div class="provider-links-card"> |
| 246 |
<h4><span class="dashicons dashicons-admin-links"></span> <?php esc_html_e('Useful Links', 'botwriter'); ?></h4> |
| 247 |
<div class="links-grid"> |
| 248 |
<a href="<?php echo esc_url($info['api_url']); ?>" target="_blank" class="link-item"> |
| 249 |
<span class="dashicons dashicons-admin-network"></span> |
| 250 |
<?php esc_html_e('Get API Token', 'botwriter'); ?> |
| 251 |
</a> |
| 252 |
<a href="https://replicate.com/explore" target="_blank" class="link-item"> |
| 253 |
<span class="dashicons dashicons-images-alt2"></span> |
| 254 |
<?php esc_html_e('Explore Models', 'botwriter'); ?> |
| 255 |
</a> |
| 256 |
<a href="<?php echo esc_url($info['docs_url']); ?>" target="_blank" class="link-item"> |
| 257 |
<span class="dashicons dashicons-book"></span> |
| 258 |
<?php esc_html_e('Documentation', 'botwriter'); ?> |
| 259 |
</a> |
| 260 |
<a href="https://replicatestatus.com/" target="_blank" class="link-item"> |
| 261 |
<span class="dashicons dashicons-heart"></span> |
| 262 |
<?php esc_html_e('Status', 'botwriter'); ?> |
| 263 |
</a> |
| 264 |
</div> |
| 265 |
</div> |
| 266 |
</div> |
| 267 |
<?php |
| 268 |
} |
| 269 |
|