HomeVideos

OpenAI's New Image API is FINALLY available : Open WebUI and other use-cases

Now Playing

OpenAI's New Image API is FINALLY available : Open WebUI and other use-cases

Transcript

273 segments

0:00

Hello everyone. This is Professor

0:01

Patterns and in this video we're going

0:02

to be going over the new GPT image one

0:04

model that's now available through the

0:06

OpenAI's API. Now this is a really

0:09

powerful model and I've been using it

0:11

for so many different applications. Now

0:13

one way I've been using this is I've

0:15

actually created a pipe function on Open

0:17

Web UI meaning that I can now use this

0:19

model directly on here. Sure, I can use

0:22

it to generate images of an apple. But

0:24

here's another image of this person

0:26

who's staring off into the distance. And

0:28

you can see it's incredibly realistic.

0:30

Um, I also have another image over here

0:32

of a warrior priestess. And now I can

0:36

even compare this to what I have on chat

0:37

GBT. And chat GBT actually doesn't come

0:40

close. Even though it is the same model,

0:42

I do have a lot more insight into the

0:44

parameters and I can tune a lot of those

0:46

parameters as well depending on the type

0:48

of uh output that I would like. So

0:51

that's one way I've been using this

0:52

model. Now another way that I've used

0:54

this API is I've simply created my own

0:56

sort of web app that's running locally

0:58

on my computer. It's an AI photo booth.

1:00

I'm going to share the entire codebase

1:02

with you. So you can even try it out for

1:04

yourself. Uh maybe you can create your

1:06

own sort of photo photo booth and

1:07

variations of it. Now it's a very basic

1:10

application. All it does is that I can

1:11

either take a picture or I can upload an

1:13

existing picture. Let's say that I take

1:15

a

1:15

picture. Now I can say well turn this

1:18

into a Disney character. And then I'm

1:20

going to hit transform image. So it's

1:22

going to transform this existing image

1:23

into a Disney character variation. Now

1:26

over here I also have another variant

1:29

where I actually uploaded an image. So

1:32

this is the same exact image that I've

1:34

been using for um every single one of my

1:36

YouTube thumbnails. I uploaded the image

1:38

and I said turn this image into an anime

1:40

warrior character. And then this is what

1:42

it ended up getting me. So I can

1:44

download this image now. And then if I

1:46

take a look, this is what the output

1:48

looks like

1:49

currently. So you can even create your

1:51

own ideas. For example, where users can

1:54

go in and say it's like a variation of

1:56

this app. A user goes in, takes um a

1:58

couple of pictures, maybe some of their

2:00

front face, some of them looking at the

2:01

side and the other side, and then your

2:03

app essentially generates like a um

2:06

LinkedIn headsh shot or actor type head

2:08

shot or something for them. So those are

2:11

a couple of different variations of this

2:12

app that you can kind of turn this into.

2:15

Um, if you take a look over here at the

2:16

Disney character, this is what it

2:18

actually generated. Uh, this was the

2:20

base image and then this is what the

2:21

output looks like. Now, the main thing

2:24

that's powering this is the OpenAI API.

2:27

Now, to actually get this OpenAI API

2:29

key, you will have to create an account

2:30

on OpenAI. And then once you created

2:33

this account, you will also have to

2:34

verify your organization. Meaning that

2:36

you have to upload maybe like a driver's

2:38

license or something and then upload a

2:39

picture of your face and it verifies

2:41

that you are that person. Once you do

2:43

that, it it is pretty much

2:44

instantaneous. It's not like you have to

2:45

wait or anything like that. But once you

2:47

do that, you will then be able to use

2:49

that API. So then all you would do is

2:52

just go over here to API keys and then

2:54

ask it to generate a new API key for

2:57

you.

2:58

Now, yeah, sure. Sure. Okay. Well, at

3:01

least it's not showing all of my API

3:03

keys. But this is what you would do is

3:06

just create a new secret key and then um

3:08

you can copy and paste that key put it

3:10

into whatever application that you

3:12

wanted to whether it's open web UI or

3:13

your own apps. Now if you go over here

3:15

to the image generation API sort of

3:18

overview it gives you a full idea on

3:21

like all the things that this sort of

3:24

API is capable of. So first we can use

3:27

it for generating images. So this is a

3:29

very basic one just use it for image

3:31

generation. And this over here we can

3:34

see the code in either Python or curl or

3:37

JavaScript. So say for example Python

3:39

all you would do is you can simply copy

3:41

this code put into a Python script

3:43

execute it and it's going to run it's

3:44

going to help it's actually going to

3:46

create uh these images for you. The

3:48

other thing that you can also do is edit

3:50

images. So over here it's showing us an

3:52

example where we have 1 2 3 four

3:54

different images and the prompt is you

3:57

know collect or put all of these items

3:59

into one basket and then that's this is

4:02

the output. So these are four input

4:04

images and this is the final output

4:06

image. It also gave us the code that we

4:08

would use to do something like this. I

4:11

actually used parts of this code to

4:12

generate the app over that I had shown

4:15

before uh where it generates variants of

4:17

an existing image. There's also other

4:19

things like edit an image using a mask.

4:21

So like in painting for example where

4:23

you have this as the uh base image and

4:25

you can uh say okay well this part of

4:28

the image maybe I want to add a flamingo

4:30

or something. So you can specify what

4:32

part of the image and then based on that

4:33

it will add in the appropriate location.

4:37

So there are so many different things so

4:39

many different um characteristics that

4:41

you can take a look at. Um the other

4:43

place that I also recommend go uh taking

4:45

a look into is the image API. So this is

4:48

a little bit more of a in-depth

4:50

documentation. So it shows you all of

4:53

the APIs that you'll need for create

4:55

image uh which is going to be this one.

4:57

You can look at the Python code or curl

4:59

or NodeJS code for example. Um you can

5:02

see that there are a bunch of different

5:03

parameters. We have things like uh the

5:06

prompt. We have things like the

5:07

background the model. So moderation. So

5:10

any content moderation that you want

5:11

either you can have it as low or you can

5:14

just have it as the auto. and auto is

5:15

usually going to be the default value.

5:17

Um, you can specify the output format if

5:20

you want it as PNG, JPEG or WEBP format

5:22

or or anything like that. The quality

5:24

now well this is going to be really

5:26

important because this directly ties to

5:28

the cost of the model. So sure we can

5:31

use something like uh medium, high or

5:34

low or the GPT image one model but then

5:38

the pricing actually for these models

5:40

does end up being a little bit more on

5:41

the costly side. So, I've actually been

5:44

using the these models for a while. I've

5:46

actually generated like so many

5:48

different images so far and total cost

5:51

$8. So, it's not like it's breaking the

5:52

bank or anything like that. But, um you

5:55

you still want to be careful. Imagine

5:56

that you create this app and you just

5:58

say, "Okay, you know what? I just want

5:59

to have everyone around the world uh go

6:01

ahead and start using this app of mine

6:03

for free." Well, uh, this is me

6:05

generating I think about, um, no, it's

6:08

not 82, but it's, uh, close to about 30

6:11

or so images when I was actually testing

6:13

everything out, and that costed me about

6:15

$8. And these are actually going to be

6:18

the high quality images. So, that's the

6:20

main sort of difference over here. So,

6:23

the entire API reference for all of

6:25

these things are available here. The

6:27

only thing that you'll have to do is

6:28

just verify your organization um

6:31

generate a new API key and then you can

6:33

use this as a reference for whatever app

6:36

that you wanted to create by yourself.

6:38

So in my case the what I did was I

6:41

simply u copied this entire

6:44

documentation and I put it onto VS code

6:46

client and this is what it gave me. I

6:49

just simply went over here and I said,

6:51

"Hey, you know, can you convert this

6:53

into a web application and it did it did

6:56

all of those things for me." So, if you

6:59

haven't watched my series before on um

7:02

you know, vibe coding or AI based coding

7:04

or anything like that, I'm going to link

7:05

that in the description. Um that will

7:07

show you exactly how I'm not really a

7:09

coder, but I've coded all of these

7:10

things from scratch. Sure, there there

7:13

could be some flaws and security

7:14

vulnerabilities, but I've made sure not

7:16

to include any of my API keys in the end

7:18

variable. And just for safety, I will

7:20

still purge all of my API keys after

7:22

this video. Now, within Open Web UI,

7:25

that's the other place that I've

7:26

actually put this into as a pipe

7:28

function. So, if I go over here to my

7:30

admin panel and then select my functions

7:34

over here, the image gen, that's the

7:36

function that I created. I also have one

7:38

for variations of an existing image. Um

7:41

but the image gen this takes in a list

7:43

of different things as the input. So for

7:46

example over here I can provide it um a

7:48

lot of these different factors and I'm

7:50

also going to upload this as well. Um

7:53

the idea here is that if I go to my

7:55

valves I can okay now I definitely have

7:58

to purge this API key but I provided the

8:01

API base URL the model the size like

8:04

what if I want 1024 um or you know for

8:07

example 1024* 1536 and then the quality

8:11

for example if I want high quality low

8:12

or medium quality uh the output format

8:15

what I want that as and the moderation

8:17

whether I want auto or low for example

8:20

and then you can hit save And remember

8:23

that this is a pipe function. So if you

8:25

want haven't watched my video on pipe

8:26

function before, I'm going to link that

8:27

in the description. But basically a pipe

8:29

function is a model that you can choose

8:31

on the open web UI interface. So you can

8:33

simply choose this model and then ask it

8:35

to generate an image of a cyber punk

8:40

car, cool ghoul, weapons, guns, etc. And

8:44

then this is now going to be sending

8:45

this to the OpenAI API for image

8:48

generation. And then it's going to be

8:50

returning that particular image back.

8:52

And there we go. So, uh, created this

8:55

image of Cyberpunk, cool car, weapons,

8:57

and guns. So, it's interesting that it

9:00

selected this car. That's nice. Well,

9:02

either way, you get you get the idea.

9:04

So, what I'm going to do is um, as soon

9:06

as this video ends, I'll make sure that

9:08

I push all of my changes to the GitHub

9:10

repository. So, you can go in and you

9:13

can start using the app that I've also

9:15

created. Maybe if you wanted to like

9:16

play around with it, I'll make sure to

9:17

include a readme file as well. Um, you

9:21

can go in create like different variants

9:23

of this app. U, the only thing that

9:25

you'll need to do is add the API key in

9:28

the environment variable and then

9:30

everything else will just run um fine.

9:33

So, if you do create a multi-million

9:35

dollar SAS business, then please

9:37

remember to tip Professor Patterns. Uh,

9:40

but that's it for this video. Thank you

9:41

for tuning in. I will make a more

9:44

in-depth video as well on some other

9:46

things that I am thinking about doing

9:48

with this API. But uh for now, that's

9:51

it. Thanks for tuning in. I'll see you

9:52

in the next one. Goodbye.

Interactive Summary

This video provides a comprehensive guide on utilizing the new OpenAI image generation API. It demonstrates practical applications like building a local AI photo booth, integrating the API as a pipe function within Open Web UI, and covers technical aspects such as configuring API keys, adjusting parameters like image quality and format, and managing costs. The creator shares their approach to 'vibe coding' to build these applications and provides resources for viewers to experiment with their own implementations.

Suggested questions

4 ready-made prompts