Use Chat Completions for Image Generation Prompts with DALL-E

Colby Fayock
InstructorColby Fayock
Share this video with your friends

Social Share Links

Send Tweet
Published a year ago
Updated a year ago

With a reliable data API, we can start using our generative output in creative ways, including feeding that directly into a new generation like creating an image based off of a blog post.

We'll look at taking a GPT-generated blog post and feeding it into DALL-E along with some stylistic prompt engineering to generate an image for our post.

Instructor: [0:00] Now that we're able to confidently build an API where we know we're going to get the response that we need, including getting it in a JSON response so that we can use it programmatically, we can think of more ways to creatively use that data in other methods.

[0:12] Going back to the image endpoint that we created in a previous lesson, where we passed in a prompt and created an image with Dali, what if we now passed in our post data, including the title, into that prompt to generate an image?

[0:25] As soon as we get the blog data and set the post object to make sure we're getting the information we have on the page as soon as we can, we can now create a prompt where maybe to start, we just pass in data.title to pass in the blog post title.

[0:38] Now once we have that image, we need to store it somewhere. I'm going to reuse the setPostSetter method where I'm going to pass in a function so I can ultimately return the original data that I have, including that title and content.

[0:50] I can also return the image. Inside the UI, if I know that I have my post image, I can then render that on the page by passing in the post image as my source and because we have the title right after it, and don't have a good way to find out the description of this image, we can just have an empty alt.

[1:06] Then, when we generate this page, we first get our content like before, and then we can see that we get an image generated based off of that title.

[1:12] Now, like any of the other lessons, we can now further enhance this prompt by engineering what we actually want out of it, such as, what if I want to say, "Stylized as a retro vector illustration." If I now try to generate this with jellyfish, I get my fascinating blog post and I get my illustration that looks pretty retro to me.

[1:33] To test this out, I can say, "As a watercolor painting," where now my jellyfish looks like a watercolor with all of its mystery. Being able to create these data APIs, where we now have the ability to easily pass around this information, we can have a flexible way of passing that into other generative methods, like these images, to create images we want based off of that original content.

[1:55] In review, we can take our generated content in the form of a data object and pass that into other generative methods, such as creating an image based off that post title, where with that dynamic data, we can also pass in other instructions for how we want this to appear.

[2:09] Whether that's the style, where if we want to say, "The primary color should be green," where, on top of our ability to generate that content, we can generate images that capture that same imagination...

egghead
egghead
~ 47 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today