连接器指南阅读约 3 分钟13 个 MCP 工具7 种语言

Gemini API 接入 MCP:从任意 AI 代理使用 Google Gemini

让你的 AI 用你自己的 API 密钥使用 Google Gemini:向 Gemini 模型提问,通过链接分析图片和 PDF,统计 token,创建嵌入向量,并用 Nano Banana 生成或编辑图片,图片直接显示在聊天中。

HC作者:HelpCode 团队更新于 3 分钟阅读 在 GitHub 开源

无需信用卡 · 7 天试用 · 提供自托管方案

Google Gemini API

Google Gemini API

Let your AI use Google Gemini with your own API key: ask Gemini models questions, analyse images and PDFs from a link, count tokens, create embeddings, and generate or edit pictures with Nano Banana that appear right in the chat.

个工具

13

区域

INTL

类别

公共数据

身份验证

API Key

所需环境变量

GEMINI_API_KEY
在 Cloud 上一键安装

7 天免费试用 · 无需信用卡

  • 7 天免费试用
    无需信用卡
  • 符合 GDPR,SOC 2 就绪
    数据驻留欧盟,审计日志
  • 在 GitHub 开源
    开源 · AGPL-3.0
  • 支持 ChatGPT、Claude、Gemini
    任何兼容 MCP 的客户端

跳过安装。2 分钟内即可运行。

在 cloud.anythingmcp.com 开始免费试用,一键添加 Google Gemini API,然后将你的 AI 客户端(Claude、ChatGPT、Copilot 或 Cursor)指向生成的 MCP 端点。无需 Docker,无需 git clone,无需任何工程经验。

开始免费试用

摘要

让你的 AI 用你自己的 API 密钥使用 Google Gemini:向 Gemini 模型提问,通过链接分析图片和 PDF,统计 token,创建嵌入向量,并用 Nano Banana 生成或编辑图片,图片直接显示在聊天中。

试试这样问

Google Gemini API 的示例提示

点击任意提示即可复制,然后粘贴到 Claude、ChatGPT、Cursor、Gemini、Copilot 或 OpenClaw 中,在该连接器上运行。

Google Gemini API · 通过 MCP 实时
分享
Opus 4.7

Claude 是 AI,可能会出错。请核对回答。

💡 无需安装? 直接使用 cloud.anythingmcp.com。 登录、点击 Connectors → Google Gemini API、粘贴凭证、生成 MCP API key,即可完成。无 Docker、无 git clone、无本地服务器。

Gemini API

让你的 AI 用你自己的 API 密钥使用 Google Gemini:向 Gemini 模型提问,通过链接分析图片和 PDF,统计 token,创建嵌入向量,并用 Nano Banana 生成或编辑图片,图片直接显示在聊天中。

设置

  1. 打开 Google AI Studio(https://aistudio.google.com/apikey),用你的 Google 账号登录。
  2. 点击 Create API key,选择或新建一个 Google Cloud 项目,然后复制密钥。密钥通常以 AIza 开头。
  3. 把它粘贴到 GEMINI_API_KEY,然后安装连接器。密钥只会发送给 Google。
  4. 如需生成图片或更高的限额,请在 AI Studio 中为该密钥所在的项目启用结算(Get API key,然后 Set up billing)。图片模型没有免费层级。
  5. 运行 gemini_list_models,查看你的密钥可以使用哪些模型。这不产生费用。

计费:Gemini API 使用你自己的密钥。除模型列表、Files API 和 token 统计外,每次调用都会计入该密钥所在项目的费用,或占用其免费层级额度。在免费层级中,文本模型和嵌入模型在每分钟和每天的限额内免费使用,Google 可能会用免费层级的提示词来改进其产品。除非你要求更强的模型,AI 会使用便宜、快速的默认模型(文本用 gemini-3.1-flash-lite,嵌入用 gemini-embedding-001),发送长提示词之前可以用 gemini_count_tokens 免费估算。

图片需要付费:gemini_generate_image 和 gemini_edit_image 用 Nano Banana 生成或修改图片,并直接显示在聊天中。默认图片模型每张约 0.034 美元,最强的模型每张约 0.13 美元,因此 AI 每次生成图片前都会先与你确认。超过 4 MB 的图片不会返回,请要求更小的尺寸。

通过链接提供文件:gemini_analyze_file_url 可以回答关于图片、PDF、文本或 CSV 文件以及短视频的问题,文件通过公开的 HTTPS 链接提供,最大 15 MB。Gemini 会自己打开链接,所以链接必须无需登录即可访问。Files API 工具可以列出和读取项目中保存的文件,这些文件 48 小时后过期。gemini_delete_file 在安装时处于关闭状态。

常见错误:提示密钥无效的 400:密钥错误或已被删除,请在 AI Studio 中新建一个。403:密钥被限制为只能调用其他 API(在 Google Cloud console 的 Credentials、API restrictions 中允许 Generative Language API),项目中未启用该 API,或文件链接不是公开的。404:该模型代码不存在,请用 gemini_list_models 核对。429:达到了免费层级或付费层级的限额,或在未启用结算的情况下调用了图片模型;请等待,或启用结算。提示免费层级不可用的 400 表示你所在地区不提供免费层级:请启用结算。被 Google 安全过滤器拦截的请求会以错误返回,且不会重试。

此连接器不上传文件,不进行音频或视频流式传输(Live API),不生成语音或视频(Veo),也不支持上下文缓存、批处理任务、调优模型或文件搜索存储。

前提条件: GEMINI_API_KEY

本地安装连接器

curl -fsSL https://raw.githubusercontent.com/HelpCode-ai/anythingmcp/main/docker-compose.quickstart.yml -o docker-compose.yml
printf 'JWT_SECRET=%s\nENCRYPTION_KEY=%s\n' "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" > .env
docker compose up -d

打开 http://localhost:3000/connectors/store,选择 Google Gemini API 并填入前提条件中列出的环境变量。

可用工具

ToolWhat it does
gemini_list_modelsList the Gemini models this API key can use, with their input and output token limits, whether they think, and the methods they support…
gemini_get_modelRead one Gemini model: display name, description, version, input and output token limits, default temperature, top-p and top-k, whether it…
gemini_generate_textAsk a Gemini model one question and get its text answer (generateContent)
gemini_generate_contentFull generateContent call for conversations and mixed input. contents is the list of turns: [{"role": "user", "parts": [{"text": "..."}]}…
gemini_analyze_file_urlAsk a Gemini model about a file on the web: an image, a PDF, a text or CSV file or a short video, given by its public HTTPS link (up to 15…
gemini_count_tokensCount how many input tokens a text is for a Gemini model, to estimate cost or check it fits the context window before a long call
gemini_embed_textTurn one text into an embedding vector (embedContent) for semantic search, clustering or similarity
gemini_batch_embed_textsEmbed up to 20 texts in one call (batchEmbedContents); the vectors come back in the order given
gemini_generate_imageCreate a picture from a text description with a Gemini image model (Nano Banana) and return it as an image the user can see
gemini_edit_imageChange an existing picture with a Gemini image model: describe the edit ("replace the sky with a sunset", "remove the person on the left"…
gemini_list_filesList the files stored in the project's Gemini Files API (uploaded for prompts, or generated), newest first, with name, display name, MIME…
gemini_get_fileRead one file of the Gemini Files API: display name, MIME type, size, state (PROCESSING, ACTIVE or FAILED), uri to use in…
gemini_delete_fileDelete a file from the Gemini Files API before it expires

示例提示

  • “读取我在下面贴出的链接中的供应商价目表 PDF,列出每个产品及其价格。”
  • “让 Gemini 把这段商品描述改写得更简短、更亲切,用于我们的网店。”
  • “这份方案在 Gemini 中有多少 token,用默认模型总结它要花多少钱?”
  • “用 Nano Banana 生成一张我们的蓝色陶瓷马克杯放在木桌上的产品照片,但先告诉我费用,等我确认后再生成。”

下一步

这份指南对你有帮助吗?

你的 Google Gemini API 智能体只差一次点击。

安装连接器,粘贴密钥,向你的 AI 客户端提问。免费试用 7 天,无需信用卡。

相关指南

连接器

如何通过 MCP 将 Gemini API 连接到 ChatGPT

让你的 AI 用你自己的 API 密钥使用 Google Gemini:向 Gemini 模型提问,通过链接分析图片和 PDF,统计 token,创建嵌入向量,并用 Nano Banana 生成或编辑图片,图片直接显示在聊天中。

连接器

如何通过 MCP 将 Gemini API 连接到 Claude

让你的 AI 用你自己的 API 密钥使用 Google Gemini:向 Gemini 模型提问,通过链接分析图片和 PDF,统计 token,创建嵌入向量,并用 Nano Banana 生成或编辑图片,图片直接显示在聊天中。

连接器

如何通过 MCP 将 Gemini API 连接到 Cursor

让你的 AI 用你自己的 API 密钥使用 Google Gemini:向 Gemini 模型提问,通过链接分析图片和 PDF,统计 token,创建嵌入向量,并用 Nano Banana 生成或编辑图片,图片直接显示在聊天中。

连接器

如何通过 MCP 在 Gemini CLI 中使用 Gemini API

让你的 AI 用你自己的 API 密钥使用 Google Gemini:向 Gemini 模型提问,通过链接分析图片和 PDF,统计 token,创建嵌入向量,并用 Nano Banana 生成或编辑图片,图片直接显示在聊天中。

连接器

如何通过 MCP 将 Gemini API 连接到 Meta Muse

让你的 AI 用你自己的 API 密钥使用 Google Gemini:向 Gemini 模型提问,通过链接分析图片和 PDF,统计 token,创建嵌入向量,并用 Nano Banana 生成或编辑图片,图片直接显示在聊天中。

连接器

Avito 接入 MCP:在任意 AI 智能体中管理 Avito 广告、价格和数据

让你的 AI 使用你的 Avito 企业账户:列出广告并修改价格,读取浏览、联系和来电统计,检查自动上传 (autoload) 的上传记录及其错误、Feed 格式和钱包,并读取 Avito Messenger 聊天。发送消息和修改自动上传设置为可选功能,默认关闭。