摘要
让你的 AI 用你自己的 xAI API 密钥向 Grok 提问:Grok 模型的回答、基于网络或 X 实时搜索并附来源的回答、在后台生成的长回答,以及直接在聊天中用 Grok Imagine 生成或编辑的图片。
引导式设置
2 分钟将 xAI Grok 连接到 Microsoft Copilot
开始 AnythingMCP Cloud 免费试用,在引导式设置中连接 xAI Grok,再把你的 MCP URL 添加到 Microsoft Copilot。无需代码,也无需自行运行服务器。
无需信用卡 · 7 天试用 · 提供自托管方案
试试这样问
xAI Grok 的示例提示
点击任意提示即可复制,然后粘贴到 Claude、ChatGPT、Cursor、Gemini、Copilot 或 OpenClaw 中,在该连接器上运行。
Claude 是 AI,可能会出错。请核对回答。
💡 无需安装? 直接使用 cloud.anythingmcp.com。 登录、点击 Connectors → xAI Grok、粘贴凭证、生成 MCP API key,即可完成。无 Docker、无
git clone、无本地服务器。
xAI Grok + Microsoft Copilot
让你的 AI 用你自己的 xAI API 密钥向 Grok 提问:Grok 模型的回答、基于网络或 X 实时搜索并附来源的回答、在后台生成的长回答,以及直接在聊天中用 Grok Imagine 生成或编辑的图片。
前提条件
完整的设置说明已内置在连接器中 (在 store 中选择连接器时可见)。所需环境变量:
XAI_API_KEY
步骤 1 — 获取凭证
- 登录
https://console.x.ai,在 Billing 中购买预付额度。Grok API 与 X Premium 或 SuperGrok 订阅相互独立,这些订阅不包含 API 使用;额度用完后请求会被拒绝。 - 打开 API Keys,创建一个密钥并复制(以
xai-开头)。 - 按 xAI 显示的原样将其粘贴到
XAI_API_KEY,不要加 Bearer 一词,然后安装连接器。密钥只会发送给 xAI。 - 先运行
xai_get_api_key_info:它不收费,并能显示密钥的名称、团队和权限。
计费使用你自己的 xAI 额度:每次调用 Grok 都会消耗你的预付额度。模型列表、密钥详情、token 计数和获取结果都是免费的。除非你要求更多,连接器默认使用低成本设置:文本用 grok-4.3(每百万输入 token 约 1.25 美元,每百万输出 token 约 2.50 美元,上下文 100 万 token),图片用 grok-imagine-image(每张约 0.02 美元)。旗舰模型是 grok-4.7(2 美元和 6 美元),grok-imagine-image-2.0 生成质量更高的图片(约 0.04 美元)。每个回答都会显示其费用。
功能:
xai_create_response通过 xAI 推荐的 Responses API 向 Grok 提问,支持通过链接输入图片、指令、推理强度和 JSON 输出。只有在你要求时才会保存回答;已保存的回答可以用xai_get_response读取并继续。- 借助
xai_web_search和xai_x_search,Grok 会自己搜索网络或 X 上的帖子,并附上来源回答。网络搜索可以限定在某些域名,X 搜索可以限定在某些账号和日期范围。搜索在 token 之外另行计费(网络约每 1,000 次搜索 5 美元;X 约每 1,000 条帖子 5 美元、每 1,000 个用户资料 10 美元),因此 AI 只在问题需要最新信息时才使用。 xai_start_deferred_completion和xai_get_deferred_completion在后台处理长回答。AI 每 10 到 30 秒查看一次,结果可在 24 小时内获取一次。xai_generate_image和xai_edit_image用 Grok Imagine 生成或修改图片,并直接显示在聊天中。编辑时,原图通过公开链接传入。xai_tokenize_text免费计算 token 数,xai_list_language_models、xai_list_image_models和xai_list_models显示你的密钥可以使用的模型及价格。
先确认:每张图片都要花钱,因此 AI 在每次调用 xai_generate_image 或 xai_edit_image 之前都会先征得你的确认,并且除非你要更多,只生成一张。xai_delete_response 在安装时处于关闭状态;启用后它同样会先确认,且删除的回答无法恢复。
时间限制:通过连接器的调用会在 30 秒后中断。快速回答请保持较低的推理强度,较长的回答交给后台工具。超过 4 MB 的图片不会在聊天中显示,所以请保持 1k 分辨率。
不可信内容:搜索结果、帖子和回答来自开放网络和 X。AI 会把其中的指令当作数据,而不是命令。
常见错误:400 Incorrect API key provided 表示密钥错误:xAI 对无效密钥返回 400 而不是 401,请从控制台重新复制。401 No credentials presented:缺少密钥。403:团队额度已用完,或密钥没有访问此端点或模型的权限(xai_get_api_key_info 会列出其权限);请在 Billing 中充值。404:模型不存在或你的团队无权访问,请查看 xai_list_language_models。422:某个字段格式不对,消息会指出是哪一个。429:速率限制;请稍候并重试一次。
该连接器不支持流式回答,不用 Chat Completions 生成普通回答(由 Responses API 负责),也不支持视频生成、语音、文件、collections、批处理任务以及兼容 Anthropic 的端点。
步骤 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 窗格中试一试:提出需要用到
xAI Grok的工具的请求。 - 选择 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 |
|---|---|
xai_list_language_models | List the Grok language models the API key can use, with id, aliases, input and output modalities, and prices |
xai_list_models | List every model id the xAI API key can use (language, image and video models) with owner and creation time |
xai_list_image_models | List the Grok Imagine image models the key can use, with id, aliases, maximum prompt length and price per image (pricing lists… |
xai_create_response | Ask Grok and get its answer through xAI's Responses API, the API xAI recommends |
xai_web_search | Ask Grok a question it answers by searching the web itself (Responses API with the web_search server-side tool; the old Live Search… |
xai_x_search | Ask Grok a question it answers by searching posts on X (Responses API with the x_search server-side tool), optionally limited to some… |
xai_get_response | Get a stored xAI response by id (one created with store true), with output_text, citations, status and usage |
xai_delete_response | Delete a stored xAI response, so it can no longer be read or continued |
xai_start_deferred_completion | Start a long Grok answer in the background (deferred chat completion) and get a request_id at once, for questions that may take longer than… |
xai_get_deferred_completion | Fetch the result of a deferred Grok answer started with xai_start_deferred_completion |
xai_generate_image | Create pictures from a text description with Grok Imagine and return them as images the user can see |
xai_edit_image | Change a picture with Grok Imagine from a text instruction (e.g. 'make the sky stormy', 'remove the car') and return the result as an image… |
xai_tokenize_text | Count the tokens a text uses with a Grok model's tokenizer, and list them, e.g. to estimate the cost of a long prompt |
xai_get_api_key_info | Get the details of the xAI API key in use: redacted key, name, team id, permissions (acls) and whether the key or the team is blocked or… |
示例提示
- “让 Grok 在 X 上搜索本周大家对我们产品发布的评价,并列出它用到的帖子。”
- “用 Grok 的网络搜索查找 Node.js 最新的发布说明,并附上来源做个总结。”
- “用 Grok Imagine 为我们的电子报生成一张温馨阅读角的图片,但先和我确认费用。”
- “这份合同文本用 Grok 的分词器有多少个 token?用 grok-4.3 做摘要大概要花多少钱?”
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" 即可使用新版本。
下一步
这份指南对你有帮助吗?