摘要
让你的 AI 用你自己的 API 密钥使用 Google Gemini:向 Gemini 模型提问,通过链接分析图片和 PDF,统计 token,创建嵌入向量,并用 Nano Banana 生成或编辑图片,图片直接显示在聊天中。
引导式设置
2 分钟将 Google Gemini API 连接到 Microsoft Copilot
开始 AnythingMCP Cloud 免费试用,在引导式设置中连接 Google Gemini API,再把你的 MCP URL 添加到 Microsoft Copilot。无需代码,也无需自行运行服务器。
无需信用卡 · 7 天试用 · 提供自托管方案
试试这样问
Google Gemini API 的示例提示
点击任意提示即可复制,然后粘贴到 Claude、ChatGPT、Cursor、Gemini、Copilot 或 OpenClaw 中,在该连接器上运行。
Claude 是 AI,可能会出错。请核对回答。
💡 无需安装? 直接使用 cloud.anythingmcp.com。 登录、点击 Connectors → Google Gemini API、粘贴凭证、生成 MCP API key,即可完成。无 Docker、无
git clone、无本地服务器。
Gemini API + Microsoft Copilot
让你的 AI 用你自己的 API 密钥使用 Google Gemini:向 Gemini 模型提问,通过链接分析图片和 PDF,统计 token,创建嵌入向量,并用 Nano Banana 生成或编辑图片,图片直接显示在聊天中。
前提条件
完整的设置说明已内置在连接器中 (在 store 中选择连接器时可见)。所需环境变量:
GEMINI_API_KEY
步骤 1 — 获取凭证
- 打开 Google AI Studio(
https://aistudio.google.com/apikey),用你的 Google 账号登录。 - 点击 Create API key,选择或新建一个 Google Cloud 项目,然后复制密钥。密钥通常以
AIza开头。 - 把它粘贴到
GEMINI_API_KEY,然后安装连接器。密钥只会发送给 Google。 - 如需生成图片或更高的限额,请在 AI Studio 中为该密钥所在的项目启用结算(Get API key,然后 Set up billing)。图片模型没有免费层级。
- 运行
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),也不支持上下文缓存、批处理任务、调优模型或文件搜索存储。
步骤 2 — 安装 adapter
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
步骤 3 — 在 Microsoft Copilot 中添加连接器
你的服务器 URL: 在 AnythingMCP 中打开 MCP Servers → 此连接器所在的服务器,复制它的 URL(
https://cloud.anythingmcp.com/mcp/…)。本指南中出现YOUR_SERVER_ID的地方都用它替换。
Microsoft Copilot 通过在 Copilot Studio 中构建的智能体使用 MCP 服务器:把 AnythingMCP 作为工具添加到智能体,然后把智能体发布到 Microsoft 365 Copilot 和 Teams。Copilot Studio 从 Microsoft 的云端通过 Streamable HTTP 连接,AnythingMCP 支持这种方式。
- 在 Copilot Studio 中打开你的智能体(或新建一个),进入 Tools,选择 Add a tool → New tool → Model Context Protocol。
- 填写 Server name(例如
AnythingMCP)、说明连接器用途的 Server description,以及 Server URLhttps://cloud.anythingmcp.com/mcp/YOUR_SERVER_ID。Copilot Studio 根据描述决定何时调用该服务器。 - 身份验证选择 API key,把 Type 设为 Header,请求头名称填
X-API-Key,然后选择 Create。 - 在 Add tool 中选择 Create a new connection,粘贴 AnythingMCP 的 MCP API 密钥(MCP Servers → 你的服务器 → API keys),然后选择 Add to agent。
- 在智能体的 Test 窗格中试一试:提出需要用到
Gemini API的工具的请求。 - 选择 Publish,然后进入 Channels → Microsoft 365 and Microsoft Teams,保持勾选 Make agent available in Microsoft Copilot,再选择 Add channel。See agent in Teams 会为你安装该智能体;在 Microsoft 365 Copilot 中输入 @ 并选择该智能体。
希望每个用户各自登录?请选择 OAuth 2.0 → Dynamic discovery 代替 API 密钥:每个用户会在智能体首次调用时登录 AnythingMCP。
自托管?请用你实例的公网 HTTPS 地址替换 https://cloud.anythingmcp.com。Copilot Studio 从 Microsoft 的云端连接,因此 localhost 无法使用。
可用工具
| Tool | What it does |
|---|---|
gemini_list_models | List 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_model | Read one Gemini model: display name, description, version, input and output token limits, default temperature, top-p and top-k, whether it… |
gemini_generate_text | Ask a Gemini model one question and get its text answer (generateContent) |
gemini_generate_content | Full generateContent call for conversations and mixed input. contents is the list of turns: [{"role": "user", "parts": [{"text": "..."}]}… |
gemini_analyze_file_url | Ask 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_tokens | Count 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_text | Turn one text into an embedding vector (embedContent) for semantic search, clustering or similarity |
gemini_batch_embed_texts | Embed up to 20 texts in one call (batchEmbedContents); the vectors come back in the order given |
gemini_generate_image | Create 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_image | Change 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_files | List the files stored in the project's Gemini Files API (uploaded for prompts, or generated), newest first, with name, display name, MIME… |
gemini_get_file | Read one file of the Gemini Files API: display name, MIME type, size, state (PROCESSING, ACTIVE or FAILED), uri to use in… |
gemini_delete_file | Delete a file from the Gemini Files API before it expires |
示例提示
- “读取我在下面贴出的链接中的供应商价目表 PDF,列出每个产品及其价格。”
- “让 Gemini 把这段商品描述改写得更简短、更亲切,用于我们的网店。”
- “这份方案在 Gemini 中有多少 token,用默认模型总结它要花多少钱?”
- “用 Nano Banana 生成一张我们的蓝色陶瓷马克杯放在木桌上的产品照片,但先告诉我费用,等我确认后再生成。”
FAQ
这适用于哪个 Copilot? 适用于工作中的 Microsoft 365 Copilot,通过 Copilot Studio 的智能体实现。面向个人账户的 Microsoft Copilot 应用无法添加自己的 MCP 服务器。
我需要什么? 一个可以使用 Copilot Studio 的工作账户(许可证或试用版),用于构建智能体。在 Microsoft 365 Copilot 或 Teams 中使用它的人需要拥有该智能体的访问权限:把它共享给他们,或请管理员为整个组织发布。如果你的组织对 Power Platform 连接器设置了数据策略,这些策略同样适用于 MCP 服务器。
智能体不调用工具。 检查请求头名称是否正好是 X-API-Key,密钥是否属于与 URL 相同的 MCP 服务器,并把 Server description 写得具体:Copilot Studio 根据它决定何时调用服务器。每次修改后重新发布智能体;在已打开的对话中输入 "start over" 即可使用新版本。
下一步
这份指南对你有帮助吗?