hongliang (@snowman)记录一下如何使用 Google Vertex AI 的 API 调用 中发帖

由于 Google AI 的 Cloud 赠金只能用在 Vertex AI 上,Vertex AI 的调用又特别麻烦。特此记录下调用过程。 

在 Benefits 页面领取赠金

如果之前没有创建 Google Cloud 项目,需要先创建一个 Google Cloud 项目,并且将你的赠金绑定到这个 Google Cloud 项目下


去 Google Agent Platform,申请一个类型为 Agent Platform 的 API Key

不要申请类型为 Gemini API 的 API Key,这个类型的 Key 不走赠金
P.S. 这个平台以前叫 Google Vertex AI


使用 google-genai 包来进行 API 调用

使用 OpenAI 格式的调用需要使用凭据,有点麻烦,不太推荐



from google import genai

API_...