Now.
Steps three and four of the set of instructions are optional.
I strongly recommend that you get an account with OpenAI if you don't have one already, so that we
can use the most powerful models on the planet, and OpenAI is a good one to start with.
But you don't need to.
It requires a payment $5 up front, and you might not want to spend that.
And you can use free models throughout this course.
You can use Gemini or you can use llama.
And there are detailed instructions for how to do it.
And I will have an example lab as well.
But assuming that you do want to go ahead and set up an OpenAI account, you may already have one as
well.
Let's do that.
That is step three, and feel free to skip this or just watch what I do if you don't want to.
So you go to a web browser.
I've got an incognito tab here.
So because I'm already logged into OpenAI, but you go to platform OpenAI, that is where you come to
the kind of the API side of OpenAI, not to use ChatGPT, but to have your own account to use the API.
and that's an important point.
Some people are confused about the fact that there is ChatGPT the product which you can interact with
and which has a paid plan for like $20 a month and an even higher tier paid plan.
And then separate to that, there is an API, the OpenAI API, for connecting to the model directly.
And people, some people are confused about that and say, hey, if I'm paying for one, why can't I
have the other?
Luckily, I've written a guide about exactly that.
There's a guide called Technical Foundations, which you'll find in the guides folder.
It takes you through some of the foundational information to help you navigate through some of these
concepts.
And I explain very clearly the difference between the product ChatGPT and using the API from an AI engineer's
point of view.
So do please read that if you've got any confusion.
But assuming that that's that's obvious to you, then then great, come here.
Come to platform OpenAI.
And the first thing to do is to click sign up.
And you can then come in and use like your your Google auth any or Microsoft account or an Apple account,
or just create an account with an email address.
I think people that are coming internationally outside the US, you might need to click a button like
create organization or something first.
You might need to click through some screen before you get to create your account, but it should be
pretty obvious you should get here.
Sign up for an account.
So far, it's completely free.
The money will come in just a second.
The $5 spend.
Uh, let's let's, uh, come back once you've set up your account.
Okay.
So this is what you see once you come to platform and once you've signed in with an account, and the
navigation is just a little bit confusing, but you have to be aware that at the top here there's dashboard.
And over on the right there's settings.
And the first thing to do is to go over to settings, which is where the billing information is, and
go to settings and then come down to billing right here.
And this is where you get to put a balance on OpenAI.
OpenAI is a pay as you go model, which means you put down an amount of money and then you draw down
against that over time and you only spend.
Tiny amounts of money on this course.
We will spend fractions of a cent, typically for each of our projects.
Except where I tell you otherwise, you should always track your your spend always come back here.
The nice thing about this is that because it's a pay as you go model, you're always paying up front.
You're not likely to get some kind of surprise as long as you only top up with a small amount.
There are some some other services like AWS where it doesn't work that way, which I don't like.
This one is better because you get to be in complete control of your spend.
Nonetheless, you should come back and have a look at it.
You should always have auto recharge off.
You don't want it to automatically recharge.
Don't press that.
Enable auto recharge button.
You don't want it automatically billing to your credit card, unless this is something that you're in
production and you know exactly what you're doing.
So the first thing you do when you come in here, you should see zero credit balance.
And you will want to press the Add to credit balance button.
And you'll want to to type in an amount there.
And you'll want to select a payment method.
And then once you've done that, you would then add that amount and sorry, $5 is the minimum.
You don't need to spend $10.
$5 is the minimum payment amount.
You will then draw down and that lasts a year.
So you've got you've got plenty of time to spend that $5.
You need to make sure that your payment methods includes a valid credit card that you can charge against.
Otherwise, OpenAI will throw various errors.
So make sure that you add a proper payment method which it can use.
And I should mention a lot of students do have problems with payments not being accepted, getting declined
through through OpenAI.
And it's worth pointing out that almost always most of the time, any time that I've been aware of that
problem is with your credit card not accepting OpenAI's charge as an international vendor, OpenAI is
happy to take your money if you let it.
It's unlikely to be a problem with OpenAI.
It's more likely that your credit card company, for whatever reason, is refusing an international
charge.
And so you might need to go into your to your bank account and select something which enables that kind
of charge.
Perhaps something to look out for.
Otherwise, if you if you really can't get past this and can't get a balance on there, then you can
contact OpenAI support.
They're actually really responsive.
Okay.
But let me assume you've done this.
This is now showing $5 and it's looking great.
You've got a good payment method associated with your account.
We're ready to set up an API key.
Okay.
So you're still in settings.
You're still seeing this menu up here.
And the first thing to do is to select API keys up here making sure you're under the organization heading.
You're right up here API keys.
And here you go.
You can see that that I have some API keys.
And you're going to make one yourself.
Right now these are your API keys.
And it's super important to be careful about what you do next.
You're going to press the Create new Secret key button like so.
You're going to want to create a new secret key.
It is owned by you not service account.
You can give it whatever name you want, but something that you remember, like, uh, LM engineering
key.
And now be careful with this for the project.
Select default project because you don't want to have any extra constraints.
If people if you do anything clever here that that constrains it in some way, then you might get errors
later.
So just have default project, which means any project can access this and leave permissions at all.
And then you're going to press the Create secret key button.
And when you do that which I will do it now it will come up with a key like this.
And fear not I'm going to delete this key right afterwards.
Aha.
Uh this key is your key with OpenAI.
It's your way to link your code to using OpenAI.
And it begins ESC hyphen, hyphen.
And then this long thing right here.
And that is your secret key.
And that's something which we're going to be using in our code.
And if you get this wrong, if you type, if you, if you change one of these numbers or one of these
letters, it's like a password.
Everything has to be right.
If something's wrong, it's not going to work.
So copy it into your clipboard by pressing copy.
It's now copied.
So when you press paste, it's going to paste.
And in a minute we're going to paste it somewhere.
And please now don't don't paste it somewhere else first and then copy it again or anything that might
mess with the key.
Let it be in your clipboard in pristine shape.
We're not going to change it.
We're going to paste it exactly as it is into our actual inter cursor.
So keep it like this.
In fact, you don't even need to press the done button yet.
You can keep this screen up here.
We're going to go back to cursor and put this in cursor right away.
Let's go do that.
So here I am back in cursor.
By the way if you have one of your terminal screens appearing like this, you can close it just by pressing
the X button there.
So you've got nice clean screen.
Okay.
What we're going to do now is create a file called the file, which is a file that contains your secrets.
And it's super important that you do this carefully.
It's got to be right or things ain't going to work.
So?
So this needs to be right.
The EMV file is a new file we're going to create, which has to be at the top level.
It has to be a file within LM engineering not inside any of these directories.
So what we can do is we can get this little blank space just here underneath the bottom of this list
of files.
You can right click there and say new file.
And you can see it's now giving me a new file.
And you can just double check.
It's at the same top level as all these other top level files.
And I'm going to call it it's going to be called exactly a period dot like that.
And then the letter E and the letter n and the letter v e v and it can't be called dot EMV dot txt.
It can't be called EMV in your name.
It can't be called EMV dot it.
In case you didn't get the message, it's got to be called EMV and only that and it's got to be in the
project root in this top folder.
And there it is.
That is the right place to be Okay.
And now what I'm going to put in here is going to be my open AI key.
And here's how you do it.
You have to type open AI underscore API underscore key.
And it's got to be exactly this open AI underscore API underscore key.
It's got to be in block capitals.
It's not this it's not open API key.
It's open AI API key.
Now you wonder why I'm going on about this.
I get more than a thousand emails every couple of during every few weeks.
I get that many emails from people that have mistyped these words.
So don't do that.
Spell it open AI API key exactly like this.
Uh, then equals it's open ai API key equals.
And then you're going to press paste.
And when you do paste it's going to paste in that key that you copied from the open AI screen.
Let's check it out.
Look it's open OpenAI.
API key equals sq.
Proj dash.
And then this long funny thing.
And there's nothing crazy at the end of it.
We haven't pasted in an extra space.
An extra empty.
We've been careful.
It is exactly this.
Now, that white blob just to the right there means that I haven't yet saved this file.
It's not been saved.
It's not on the disk, which means it's empty as far as my computer is concerned.
So I have to press command S Ctrl s on a PC, command S on a mac or file save to save it, and the white
blob goes away.
And that means it's now saved.
This is now in the file I get, I get, I get hundreds of emails from people that haven't saved the
files.
Saved the file.
You'll see that there is a little stop sign next to it.
I also get hundreds of emails from people that are worried about that stop sign.
But that stop sign is actually good news.
That stop sign is cursor telling you if you hover over it, it will tell you.
It's telling you that AI features are disabled for this file.
And the reason for that is that this file contains your secrets.
This contains your precious key that connects you to OpenAI and to your credit card.
And we don't want that leaking out.
And particularly we don't want cursor sending this off to different AI to get some sort of information
on it.
So as a result, cursor is saying, hey, hands off.
I'm I'm not going to touch this file.
I'm not going to do AI suggestions for this file.
This file is secretly just for you.
So we like to see that stop sign.
That is good news.
Look out for it in anything with secrets in it.
Like the EMV file.
All right I think I belabored this one enough.
You've got a EMV file.
It's called exactly EMV.
It's in your project root.
In the top level.
It says OpenAI API key in block capitals equals.
And then it's got this key right here that you have taken from your your actual API key that you took
from OpenAI.
And you pasted it in here.
Congratulations.
You've got through the hardest part of the whole course getting the API key in there.
Let's move on.