WEBVTT

1
00:00:00.820 --> 00:00:05.320
What if we instead want to consume Azure

2
00:00:05.320 --> 00:00:07.280
OpenAI instead of OpenAI?

3
00:00:08.100 --> 00:00:11.880
Well, we only need to switch out this

4
00:00:11.880 --> 00:00:15.300
top part, meaning this API key is not

5
00:00:15.300 --> 00:00:20.600
Azure OpenAI, but instead we need another API

6
00:00:20.600 --> 00:00:24.520
key, and for Azure we also need an

7
00:00:24.520 --> 00:00:24.940
endpoint.

8
00:00:27.760 --> 00:00:33.580
So, let's make ready for an endpoint, and

9
00:00:33.580 --> 00:00:38.960
let's go to ai.azure.com and get

10
00:00:38.960 --> 00:00:40.400
our credentials up here.

11
00:00:41.380 --> 00:00:43.760
If you don't have one of these, you

12
00:00:43.760 --> 00:00:45.460
can go in and say create new project,

13
00:00:45.920 --> 00:00:49.600
and then you have your new endpoint.

14
00:00:49.600 --> 00:00:53.320
I already made mine here, and we need

15
00:00:53.320 --> 00:00:55.040
to do three things.

16
00:00:55.460 --> 00:00:57.160
The first thing is we need to get

17
00:00:57.160 --> 00:01:01.280
our endpoint, and if we look at this

18
00:01:01.280 --> 00:01:03.459
endpoint, it has a name here.

19
00:01:04.019 --> 00:01:08.100
In this case, my endpoint is this, and

20
00:01:08.100 --> 00:01:10.380
then it has some project part over here.

21
00:01:10.700 --> 00:01:14.200
The project part we cannot use directly with

22
00:01:14.200 --> 00:01:16.660
a direct access model like this.

23
00:01:16.660 --> 00:01:19.940
This is more for something called Microsoft Foundry,

24
00:01:20.200 --> 00:01:22.860
which we'll cover later in this series.

25
00:01:23.660 --> 00:01:25.600
So, for now, we just take the endpoint

26
00:01:25.600 --> 00:01:28.220
and get rid of the slash API part

27
00:01:28.220 --> 00:01:32.200
down here, and then we get our API

28
00:01:32.200 --> 00:01:34.340
key, and again, I'm going to show you

29
00:01:34.340 --> 00:01:39.220
my API key, but I will have revoked

30
00:01:39.220 --> 00:01:45.180
it before you see this video, and so

31
00:01:45.180 --> 00:01:47.420
you can't use it for anything like this.

32
00:01:48.300 --> 00:01:51.960
So, this is what we need, and we

33
00:01:51.960 --> 00:01:55.660
need to talk with Azure instead of OpenAI,

34
00:01:55.960 --> 00:01:58.140
so we need an Azure OpenAI client.

35
00:01:59.240 --> 00:02:04.960
That is an additional key up here, our

36
00:02:04.960 --> 00:02:09.060
NuGet package, which is called Azure.AI.OpenAI,

37
00:02:10.220 --> 00:02:16.420
and we'll wrap that as well and put

38
00:02:16.420 --> 00:02:21.440
it in, and now the only thing we

39
00:02:21.440 --> 00:02:23.100
really need to do is we need to

40
00:02:23.100 --> 00:02:26.120
say instead of OpenAI client, we need to

41
00:02:26.120 --> 00:02:32.220
say Azure OpenAI client, and have a new

42
00:02:32.220 --> 00:02:41.940
of those, and provides an endpoint and

43
00:02:41.940 --> 00:02:43.300
an API key.

44
00:02:43.780 --> 00:02:47.820
It is possible instead of an API key

45
00:02:47.820 --> 00:02:51.920
to also use the role-based access system

46
00:02:51.920 --> 00:02:56.900
from Azure, but we'll cover that later on

47
00:02:56.900 --> 00:03:00.020
in the system, but it's essentially just using

48
00:03:00.020 --> 00:03:04.200
the Azure default credentials or Azure CLI credentials.

49
00:03:04.940 --> 00:03:06.580
For now, we're going to use an API

50
00:03:06.580 --> 00:03:11.520
key, and we have our connection.

51
00:03:12.080 --> 00:03:14.960
The rest is actually exactly the same.

52
00:03:15.500 --> 00:03:19.200
The only thing is that in OpenAI, you

53
00:03:19.200 --> 00:03:21.420
don't need to deploy the model yourself.

54
00:03:21.420 --> 00:03:25.760
You need to do that in Azure, so

55
00:03:25.760 --> 00:03:28.380
what you need to do is you need

56
00:03:28.380 --> 00:03:31.440
to go to the portal again and go

57
00:03:31.440 --> 00:03:35.020
to the Build tab here, go to Models,

58
00:03:35.400 --> 00:03:37.340
and then Deploy a Model.

59
00:03:37.520 --> 00:03:40.540
You can see I've already deployed chat gpt-4.1-nano

60
00:03:40.540 --> 00:03:47.360
Nano here, gpt-5-nano, and Text-Embedding-3-Small,

61
00:03:47.540 --> 00:03:49.060
which is the three ones we are going

62
00:03:49.060 --> 00:03:51.300
to use throughout this series.

63
00:03:52.820 --> 00:03:55.920
But if you need to deploy a new

64
00:03:55.920 --> 00:03:59.380
model, you simply press Deploy here.

65
00:03:59.840 --> 00:04:02.180
You get to choose among all the different

66
00:04:02.180 --> 00:04:05.440
models they have available, so that we wanted

67
00:04:05.440 --> 00:04:08.980
to need to deploy a ChatGPT.

68
00:04:09.280 --> 00:04:11.540
Let's find one of the mini models.

69
00:04:17.540 --> 00:04:21.600
Let's say we wanted to deploy the 4.1

70
00:04:21.600 --> 00:04:22.000
mini.

71
00:04:23.100 --> 00:04:24.960
We go to the Deploy tab here.

72
00:04:25.140 --> 00:04:26.680
You can either deploy with default.

73
00:04:27.140 --> 00:04:29.000
I tend to always do it with custom,

74
00:04:31.340 --> 00:04:34.660
and we can choose how we want to

75
00:04:34.660 --> 00:04:37.840
deploy it using global settings or standard settings.

76
00:04:38.620 --> 00:04:40.780
This is beyond the scope of this video,

77
00:04:41.080 --> 00:04:44.240
how many tokens per minute we will allow,

78
00:04:44.980 --> 00:04:48.780
and we would deploy because else it wouldn't

79
00:04:48.780 --> 00:04:50.440
understand it in Azure OpenAI.

80
00:04:50.440 --> 00:04:55.580
So they control what models can be chosen

81
00:04:55.580 --> 00:05:00.260
by the developer instead of in OpenAI, where

82
00:05:00.260 --> 00:05:01.860
you just have access to all models.

83
00:05:04.180 --> 00:05:07.380
So if we run this code instead of

84
00:05:07.380 --> 00:05:12.360
OpenAI, we will see hopefully exactly the same

85
00:05:12.360 --> 00:05:13.060
outcome.

86
00:05:15.080 --> 00:05:17.420
And as it says, the capital of France

87
00:05:17.420 --> 00:05:18.140
is Paris.
