如果您在 Google Cloud 上构建 AI 代理或开发者工具,请停止依赖脆弱的网页抓取或与过时的 LLM 训练截止时间作斗争。
使用 Google Developer Knowledge API 生态系统(包括我们的 gcloud CLI 界面、官方代理技能、API Explorer 和多语言客户端库)来更快、更智能、更自信地进行构建。无论您是在命令行终端中操作、向 AI 代理发出提示、交互式测试请求,还是编写生产软件,我们的工具都能提供 Google 文档。
什么是 Developer Knowledge API?
Developer Knowledge API 是 Google 针对 Google Cloud、Firebase、Android 等开发者文档的官方程序化事实来源。它专为现代 AI 代理、IDE 扩展和自动化工作流而设计,用提供新鲜 Markdown 格式文档的结构化 API 取代了脆弱的网页抓取。
通过提供语义和关键词搜索、智能文档分块以及基于事实的问答能力,该 API 确保您的代理和开发者工具保持准确且节省 Token。
Developer Knowledge API 会频繁索引,以确保可预测的检索、最新的文档以及上游更新与代理访问之间的最小延迟。
借助 Developer Knowledge API 接口,开发者和 AI 代理可以在终端、IDE 和后端代码库中查找、检索并综合基于官方 Google 文档的答案。
gcloud CLI
Developer Knowledge API 的 gcloud CLI 界面将官方文档搜索、检索和基于事实的问答集成到您的命令行环境中。它预装在 Cloud Shell 中,并在 Linux、macOS 和 Windows 上的标准 Google Cloud SDK 安装中工作,无需额外的插件或配置。
关键功能和命令:
answer-query :在终端中获取基于事实的答案。
documents search-chunks :在 Google 文档中搜索文档片段和分块。
documents describe :检索特定文档的元数据和内容。
示例:
gcloud developer-knowledge answer-query --query="How do I create a BigQuery dataset?"
gcloud developer-knowledge documents search-chunks --query="Firestore transactions"
gcloud developer-knowledge documents describe "documents/docs.cloud.google.com/storage/docs/creating-buckets"
gcloud developer-knowledge answer-query --query="$(cat error.txt)"
Shell
要开始使用 gcloud CLI,请参阅 gcloud CLI 快速入门 。
代理技能
Developer Knowledge 代理技能建立了 AI 编码助手与 Google 文档生态系统之间的链接,使自主工具能够访问最新的技术规范。
关键优势
基于事实 & 减少幻觉:为 AI 编码助手和代理工作流提供对最新 Google 开发者文档的访问权限,从而减少因过时的 LLM 训练截止时间而产生的幻觉。
优化的 Token 和上下文使用:使用多步检索工作流——首先使用 searchDocumentChunks 检查代码和文档分块,然后使用 documents.get 获取完整的 Markdown 页面,或使用 answerQuery 提供基于事实的答案。
广泛的工具兼容性:在 Google Antigravity、Claude Code、Cursor、GitHub Copilot 和自定义代理框架中广泛使用标准 MCP 集成。该技能指导您的助手如何使用 Developer Knowledge MCP 服务器(或通过 curl 回退到 REST API)。
配置代理技能
通过在终端中运行以下 CLI 辅助命令来配置该技能:
npx skills add google/skills --skill retrieving-developer-knowledge
Shell
此命令会在您的项目中安装 Developer Knowledge 智能体技能。该技能会指导您的助手如何使用 Developer Knowledge MCP 服务器(或在无法使用时回退至使用 curl 的 REST API)。
要在 IDE 中连接到 MCP 服务器,或配置使用 Application Default Credentials 或 API 密钥的身份验证,请参阅“连接到 Developer Knowledge MCP 服务器”。
客户端库
客户端库使您能够将文档检索、搜索和基于事实的答案生成嵌入到生产系统、自动化 CI/CD 流水线以及企业知识库机器人中。
主要优势:
编程访问权限:提供对 AnswerQuery、SearchDocumentChunks、GetDocument 和 BatchGetDocuments 的编程访问权限。
惯用集成:为每种支持的语言生态系统量身定制的原生类型定义、构建器模式、错误处理和异步执行机制。
批处理与效率:BatchGetDocuments 等方法允许在单次 API 调用中检索多达 20 份文档。
企业级安全与可靠性:支持 Google Cloud Application Default Credentials、自动重试以及结构化引用追踪。
支持的语言:
通过遵循快速入门指南来设置环境、安装库并开始检索开发者文档,即可开始使用。
代码示例:
以下示例演示了 AI 智能体如何使用 Python 客户端库获取最新的产品发行说明,确保其回答基于超出模型训练截止日期的数据:
from google.cloud import developer_knowledge_v1
def FetchMyProductReleaseNotes(my_product_name: str) -> str:
"""获取最新的发行说明,以弥补模型知识截止日期的不足。"""
my_api_client = developer_knowledge_v1.DeveloperKnowledgeClient()
my_search_query = f"{my_product_name} latest release notes"
my_request = developer_knowledge_v1.SearchDocumentChunksRequest(
query=my_search_query,
)
my_response = my_api_client.search_document_chunks(request=my_request)
my_release_notes = [my_chunk.text for my_chunk in my_response.chunks]
return "\n".join(my_release_notes)
Python
各种任务的代码示例:
APIs Explorer
Developer Knowledge API 的 Google APIs Explorer 提供了一个集成在 Google 开发者网站中的交互式、零代码界面,使您能够实验和验证 API 请求及响应结构。
通过 APIs Explorer,您可以测试以下核心端点:
后续步骤
准备将 Google 开发者文档集成到您的工作流和 AI 工具中吗?以下是几种开始使用的方法:
如果您已经拥有 gcloud CLI:您可以立即使用 gcloud CLI 界面查询官方文档。
如果您没有 gcloud CLI:请将智能体技能赋予您的 AI 编码助手或智能体,以启用基于事实的检索功能。
If you build AI agents or developer tools on Google Cloud, stop relying on brittle web-scraping or wrestling with stale LLM training cutoffs.
Build faster, smarter, and with greater confidence using the Google Developer Knowledge API ecosystem, including our gcloud CLI surface, an official agent skill, API Explorer, and multi-language client libraries. Whether you are operating in a command-line terminal, prompting an AI agent, testing requests interactively, or writing production software, our tools deliver Google documentation.
What is the Developer Knowledge API?
The Developer Knowledge API is Google's official, programmatic source of truth for developer documentation about Google Cloud, Firebase, Android, and more. Designed specifically for modern AI agents, IDE extensions, and automated workflows, it replaces brittle web-scraping with a structured API that serves fresh, Markdown-formatted documentation.
By offering semantic and keyword search, intelligent document chunking, and grounded Q&A capabilities, the API ensures your agents and developer tools remain accurate and token-efficient.
The Developer Knowledge API is indexed frequently to ensure predictable retrieval, fresh documentation, and minimal lag between upstream updates and agent access.
With the Developer Knowledge API interfaces, developers and AI agents can discover, retrieve, and synthesize answers grounded in official Google documentation across terminals, IDEs, and backend codebases.
gcloud CLI
The Developer Knowledge API gcloud CLI surface integrates official documentation search, retrieval, and grounded Q&A into your command-line environment. It comes pre-installed in Cloud Shell and works across standard Google Cloud SDK installations on Linux, macOS, and Windows without requiring extra plugins or configuration.
Key capabilities and commands:
answer-query : Get grounded answers in your terminal.
documents search-chunks : Search document snippets and chunks across Google documentation.
documents describe : Retrieve metadata and content for a specific document.
Examples:
gcloud developer-knowledge answer-query --query="How do I create a BigQuery dataset?"
gcloud developer-knowledge documents search-chunks --query="Firestore transactions"
gcloud developer-knowledge documents describe "documents/docs.cloud.google.com/storage/docs/creating-buckets"
gcloud developer-knowledge answer-query --query="$(cat error.txt)"
Shell
To get started with the gcloud CLI, see the gcloud CLI Quickstart .
Agent skill
The Developer Knowledge agent skill establishes a link between AI coding assistants and Google's documentation ecosystem, enabling autonomous tools to access up-to-date technical specifications.
Key Benefits
Grounding & reduced hallucinations: Provides AI coding assistants and agentic workflows access to up-to-date Google developer documentation, reducing hallucinations from stale LLM training cutoffs.
Optimized token & context usage: Uses a multi-step retrieval workflow—inspecting code and documentation chunks using searchDocumentChunks first before fetching complete Markdown pages with documents.get , or delivering grounded answers using answerQuery .
Broad tooling compatibility: Uses the standard MCP integration across Google Antigravity, Claude Code, Cursor, GitHub Copilot, and custom agentic frameworks. The skill instructs your assistant how to use the Developer Knowledge MCP server (or fall back to the REST API via curl ).
Configure the agent skill
Configure the skill by running the following CLI helper command in your terminal:
npx skills add google/skills --skill retrieving-developer-knowledge
Shell
This command installs the Developer Knowledge agent skill in your project. The skill instructs your assistant how to use the Developer Knowledge MCP server (or fall back to the REST API using curl).
To connect to the MCP server in your IDE, or to configure authentication with Application Default Credentials or an API key , see Connect to the Developer Knowledge MCP server .
Client libraries
The client libraries let you embed documentation retrieval, search, and grounded answer generation into production systems, automated CI/CD pipelines, and enterprise knowledge bots.
Key benefits:
Programmatic access: Provides programmatic access to AnswerQuery , SearchDocumentChunks , GetDocument , and BatchGetDocuments .
Idiomatic integration: Native type definitions, builder patterns, error handling, and asynchronous execution tailored to each supported language ecosystem.
Batching and efficiency: Methods like BatchGetDocuments enable retrieving up to 20 documents in a single API call.
Enterprise security and reliability: Support for Google Cloud Application Default Credentials, automatic retries, and structured citation tracking.
Supported languages:
Get started by following the Quickstart to set up your environment, install a library, and start retrieving developer documentation.
Code examples:
The following example demonstrates how an AI agent can use the Python client library to fetch the latest product release notes, ensuring its responses are grounded in data beyond its training cutoff:
from google.cloud import developer_knowledge_v1
def FetchMyProductReleaseNotes(my_product_name: str) -> str:
"""Fetches the latest release notes to bridge a model's knowledge cutoff."""
my_api_client = developer_knowledge_v1.DeveloperKnowledgeClient()
my_search_query = f"{my_product_name} latest release notes"
my_request = developer_knowledge_v1.SearchDocumentChunksRequest(
query=my_search_query,
)
my_response = my_api_client.search_document_chunks(request=my_request)
my_release_notes = [my_chunk.text for my_chunk in my_response.chunks]
return "\n".join(my_release_notes)
Python
Code examples across various tasks:
APIs Explorer
The Google APIs Explorer for the Developer Knowledge API offers an interactive, zero-code interface integrated into Google's developer site, enabling experimentation and verification of API requests and response structures.
Through the APIs Explorer, you can test the following core endpoints:
Next steps
Ready to integrate Google developer documentation into your workflows and AI tools? Here are a few ways to get started:
If you already have the gcloud CLI: You can start querying official documentation right away using the gcloud CLI surface .
If you don't have the gcloud CLI: Give the agent skill to your AI coding assistant or agent to enable grounded retrieval.
| 刊期 | 得分 | 排名 | 结果 |
|---|---|---|---|
| 2026-10-09 | 8.4 | 43 | 入选 |
| 2026-10-08 | 8.4 | 46 | 未入选 |