Skip to content

使用 AI 工具 Gemini

插件名称:Gemini Code Assist

查看用量明细:https://aistudio.google.com/usage?timeRange=this-month

创建项目并生成密钥:https://aistudio.google.com/projects

总结: 注册 google 账号,然后用 google 账号登录 Gemini Code Assist。 向个人社区版用户限制每日请求:250次/天。分钟请求:10次/分钟。

插件版的流需要走系统代理。

  • 可以配置系统代理。
  • 也可以配置 IDEA 代理:
    • 设置路径:Settings -> Appearance & Behavior -> System Settings -> HTTP Proxy。
    • IDEA 配置代理后,所有的 IDEA 插件都会走代理流量,这点在国内使用就很不友好。

Intellij IDEA

插件ID:com.google.tools.ij.aiplugin

插件市场搜索名称即可。

Visual Studio Code

插件ID:google.geminicodeassist

插件市场搜索名称即可。

Github Actions

可以在 Github Actions 中使用,需要配置密钥。

获取 Gemini API 密钥

去 Google AI Studio 创建项目,点 “Get API key”,创建后复制字符串。

https://aistudio.google.com/projects

在仓库中添加 Secret

路径:Settings → Secrets and variables → Actions → New repository secret

Name: GEMINI_API_KEY

Value: 粘贴刚才复制的 API 密钥

添加 Github Actions

然后就可以在仓库中添加 Github Actions,使用 GEMINI_API_KEY 变量来引用密钥了。

由于免费,所有非常适合用来作为在开源项目中使用 Github Actions 来实现当用户提出一个 issue后,自动回复使用 AI 分析并回复的功能。

常见问题

"Your current account is not eligible for Gemini Code Assist for individuals..."

这是你的 Google 账号归属地 被判定为了不支持的地区(如中国大陆)。

Google 账号归属地:https://policies.google.com/country-association-form

如果显示的是中国,则无法使用插件。此时可以尝试提交修改到其它国家。

如果无法修改,就只能重新注册一个 Google 账号了。