Image widget code: choosing the right image model for speed and price
The same widget code can run any image model in the catalog. Here is how to compare models for an image widget and switch between them without touching your site.
Published:
Your image widget's embed code does not name a model. The model is a setting stored with the widget, which means you can test, compare and switch models while the code on your site stays exactly the same:
<script src="https://api14.com/widget.js" data-widget="YOUR_WIDGET_ID" async></script>
That makes the model choice a decision you can revisit, not a commitment. Here is how to make it well.
What to compare
Price per image. The model picker in the widget editor shows the price of each model. For a public widget that anyone can use, price per image is the number that scales with traffic.
Speed. Visitors wait in front of the widget while the image is generated. Faster models feel better for casual use, and slower, more detailed models suit pages where people expect to wait for quality.
Style and prompt following. Some models are better at photorealism, others at illustration or text inside images. The only reliable test is your own prompts.
A simple way to test
- Write five prompts that your visitors are likely to type.
- Open the widget in Widgets and run them in the preview with the first model. The preview sends real requests with your unsaved settings.
- Switch the model in the picker and run the same prompts again.
- Compare the results side by side with the price of each model.
You can also compare models outside the widget in the playground or on the compare pages.
Match the API key to the model
Every widget runs under one of your API keys. If you restrict that key to the image model you chose (the key's allowed models), the widget cannot be used with anything else, even if settings change by mistake. Need a separate key? The last option in the editor's key list is Create new API key.
When you later switch models, remember to add the new model to the key's allowed list, or the widget will stop with a "model not allowed" error that you will see in the widget list.
Switching without downtime
- Test the new model in the preview.
- Make sure the API key allows it.
- Save the widget. The next visitor request uses the new model.
Nothing changes on your website, and there is no cache to clear.
Explore image models and their prices in the model catalog, then set up your widget on the widgets page.