1
00:00:00,080 --> 00:00:05,200
All right, so I'll do some more typing since since the haters will yell at me if I don't, so I'll
好吧，所以我会再打字，因为如果我不打字，讨厌者就会对我大喊大叫，所以我会

2
00:00:05,200 --> 00:00:06,040
do some typing.
打字。

3
00:00:06,080 --> 00:00:08,000
Let's do it the proper way.
让我们以正确的方式来做吧。

4
00:00:08,240 --> 00:00:11,360
Let's create an OpenAI Python client.
让我们创建一个 OpenAI Python 客户端。

5
00:00:11,360 --> 00:00:13,720
You just say OpenAI equals OpenAI.
你只是说 OpenAI 就等于 OpenAI。

6
00:00:13,840 --> 00:00:15,800
Oops, like so.
哎呀，就像这样。

7
00:00:16,160 --> 00:00:24,000
And it by default looks in the uh, in the environment variable OpenAI API key by default if you don't
如果您不这样做，它默认会在环境变量 OpenAI API 密钥中查找

8
00:00:24,000 --> 00:00:24,760
specify one.
请指定一个。

9
00:00:24,760 --> 00:00:27,240
So that's just just hard coded in there.
所以这只是硬编码在那里。

10
00:00:27,240 --> 00:00:30,920
And I have to say from OpenAI import OpenAI to be able to do that.
我不得不说从 OpenAI 导入 OpenAI 才能做到这一点。

11
00:00:31,120 --> 00:00:31,720
Okay.
好的。

12
00:00:31,760 --> 00:00:37,760
And now what we're going to say is, uh, response equals I guess it just fills it in.
现在我们要说的是，呃，响应等于我想它只是填充了它。

13
00:00:37,760 --> 00:00:46,000
What's the point in me typing OpenAI chat dot completions dot create.
我输入 OpenAI 聊天点完成点创建有什么意义。

14
00:00:46,040 --> 00:00:52,480
So that is basically saying I want to go to slash chat completions and I want to do a post request,
所以这基本上是说我想要进行斜杠聊天完成并且我想做一个发布请求，

15
00:00:52,480 --> 00:00:54,200
which is like doing a create.
这就像进行创建一样。

16
00:00:54,360 --> 00:00:57,840
And I'm going to pass in like I don't have to manufacture JSON.
我将传递就像我不必制造 JSON 一样。

17
00:00:57,840 --> 00:01:03,400
I can just say model equals GPT five nano five nano.
我只能说模型等于 GPT 5 nano 5 nano。

18
00:01:03,520 --> 00:01:04,760
Oh, I could just press tab.
哦，我可以按 Tab 键。

19
00:01:04,760 --> 00:01:05,360
You know it.
你知道的。

20
00:01:05,360 --> 00:01:06,600
You know what I'm gonna say?
你知道我要说什么吗？

21
00:01:06,900 --> 00:01:10,740
messages is that list of dictionaries that I passed in right there.
messages 是我在那里传递的字典列表。

22
00:01:11,100 --> 00:01:18,860
And then instead of this fussy JSON plowing, I can just say response dot choices.
然后我可以直接说响应点选择，而不是这种繁琐的 JSON 操作。

23
00:01:18,900 --> 00:01:25,860
Zero choices, zero dot message content.
零选择，零点消息内容。

24
00:01:25,860 --> 00:01:28,740
And I'm just going through Python fields.
我只是浏览一下 Python 领域。

25
00:01:28,820 --> 00:01:31,940
It's actually pedantic object of course, for people that know this stuff.
当然，对于了解这些东西的人来说，这实际上是一个迂腐的对象。

26
00:01:32,100 --> 00:01:41,020
Uh, and uh, as a result, it's got all of the, all of the nice features of using proper Python methods
呃，呃，因此，它具有使用正确的 Python 方法的所有、所有好的功能

27
00:01:41,020 --> 00:01:44,980
and attributes like, like the ID can check, I've spelt it right and things like that.
还有诸如 ID 可以检查、我拼写正确之类的属性。

28
00:01:45,020 --> 00:01:48,780
I'm not just guessing, uh, values to to look into the JSON.
我不只是猜测，呃，查看 JSON 的值。

29
00:01:48,780 --> 00:01:50,180
I know that I've got this right.
我知道我做对了。

30
00:01:50,580 --> 00:01:55,380
And so I run this and we should get ourselves a new fun fact.
所以我运行这个，我们应该得到一个新的有趣的事实。

31
00:01:55,580 --> 00:01:59,180
And the thing to, to understand, uh, here we go.
以及要理解的事情，呃，我们开始吧。

32
00:01:59,220 --> 00:02:01,900
Bananas are berries, but strawberries aren't.
香蕉是浆果，但草莓不是。

33
00:02:01,940 --> 00:02:03,180
Strawberries are not.
草莓则不然。

34
00:02:03,460 --> 00:02:04,460
And and there we go.
我们就这样吧。

35
00:02:04,540 --> 00:02:05,700
We've got our explanation for that.
我们对此有自己的解释。

36
00:02:05,740 --> 00:02:08,260
A lovely, fun fact from GPT five nano.
GPT 5 nano 的一个可爱又有趣的事实。

37
00:02:08,300 --> 00:02:09,620
I hope you've been enjoying yours too.
我希望你也玩得很开心。

38
00:02:10,060 --> 00:02:16,600
Of course, the point I'm trying to make to you is that this is exactly the same as doing it the boring
当然，我想向你说明的一点是，这与做无聊的事情完全相同。

39
00:02:16,640 --> 00:02:17,080
way.
方式。

40
00:02:17,120 --> 00:02:20,080
It's just this looks a little bit more elegant and simple.
只是这样看起来更加优雅和简单一些。

41
00:02:20,080 --> 00:02:24,000
And the reason I show you this is so that hopefully, and maybe this is all obvious to you, in which
我向您展示这一点的原因是希望，也许这对您来说都是显而易见的，其中

42
00:02:24,000 --> 00:02:25,440
case, well, hang on in there.
情况，好吧，坚持住。

43
00:02:25,760 --> 00:02:29,640
But if not, it just shows you that's all that this library is.
但如果没有，它只是向您展示了这个库的全部内容。

44
00:02:29,640 --> 00:02:35,960
At the end of the day, it's just a nice, simple wrapper around making an HTTP call to an API in the
归根结底，它只是一个很好的、简单的包装器，用于对 API 中的 HTTP 调用

45
00:02:35,960 --> 00:02:36,520
cloud.
云。

46
00:02:36,800 --> 00:02:39,760
And it by default it looks for OpenAI API key.
默认情况下，它会查找 OpenAI API 密钥。

47
00:02:39,760 --> 00:02:46,440
And that's what it puts in that bearer in that that authorization field in the headers of the HTTP request.
这就是它在 HTTP 请求标头的授权字段中放置的内容。

48
00:02:46,640 --> 00:02:48,400
And it's as simple as that.
就这么简单。

49
00:02:48,400 --> 00:02:51,920
We have made our call to OpenAI on the cloud.
我们已经向云上的 OpenAI 发出了呼吁。

50
00:02:51,920 --> 00:02:53,720
It looks like we did it with code.
看起来我们是用代码做到的。

51
00:02:53,720 --> 00:02:57,240
In fact, it was an HTTP call over an endpoint.
事实上，这是通过端点进行的 HTTP 调用。

52
00:02:57,240 --> 00:02:58,040
Over an endpoint.
越过一个端点。

53
00:02:58,200 --> 00:03:01,320
What I meant to say was it's an endpoint call over HTTP.
我的意思是它是通过 HTTP 进行的端点调用。

54
00:03:01,560 --> 00:03:02,200
All right.
好的。

55
00:03:02,520 --> 00:03:04,000
So I've already typed all this.
所以我已经输入了所有这些内容。

56
00:03:04,000 --> 00:03:04,680
We can get rid of that.
我们可以摆脱它。

57
00:03:04,680 --> 00:03:05,480
Get rid of that.
摆脱它。

58
00:03:05,840 --> 00:03:08,640
So so then something cool happened.
就这样，然后发生了一些很酷的事情。

59
00:03:08,800 --> 00:03:17,680
So then OpenAI's chat completions API was so popular that all the other providers started to offer an
因此，OpenAI 的聊天完成 API 非常受欢迎，以至于所有其他提供商都开始提供

60
00:03:17,860 --> 00:03:19,580
identical end point.
相同的终点。

61
00:03:19,580 --> 00:03:25,340
So you could use exactly the same web request and and just call a different model instead, because
因此，您可以使用完全相同的 Web 请求，然后调用不同的模型，因为

62
00:03:25,340 --> 00:03:29,420
people sort of converged on OpenAI's approach as a way to do it.
人们都倾向于将 OpenAI 的方法作为实现这一目标的一种方式。

63
00:03:29,420 --> 00:03:31,540
So everyone else offered them to Gemini.
所以其他人都把它们送给了双子座。

64
00:03:31,580 --> 00:03:35,940
Google, for example, they had one endpoint that was very specific to Gemini, and they were like,
例如，谷歌，他们有一个专门针对 Gemini 的端点，他们就像，

65
00:03:35,980 --> 00:03:39,740
oh, I know what, we'll just give a second one that's identical for anyone that wants it.
哦，我知道什么，我们只会为任何想要它的人提供第二个相同的。

66
00:03:39,980 --> 00:03:43,980
And out of all of them, anthropic held out the longest.
在所有这些中，人类坚持的时间最长。

67
00:03:44,020 --> 00:03:46,580
They they obviously their enemy OpenAI.
他们显然是他们的敌人 OpenAI。

68
00:03:46,620 --> 00:03:48,420
They didn't want that to become the standard.
他们不希望这成为标准。

69
00:03:48,420 --> 00:03:49,300
So they held out.
所以他们坚持了下来。

70
00:03:49,300 --> 00:03:50,740
But in the end they relented.
但最终他们还是妥协了。

71
00:03:50,740 --> 00:03:55,580
And they also created an OpenAI compatible endpoint.
他们还创建了一个 OpenAI 兼容端点。

72
00:03:55,580 --> 00:03:57,660
So now all of them have it.
所以现在他们都拥有了。

73
00:03:57,820 --> 00:04:00,220
And for example, this is Google's one.
例如，这是谷歌的一个。

74
00:04:00,460 --> 00:04:02,180
It's Https generative.
它是 Https 生成的。

75
00:04:06,900 --> 00:04:07,620
OpenAI.
开放人工智能。

76
00:04:07,900 --> 00:04:09,940
It's got OpenAI in its name.
它的名字中有 OpenAI。

77
00:04:10,140 --> 00:04:14,540
That is their endpoint for making OpenAI compatible request.
这是他们发出 OpenAI 兼容请求的端点。

78
00:04:15,140 --> 00:04:21,980
And because everybody did this, OpenAI decided, oh, I guess we'll be good corporate citizens, good
因为每个人都这样做了，OpenAI 决定，哦，我想我们会成为优秀的企业公民，很好

79
00:04:21,980 --> 00:04:23,100
AI citizens.
人工智能公民。

80
00:04:23,100 --> 00:04:23,310
Reasons.
原因。

81
00:04:23,350 --> 00:04:28,510
And we'll say to people, look, you can use the same OpenAI library.
我们会对人们说，看，你可以使用相同的 OpenAI 库。

82
00:04:28,510 --> 00:04:35,710
The same client library will allow you to say, hey, I don't actually want to talk to OpenAI's endpoint.
同一个客户端库将允许您说，嘿，我实际上不想与 OpenAI 的端点对话。

83
00:04:35,710 --> 00:04:39,190
I want to switch to a different endpoint like this.
我想像这样切换到不同的端点。

84
00:04:39,190 --> 00:04:47,270
You can say OpenAI base URL equals and switch to a different URL and pass in a different API key.
您可以说 OpenAI 基本 URL 等于并切换到不同的 URL 并传入不同的 API 密钥。

85
00:04:47,670 --> 00:04:54,350
And if you do that, then you can talk to Gemini using OpenAI's client library because it's just simple,
如果你这样做了，那么你就可以使用 OpenAI 的客户端库与 Gemini 交谈，因为它很简单，

86
00:04:54,350 --> 00:04:55,470
lightweight code.
轻量级代码。

87
00:04:55,710 --> 00:04:56,270
That's it.
就是这样。

88
00:04:56,270 --> 00:05:02,790
And so yeah, just to be crystal clear, even though OpenAI is is in our code here, we're not actually
所以，是的，澄清一下，尽管 OpenAI 存在于我们的代码中，但我们实际上并没有

89
00:05:02,790 --> 00:05:05,430
using anything to do with OpenAI's models.
使用任何与 OpenAI 模型有关的东西。

90
00:05:05,430 --> 00:05:08,990
We're just using their lightweight code to make an endpoint request.
我们只是使用他们的轻量级代码来发出端点请求。

91
00:05:08,990 --> 00:05:10,350
And you might know all this back to front.
你可能从头到尾都知道这一切。

92
00:05:10,350 --> 00:05:14,990
This might be super obvious to you, but you'd be amazed how many people are confused by this and that
这对你来说可能是非常明显的，但你会惊讶地发现有多少人对此感到困惑

93
00:05:14,990 --> 00:05:18,670
this can be really refreshing to understand exactly how this works.
了解其工作原理确实令人耳目一新。

94
00:05:18,670 --> 00:05:23,070
So if you're in that category, then then, then I'm pleased to hear it and it's going to hopefully
所以，如果你属于这一类，那么，那么我很高兴听到它，并且希望它会

95
00:05:23,070 --> 00:05:25,030
make a lot of sense what we do next.
让我们接下来要做的事情变得很有意义。

96
00:05:25,030 --> 00:05:25,590
Okay.
好的。

97
00:05:25,630 --> 00:05:30,930
So uh, we are going to look at Gemini's base URL.
所以呃，我们要看看 Gemini 的基本 URL。

98
00:05:30,930 --> 00:05:32,210
That's the one I just showed you.
这就是我刚刚给你看的那个。

99
00:05:32,210 --> 00:05:36,050
It's like a Google URL with OpenAI stuffed at the end of it.
它就像一个末尾填充了 OpenAI 的 Google URL。

100
00:05:36,490 --> 00:05:39,970
In my EMV file, I have a Google API key.
在我的 EMV 文件中，我有一个 Google API 密钥。

101
00:05:40,010 --> 00:05:43,250
Now you might not do it, in which case, don't worry, just just skip this next one.
现在您可能不会这样做，在这种情况下，不用担心，只需跳过下一个即可。

102
00:05:43,250 --> 00:05:49,930
But if you do, if you've got a Gemini or a Gemini API key, then then hopefully you've added Google
但如果你这样做了，如果你有 Gemini 或 Gemini API 密钥，那么希望你已经添加了 Google

103
00:05:49,930 --> 00:05:51,890
API key to your EMV file.
您的 EMV 文件的 API 密钥。

104
00:05:52,010 --> 00:05:57,490
Uh, then then you can run this cell and uh, I'm just going to run it and it's going to confirm that
呃，然后你可以运行这个单元格，呃，我将运行它，它将确认

105
00:05:57,490 --> 00:06:04,530
it found a Google API key in my EMV, and that it has the right format R and Z.
它在我的 EMV 中找到了 Google API 密钥，并且它具有正确的 R 和 Z 格式。

106
00:06:04,930 --> 00:06:08,130
And if you yeah, if you want to get yourself an API key, you can you can head over.
如果你是的，如果你想给自己一个 API 密钥，你可以直接过去。

107
00:06:08,130 --> 00:06:09,650
The instructions are in guide nine.
说明位于指南九中。

108
00:06:09,690 --> 00:06:11,330
That will tell you exactly what you need to do.
这会准确地告诉您需要做什么。

109
00:06:11,530 --> 00:06:12,050
Okay.
好的。

110
00:06:12,210 --> 00:06:16,330
So now look at this line Gemini is OpenAI.
那么现在看这条线Gemini就是OpenAI。

111
00:06:16,450 --> 00:06:20,210
Remember it's just the lightweight Python client library.
请记住，它只是轻量级 Python 客户端库。

112
00:06:20,250 --> 00:06:25,090
We give it the Gemini base URL and we give it the Google API key.
我们给它 Gemini 基本 URL，并给它 Google API 密钥。

113
00:06:25,330 --> 00:06:31,090
And that has now given me a, a basically like a class that's ready to connect to Gemini.
现在，这给了我一个基本上就像一个准备连接到 Gemini 的类。

114
00:06:31,410 --> 00:06:31,970
Okay.
好的。

115
00:06:32,290 --> 00:06:36,430
So what we can basically do is take exactly the same code that we had before.
所以我们基本上可以做的就是采用与之前完全相同的代码。

116
00:06:36,670 --> 00:06:37,910
Come back up here.
回到这里来。

117
00:06:37,910 --> 00:06:39,950
I can just copy this.
我可以复制这个。

118
00:06:40,630 --> 00:06:45,150
I can come down here and I can use the identical code.
我可以下来这里，我可以使用相同的代码。

119
00:06:45,310 --> 00:06:50,270
The only difference is I'm going to change the word OpenAI to be the word Gemini.
唯一的区别是我要把 OpenAI 这个词改为 Gemini 这个词。

120
00:06:50,550 --> 00:06:52,950
And I'm obviously also going to change the model.
显然我也会改变模型。

121
00:06:52,950 --> 00:06:56,190
If I try and talk to Gemini with GPT five, it'll say what it's not.
如果我尝试用 GPT 5 与 Gemini 交谈，它会说不是什么。

122
00:06:56,190 --> 00:06:57,310
That's not our stuff.
那不是我们的东西。

123
00:06:57,310 --> 00:07:01,790
So we have to make this something like Gemini 2.5 Pro.
所以我们必须把它做得像 Gemini 2.5 Pro 那样。

124
00:07:01,870 --> 00:07:05,310
We'll get a fun fact from the top range model.
我们将从顶级型号中得到一个有趣的事实。

125
00:07:05,630 --> 00:07:06,470
Let's check.
让我们检查一下。

126
00:07:06,470 --> 00:07:07,070
This looks right.
这看起来是对的。

127
00:07:07,070 --> 00:07:07,470
It does.
确实如此。

128
00:07:07,470 --> 00:07:08,670
Let's give this a whirl.
让我们尝试一下。

129
00:07:08,990 --> 00:07:12,470
So we are now asking Google's strongest model on the planet.
所以我们现在正在询问谷歌地球上最强大的模型。

130
00:07:12,470 --> 00:07:18,390
As of now, you might be a Gemini three user, in which case you will have great fun getting a hopefully
截至目前，您可能是 Gemini 3 用户，在这种情况下，您将获得一个充满希望的乐趣

131
00:07:18,390 --> 00:07:20,670
a more profound fun fact than my one.
这是比我的更深刻有趣的事实。

132
00:07:21,150 --> 00:07:27,430
Uh, and here is the answer a group of flamingos is called a flamboyance.
呃，这就是答案，一群火烈鸟被称为“华丽”。

133
00:07:27,670 --> 00:07:29,190
Uh, there you go.
呃，就这样吧。

134
00:07:29,510 --> 00:07:32,190
Uh, if you knew that, then you're obviously very good at trivia.
呃，如果你知道这一点，那么你显然很擅长琐事。

135
00:07:32,390 --> 00:07:40,790
Um, but there is the short, uh, and punchy fun fact from Google's Gemini 2.5 Pro, and I hope you
嗯，但是 Google 的 Gemini 2.5 Pro 有一个简短、呃、有力的有趣事实，我希望你

136
00:07:40,790 --> 00:07:41,510
enjoyed it.
很享受。
