From the course: Building a Project with the ChatGPT API
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Solution: Generate images using images API - ChatGPT Tutorial
From the course: Building a Project with the ChatGPT API
Solution: Generate images using images API
(upbeat music) - [Instructor] Time to solve our challenge. Let's look at how I solved our prompt of generating a custom image based on the summarized website. You're familiar with the code that installs the needed libraries, pulls the API key from the environment variable, collects the messages of the multi-turn conversation, and gets the completion. This code manages the multi-turn conversation, allowing the user to enter a website to summarize. I've added a new function called generate_image that takes in the summary and passes it into the prompt parameter. I also use the n parameter to indicate that I want one image generated. For the size parameter, I'm passing the value of 1024 by 1024. I'm storing the URL in the image_url variable here on line 15. I've started the multi-turn conversation already, so let me enter the website to summarize. So, it's off thinking, summarizing the website, we have our response.…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.