AI Image Studio
Generate frame art from a text prompt — and iteratively edit it in a chat — powered by the optional
laravel/ai package. Describe an image (optionally starting from an
uploaded photo), refine it with follow-up prompts, then save the result straight into your library, where
it's optimized for the panel like any other image. Past conversations are browsable, and deleting one
also deletes its generated preview images.
The Studio is opt-in: it only appears when laravel/ai is installed and enabled in config, so you
can leave it off even when the package is present. Both laravel/ai 0.11 and 1.x are supported.
composer require laravel/ai
php artisan vendor:publish --provider="Laravel\Ai\AiServiceProvider"
php artisan migrate
A Create with AI button then appears on the gallery, linking to the Studio at /switchbot/studio
(behind the same route middleware as the rest of the page). Each library card also gets an Edit with AI
button to start a conversation from that image.
Image generation uses laravel/ai's own provider configuration and auth tokens (OPENAI_API_KEY,
GEMINI_API_KEY, …) from your .env. Supported image providers are OpenAI, Gemini, xAI, Azure,
Bedrock and OpenRouter — the providers supported at the time of writing. Actual support depends on your
installed laravel/ai version; see
laravel/ai provider support for the current list.
SWITCHBOT_AI_ENABLED=true # turn the Studio off even when laravel/ai is installed
# Image generation (empty = use config/ai.php defaults):
SWITCHBOT_AI_IMAGE_PROVIDER= # optional — pin an image provider (e.g. openai)
SWITCHBOT_AI_IMAGE_MODEL= # optional — pin an image model
SWITCHBOT_AI_IMAGE_ASPECT= # default shape (portrait|landscape|square); empty follows now_showing
# "Improve prompt" is a text task — uses config/ai.php's default text provider unless overridden:
SWITCHBOT_AI_IMPROVE_PROVIDER=
SWITCHBOT_AI_IMPROVE_MODEL=
# EXPERIMENTAL, indicative-only cost estimation (see the note below):
SWITCHBOT_AI_COST_ESTIMATION=false
SWITCHBOT_AI_COST_REFRESH_HOURS=24
Note
laravel/aiships with Gemini as its default image provider. If you'd rather use OpenAI (e.g. you already haveOPENAI_API_KEY), setSWITCHBOT_AI_IMAGE_PROVIDER=openai— otherwise add aGEMINI_API_KEY.
Warning Cost estimation is experimental. When enabled, a queued job estimates the USD cost of each generation and prompt improvement from token counts and public per-token prices from LiteLLM's price sheet (fetched and cached, refreshed every
SWITCHBOT_AI_COST_REFRESH_HOURS). Figures are a rough indication only and must not be used for invoicing, budgeting or any correctness-sensitive purpose. Token usage and cost are bookkeeping only: if recording them fails, the image is still marked ready. For proper usage tracking across all yourlaravel/aicalls, with a dashboard and budgets, seespaanproductions/laravel-ai-usage.
Important Image generation and the e-ink optimization run on the queue and can take a while.
GenerateAiImageJoballows up to 120 seconds, so your queue worker's timeout must be at least that — runphp artisan queue:work --timeout=120(or set the supervisor'stimeoutto120+ inconfig/horizon.phpwhen using Horizon). If the worker runs under Supervisor, set itsstopwaitsecshigher than the worker timeout (e.g.130) so a deploy/restart doesn't kill a job mid-generation, and keep the connection'sretry_after(config/queue.php) above the timeout as well, or a slow generation may be retried while it is still running.
Een fout gevonden of een vraag? Maak een issue aan op GitHub.