What if we instead want to consume Azure
OpenAI instead of OpenAI?
Well, we only need to switch out this
top part, meaning this API key is not
Azure OpenAI, but instead we need another API
key, and for Azure we also need an
endpoint.
So, let's make ready for an endpoint, and
let's go to ai.azure.com and get
our credentials up here.
If you don't have one of these, you
can go in and say create new project,
and then you have your new endpoint.
I already made mine here, and we need
to do three things.
The first thing is we need to get
our endpoint, and if we look at this
endpoint, it has a name here.
In this case, my endpoint is this, and
then it has some project part over here.
The project part we cannot use directly with
a direct access model like this.
This is more for something called Microsoft Foundry,
which we'll cover later in this series.
So, for now, we just take the endpoint
and get rid of the slash API part
down here, and then we get our API
key, and again, I'm going to show you
my API key, but I will have revoked
it before you see this video, and so
you can't use it for anything like this.
So, this is what we need, and we
need to talk with Azure instead of OpenAI,
so we need an Azure OpenAI client.
That is an additional key up here, our
NuGet package, which is called Azure.AI.OpenAI,
and we'll wrap that as well and put
it in, and now the only thing we
really need to do is we need to
say instead of OpenAI client, we need to
say Azure OpenAI client, and have a new
of those, and provides an endpoint and
an API key.
It is possible instead of an API key
to also use the role-based access system
from Azure, but we'll cover that later on
in the system, but it's essentially just using
the Azure default credentials or Azure CLI credentials.
For now, we're going to use an API
key, and we have our connection.
The rest is actually exactly the same.
The only thing is that in OpenAI, you
don't need to deploy the model yourself.
You need to do that in Azure, so
what you need to do is you need
to go to the portal again and go
to the Build tab here, go to Models,
and then Deploy a Model.
You can see I've already deployed chat gpt-4.1-nano
Nano here, gpt-5-nano, and Text-Embedding-3-Small,
which is the three ones we are going
to use throughout this series.
But if you need to deploy a new
model, you simply press Deploy here.
You get to choose among all the different
models they have available, so that we wanted
to need to deploy a ChatGPT.
Let's find one of the mini models.
Let's say we wanted to deploy the 4.1
mini.
We go to the Deploy tab here.
You can either deploy with default.
I tend to always do it with custom,
and we can choose how we want to
deploy it using global settings or standard settings.
This is beyond the scope of this video,
how many tokens per minute we will allow,
and we would deploy because else it wouldn't
understand it in Azure OpenAI.
So they control what models can be chosen
by the developer instead of in OpenAI, where
you just have access to all models.
So if we run this code instead of
OpenAI, we will see hopefully exactly the same
outcome.
And as it says, the capital of France
is Paris.