Laravel AI SDK: Image Generation from Text with Gemini Pro/Flash LLMs

Laravel Daily| 00:13:49|Feb 18, 2026
Chapters8
Introduces the Laravel AI SDK course, free mini lessons, and the goal to show real world usage and costs.

Laravel AI SDK makes image generation from text simple, showing Gemini Pro/Flash workflows, queue handling, costs, and model swapping for thumbnails.

Summary

Laravel Daily’s walkthrough demonstrates how to generate YouTube thumbnails using the new Laravel AI SDK. The host shows Gemini-powered image creation, including swapping to cheaper Flash models and even trying OpenAI as a provider. He emphasizes practical costs, queue behavior, and real-life failures to help developers plan production-friendly pipelines. The tutorial covers setting up a Laravel queue job, building prompts, and using the AI SDK’s Image class with a background photo to generate a thumbnail. Livewire is used on the show page to poll progress, while a blade view keeps UI simple with Tailwind styling. The video also compares default models and providers configured in config AI.php and explains how to regenerate images with different models like Gemini 3 Pro versus Gemini 2.5 Flash. Finally, the host highlights maintenance considerations such as retries, queue timeout behavior, and monitoring dashboard costs. This serves as both a hands-on tutorial and a candid look at the operational realities of AI-generated assets in Laravel projects.

Key Takeaways

  • The video demonstrates generating a YouTube thumbnail by combining a video title, description, and a selected background image using Laravel AI SDK with Gemini as the provider.
  • Prompts are built programmatically and can be rendered with Blade, with the example showing a concise prompt like 'Create a high performing YouTube thumbnail' plus title and description.
  • Queue management is essential: the thumbnail generation runs as a queued job (Q), with Livewire polling every second to show progress on the show page.
  • Gemini Pro is costlier but often yields crisper results, while Gemini 2.5 Flash is cheaper but can be less stable and produce typos or variability in output (as shown by the comparison).

Who Is This For?

Essential viewing for Laravel developers migrating thumbnail generation or AI-assisted media creation into production, especially those weighing Gemini Pro vs. Flash costs and the reliability of external AI APIs.

Notable Quotes

"Generate thumbnail. It generates to the show page and then I have Livewire here to track the generating thumbnail."
Shows the end-to-end flow from generation to progress tracking in the UI.
"The default providers and models are generally configured in the config AI PHP file."
Explains where to configure provider/model defaults.
"OpenAI is slower and sometimes fails, which is why queue management and retries matter."
Highlights reliability challenges with external AI APIs.
"Gemini 3 Pro was about 55 cents for around 10 images in my testing."
Gives a concrete cost datapoint to compare models.
"Flash is cheaper than Pro, but the results can be unstable and may introduce typos or odd outputs."
Provides practical trade-offs between model families.

Questions This Video Answers

  • How do I set up Laravel AI SDK to generate YouTube thumbnails with Gemini Pro vs Flash?
  • What are the practical cost implications of using Gemini Pro for image generation in Laravel?
  • Can I switch AI providers on the fly in Laravel AI SDK and how does that affect queues?
  • What are best practices for monitoring AI image generation jobs in Laravel (queues, Livewire, retries)?
Laravel AI SDKGemini ProGemini FlashOpenAIImage generationYouTube thumbnailsLivewireQueueConfig AI.phpBackground image prompt
Full Transcript
Hello guys. So, Laravel AI SDK is officially out and I've been playing around with it a lot and I released a course on Laravel daily with six practical examples. And on YouTube, as usual, I'll release some of the stuff for free. So, I will release two lessons from the course. Today, we'll talk about how to generate YouTube thumbnails. So, we'll talk about image generation with AI and then tomorrow there will be another video with more serious example as I called it with chatbot with document. So you upload the document and ask the questions. So this is the list of projects inside of this course and we will start with generate video thumbnails in this video on YouTube. And also my goal with this course is not just to showcase the features but also to show you how much it takes in real life, how much it costs if it refreshes in the dashboard. Sometimes it doesn't. What happens if it fails? How to wrap that all in the queue. Also, I will talk what is the difference between Laravel AI SDK and Prism package. So, all of that in the course. If you want to get the access to this oneh hour full course, the link will be in the description below. By doing that, you're also supporting my mission of shooting these videos on YouTube as well for free. So, I do appreciate your support. And now, let's dive into the first example of generating video thumbnails. Tomorrow, the next example, document Q&A chatbot. Let's start this course with something fun and simple. So what can we do with AI? One of the most typical fun experiments is to generate images with it from text. And my personal use case is to generate a thumbnail for my YouTube videos for example. So I can enter the title of the video and brief description. Also choose a photo of a background which is my face basically. I will show you that in a minute. And then it will generate thumbnail. So we can do that with Laravel AI SDK and first let me demonstrate how it works and then I will show you the code. So for example this video livewire examples in 16 minutes and I will just copy and paste into the form also brief description I will copy and paste it from here from the actual video and then with photos I have three images prepared. So here in the storage folder in images subfolder I have pointing JPEG, thinking JPEG and thumbs up JPEG. This is just random background photos from my gallery. So let's leave it as thumbs up and let's generate thumbnail with Gemini model in this case and let's see what is the result and how much it takes. Generate thumbnail. It generates to the show page and then I have live wire here to track the generating thumbnail. And in this case I use Q and I will show Q in a minute but I need to run Q work or actually it was already in the background. I had actually forgot that it was running. So in 17 seconds it generated this. What do you think? I'm actually thinking to maybe start new series of thumbnails with my face with AI generated thumbnails. Now let's take a look at the code. So in the routes we have controllers for each example in this course. And let's go to video controller where we have a typical CRUD. So create form and then store method is where magic happens. So I store the video in the database title, description and status generating. So this is just Laravel and this is where I cue the job to generate the image. There are other ways to cue specific agent work with Laravel AI SDK and I will show you that later in this course. But for now, good old cued job which looks like this. implements shoot q and in constructor we have video from the database the image file name for the background and maybe model if you want to override this and this is what happens inside of this job first we build the prompt the prompt for a llm and we can choose different lm model and I will show you that later in this video but for now for any lm we need to build the prompt and for that I have private function here with this text in prompt for this you can use blade for example and then render blade separately. But this is not a big prompt. So this is inline text. Create a high performing YouTube thumbnail. This is actually AI generated partially, but I've made quite a few changes manually. For example, max five words in headline. And also I told it to not just use the title as text. And we have two parameters title and description from the form. So this is our prompt built. Then we have image path for the original image. And this is the main thing of Laravel AI SDK. So we want to build the image with original attachments as source. So my face in the background this is our prompt. This files image is a class from AIS SDK. So this is not a Laravel storage class or anything. This is specifically for AIS SDK from path. And then we can choose landscape and there are more parameters for example quality high. And after building all of that we need to choose what to generate with which provider and which model. If you don't provide anything any parameter this would get the default in configuration default models and providers and I will show you those in a minute but in this case we specifically provide Gemini and if we want model on top and we will experiment with that then this becomes another parameter to that function of generate and that's it from that we have image response which we then store in the thumbnails in public and this is the main advantage of Laravel AI SDK over for example Prism package or any PHP package. So directly we can use cues from Laravel like in this case store functions. So config file system and all of that. So this is where all comes together with AI functions. So we call external APIs but then we use Laravel functions to save it all together. then eloquent update with completed status and then delete the image if there was an old image and it is of course wrapped in try catch because a lot of things can happen in those like 16 seconds with external APIs. So yeah and then we redirect to the show page. So in the controller we dispatch the job. This is in the queue. Meanwhile we redirect to show page and here we'll have live wire to update the progress. Let me show you. So if you go to the blade view of that video's show, this is a typical page with some tailwind and then inside we have live wire component. I deliberately chose live wire and then there will be live wire polling every second with the timer instead of doing reverb with web sockets because this is more simple. I don't need to explain reverb separately on top. But probably more correct way would be to not pull every second but instead use websockets. But in this case we have if video is generating then we have wire pole every 1 second with live wire then we also have alpine timer you saw that every second it is increased and then at some point if the video is not generating and is not failed then we have the final result which is this we're loading the image the readymade image already from API with just image storage disk and those functions is generating ing is completed and others is just a helper inside of eloquent model. In addition to that, I decided to add regenerate inside of the same livewire components. You can see wire submit, but it can be a typical form without livewire as well to choose the model. The default providers and models are generally configured in the config AI PHP file. So after you install Laravel AI SDK in your project which I already did behind the scenes and then this command publishes config AI PHP file with these defaults. So default for images is Gemini which is actually if I understand correctly under the hood nano banana API but within Gemini there are also choices of more expensive or cheaper models. So that's why here in the page of show at the bottom I have this by default if you don't specify it otherwise it's calling Gemini 3 pro which is quite expensive model and we can try to regenerate the same image with cheaper model flash Gemini 2.5 flash. Let's try to do exactly that. I will save that image in a new tab so we will compare the differences and let's hit regenerate. Will it be faster? I guess not. From my experiments, it's also roughly 10 to 15 seconds. A bit faster maybe, but the result is cheaper. And I don't know, I'm not a designer, but personally, I see it's a cheaper image comparing to this one, isn't it? In my experiments before this video, this was sometimes generating some typos or missing the letters. Also, you can see Android logo here. Why Android? It's nothing to do with Android. In this case in pro model, it correctly identified live wire logo although I didn't really specified it or upload it. So yeah, if we compare the results by different models, yes, flash is cheaper and you may want to use that, but prepare for results to be more let's call it unstable. But of course also it depends a lot on the prompt. So you may specify more details in your prompt what you want or don't want to see inside of this thumbnail and it may improve results as well. And if we talk about cost for example Gemini API usage this is my dashboard and it's hard to actually calculate the exact numbers per image but if we go to billing this is what I could come up with is time range last days and it's not refreshed with the latest data unfortunately because it takes time but the cost for Gemini 3 Pro was 55 cents for around 10 images that I had generated during my testing. So I would roughly calculate like five to 10 cents per one image and I was trying to filter by Gemini 2.5 flash but it shows no available data. So I'm not even sure how to calculate that but basically you can assume that flash is generally much cheaper than pro. Now out of curiosity let's try the chat GPT model open AI. To do that, I will stop the queue and we'll need to restart it because we will make changes in the code. And then in the job, all we do is change provider Gemini to open AI for example. Here in both cases, you can change that on the fly with generate as a provider or I could also go to config AI and choose default for images change to open AI. By the way, I have API keys for all of those providers in ENV. I will not show the actual keys, but these are the values. OpenAI API key, Gemini, and also we will take a look at 11 Labs for audio later in this course. So, you need to get those API keys from AI provider dashboards. So, let's try open AI. Let's launch Q work again. It's waiting for the jobs. And I will go to the create form again with the same photo or actually let's do a different one pointing for example and let's try to generate the thumbnail with open AI. How much it will take? 10 seconds. So basically generating images is quite a time consuming task. So you should expect to wait for like 10 to 20 seconds. Let's take a look at our queue. Is it running? Yes, it's still running. So with OpenAI it's actually much slower. It's actually a minute already. Maybe the API is down. It happens with Open EI and Claude as well. And here we have fail off the job in 1 minute and 12 seconds. I didn't really rehearse that or expect that, but it does happen with basically any external APIs. And with AI, it's also not fully reliable. The most interesting part is why it actually killed the Q work. It didn't just fail. So I will just retry again just in case. So retry the Q work and let's see. It did work for me earlier actually in earlier experiments and the job is running. It did work in roughly 15 seconds. So I'm not sure about the reason of the failure. And this is where actually Q management comes as a very handy knowledge to have and expertise to have. So those AI APIs are external APIs and they're not guaranteed to work. So I'm guessing it will fail again because this is already more than a minute. So something is wrong with the API. Yep, as expected, minute and 7 seconds and probably it's killing Q work because of the default Q settings. So yeah, unfortunately I cannot show OpenAI as a provider, but you get the idea how to change the provider to generate the image. Let's actually refresh the OpenAI dashboard. So, this is what it looked like before shooting this video. The budget was 4 cents used for today. So, did it take any money with those last attempts or did it log any errors? No, I don't see anything here, which means probably it's not refreshed yet. It does take time for those dashboards to refresh the data. So, yeah, this was the example of image generation with Laravel AI SDK. Basically, it's all here in this part.

Get daily recaps from
Laravel Daily

AI-powered summaries delivered to your inbox. Save hours every week while staying fully informed.