调用Google gemini api 报错且最终没有解决hhh

错误如下:DefaultCredentialsError: Your default credentials were not found. To set up Application Default Credentials, see https://cloud.google.com/docs/authentication/external/set-up-adc for more information.
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings…
解决方法:点击链接,根据要求安装 gcloud CLI
在这里插入图片描述
运行gcloud auth application-default login
中间报错,”因为在此系统上禁止运行脚本“,使用命令set-ExecutionPolicy RemoteSigned
在这里插入图片描述

在这里插入图片描述
哈哈结果还是报错
继续看文档,使用在这里插入图片描述
gcloud auth application-default login --impersonate-service-account SERVICE_ACCT_EMAIL
在这里插入图片描述
创建json文件
哈哈新错误
Deadline of 60.0s exceeded while calling target function, last exception: 503 failed to connect to all addresses;
解决方法
genai.configure(api_key= f"{GOOGLE_API_KEY}", transport=“rest”)github给出得方法
在这里插入图片描述
??就这样吧


使用魔法后的新错误
(‘Unable to acquire impersonated credentials’, ‘{\n “error”: {\n “code”: 400,\n “message”: “Invalid form of account ID SERVICE_ACCT_EMAIL. Should be [Gaia ID |Email |Unique ID |] of the account”,\n “status”: “INVALID_ARGUMENT”\n }\n}\n’)

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Google GeminiGoogle推出的一种广告平台,旨在帮助广告主在移动设备上展示广告。它提供了一种全新的广告投放方式,可以根据用户的兴趣和行为定位广告,从而提供更加精准的广告投放效果。 Gemini广告平台的特点包括: 1. 移动优先:Gemini广告平台专注于移动设备上的广告投放,可以帮助广告主更好地触达移动用户。 2. 定位广告:Gemini广告平台可以根据用户的兴趣和行为定位广告,从而提供更加精准的广告投放效果。 3. 多种广告格式:Gemini广告平台支持多种广告格式,包括图片广告、视频广告和原生广告等。 4. 数据驱动:Gemini广告平台通过分析用户的数据,可以提供更加精准的广告投放策略,从而提高广告的转化率和效果。 以下是一个使用Gemini广告平台的示例代码: ```python import googleads # 创建一个广告客户端 client = googleads.AdWordsClient.LoadFromStorage() # 创建一个广告组 ad_group = { 'name': 'Gemini Ad Group', 'status': 'ENABLED', 'campaignId': 'INSERT_CAMPAIGN_ID_HERE', 'biddingStrategyConfiguration': { 'biddingStrategyType': 'MANUAL_CPC', }, } # 创建一个广告 ad = { 'headline': 'Gemini Ad', 'description': 'This is a Gemini ad.', 'finalUrls': ['http://www.example.com'], } # 将广告添加到广告组中 ad_group_service = client.GetService('AdGroupService') ad_group_operations = [{ 'operator': 'ADD', 'operand': ad_group, }] ad_group_service.mutate(ad_group_operations) # 将广告添加到广告组中 ad_service = client.GetService('AdService') ad_operations = [{ 'operator': 'ADD', 'operand': ad, }] ad_service.mutate(ad_operations) ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值