Information
Google's Gemini API is a powerful AI platform designed to enable developers to build advanced AI applications with ease. It offers a suite of tools and models that support multimodal inputs and outputs, making it versatile for a wide range of tasks.
Introduction
Google's Gemini API is a cutting-edge AI platform that allows developers to integrate advanced AI capabilities into their applications. It supports multimodal inputs and outputs, including text, images, and audio, enabling seamless interactions across various media types. The API is designed to be highly scalable and efficient, making it suitable for both small-scale projects and large enterprise applications. With its robust features and ease of use, the Gemini API empowers developers to create innovative AI-driven solutions. Key Features
Multimodal Capabilities
The Gemini API supports text, images, and audio, allowing for rich and diverse interactions. This enables applications to handle complex tasks that require understanding and generating multiple types of data. Scalability and Efficiency
Designed to be highly scalable, the Gemini API can handle large volumes of data and complex computations efficiently, making it suitable for enterprise-level applications. Easy Integration
The API provides comprehensive documentation and SDKs for various programming languages, including Python, Go, and Node.js, making it easy for developers to integrate and start using the API quickly. Use Cases
Customer Support
The Gemini API can be used to build intelligent customer support systems that can handle inquiries, provide accurate responses, and improve overall customer satisfaction. Content Creation
Developers can leverage the API to create applications that generate high-quality text, images, and audio, aiding in content creation for marketing, education, and entertainment. Data Analysis
The API's ability to process and analyze large datasets makes it ideal for applications that require data-driven insights and decision-making, such as financial analysis and market research. By integrating the Gemini API, developers can enhance their applications with advanced AI capabilities, improve user experiences, and drive innovation across various industries. 模型 更多 更多 Gemini API 文档 API 参考文档 SDK 价格 实战宝典 解决方案 解决方案 更多 更多 代码编写协助 代码编写协助 更多 更多 橱窗广告 橱窗广告 更多 更多 社区 社区 更多 更多 概览 开始使用 快速入门 API 密钥 库 安装 Python SDK 升级 价格 速率限制 版本说明 OpenAI 兼容性 开发者论坛 模型 Gemini 实验性模型 功能 文本生成 图片生成 视觉 音频理解 长上下文 代码执行 结构化输出 做思考状 函数调用 函数调用简介 教程:函数调用 提取结构化数据 文档理解 使用 Google 搜索建立依据 接地教程 使用 Google 搜索建议 微调 微调简介 微调教程 Embeddings 指南 Multimodal Live API 上下文缓存 提示工程 提示简介 提示策略 文件提示策略 Imagen 提示指南 令牌计数 账单信息 安全 安全设置 安全指导 其他资源 Android(设备端) Firebase Extensions 生成模型 Google AI Studio 快速入门 LearnLM 迁移到云端 OAuth 身份验证 Gemini for Research Gemini 学术计划 用例 应用 Chat 应用 代码助理 Flutter 代码生成器 内容搜索 数据探索代理 写作助理 幻灯片审核者 问题排查 API 问题排查 AI Studio 问题排查 Google Workspace 法律 服务条款 可用区域 滥用行为监控 Gemini Gemini 简介 文档 API 参考 价格 Gemma Gemma 简介 文档 Gemmaverse 借助 Gemini 构建 借助 Gemini 构建 Gemini API Google AI Studio 自定义 Gemma 开放模型 自定义 Gemma 开放模型 Gemma 开放模型 使用 Keras 实现多框架 在 Colab 中微调 在设备上运行 在设备上运行 Google AI 边缘 Android 版 Gemini Nano Chrome 内置 Web API 以负责任的方式构建 以负责任的方式构建 Responsible GenAI 工具包 安全的 AI 框架 Android Studio Chrome DevTools Colab Firebase Google Cloud JetBrains Jules 项目 IDX VS Code Gemini Showcase Gemini API 开发者竞赛 Google AI 论坛 Gemini for Research 本页内容 本页内容 项目设置 安装必备组件 克隆并配置项目 配置和测试扩展程序 修改现有命令 创建新命令 集成新命令 测试新命令 其他资源 正式版应用 此页面由 Cloud Translation API 翻译。 本页内容 本页内容 项目设置 安装必备组件 克隆并配置项目 配置和测试扩展程序 修改现有命令 创建新命令 集成新命令 测试新命令 其他资源 正式版应用 此示例已更新,可与 Gemini API 搭配使用。 您需要拥有 Google Gemini API 密钥才能运行该项目,该密钥可从 Google Gemini API 设置页面获取。 "google.gemini.apiKey" : "your-api-key-here" :请将 API 密钥视为密码,并妥善保护。请勿将密钥嵌入到公开发布的代码中。 const PROMPT = ' Write review comments for following code , identifying bugs and ways to improve code quality . Examples of bugs are syntax errors or typos , out of memory errors , and boundary value errors . Examples of improving code quality are reducing complexity of code , eliminating duplicate code , and ensuring other developers are able to understand the code . $ { CODE_LABEL } ... ... $ { REVIEW_LABEL } There are duplicate lines of code in this control structure . $ { CODE_LABEL } const fixed_value = 128 ; $ { REVIEW_LABEL } Make sure constant names are in all capitals ( FIXED_VALUE ) for clarity . ' ; // Provide instructions for the AI generative model const PROMPT = `Recommend a name for this function. Explain your reasoning in 3 sentences or less:` ; export async function generateName () { vscode . window . showInformationMessage ( 'Generating function name...' ); // Build the full prompt using the template. const fullPrompt = ` ${ PROMPT } " ${ selectedCode } " ` ; // update prefix to describe output let commentIntro = padding + commentPrefix + "Recommended name: (generated)\n" ; editBuilder . insert ( selection . start , commentIntro ); editBuilder . insert ( selection . start , pyComment ); import { generateName } from './name' ; export function activate ( context : vscode . ExtensionContext ) { ... vscode . commands . registerCommand ( 'pipet-code-agent.nameFunction' , generateName ); } "contributes" : { "commands" : [ ... { "command" : "pipet-code-agent.nameFunction" , "title" : "Pipet: Name the selected function." } ], 编写代码既有成就感又令人满意,但将代码从可用状态改为可向同事展示的状态通常是一项繁琐的工作。人工智能生成式模型可以帮助您添加代码注释、在人工审核员发现错误之前发现错误,以及执行一系列其他任务,从而简化编码工作流。 本教程介绍了如何扩展 Pipet Code Agent,这是一个由 Google AI 开发者关系团队构建的依托 AI 技术的代码辅助工具。此开源项目是 Microsoft Visual Studio Code (VS Code) 的扩展程序,可帮助您处理一些重要但不太有趣的编码任务,例如为代码添加注释、查找错误和提出改进建议。该扩展程序会向 Gemini API 发送编码协助请求,并将回复整合到您的代码编辑窗口中。 您可以修改 Pipet,让这些现有函数更好地为您服务,也可以构建新命令,更好地支持您的开发工作流程。 如需观看有关该项目及其扩展方式的视频概览,包括项目开发者的深入解析,请参阅 AI Code Assistant - Build with Google AI。否则,您可以按照以下说明开始扩展项目。 以下说明会引导您设置 Pipet Code Agent 项目,以便进行开发和测试。一般步骤包括安装一些必需的软件、设置一些环境变量、从代码库克隆项目,以及运行配置安装。 Pipet Code Agent 项目作为 Microsoft Visual Studio Code 的扩展程序运行,并使用 Node.js 和 npm 工具来管理软件包和运行应用。以下安装说明适用于 Linux 主机。 如需安装所需的软件,请执行以下操作: 下载项目代码,然后使用 npm 安装命令下载所需的依赖项并配置项目。您需要 git 源代码控制软件才能检索项目源代码。 如需下载和配置项目代码,请执行以下操作: 现在,您应该能够在设备上的 VS Code 中将 Pipet Code Agent 作为开发扩展程序运行,以测试安装情况。测试会打开一个单独的 VS Code Extension Development Host 窗口,其中包含新扩展程序。在此新窗口中,您可以配置扩展程序用于访问 Google Gemini API 的 API 密钥。 图 1. 显示 Pipet 扩展程序命令的 VS Code 扩展程序开发主机窗口。 如需配置和测试您的设置,请执行以下操作: 如需测试扩展程序命令,请执行以下操作: 修改 Pipet Code Agent 中提供的命令是最简单的更改扩展程序行为和功能的方法。注释和评价命令都采用少量提示方法,其中包含代码示例和相应代码的注释,以及一些针对 AI 生成式模型的一般说明。这些提示上下文信息可指导 Gemini 生成式模型形成回答。通过更改评论或审核命令中的提示说明和/或示例,您可以更改每个现有命令的行为方式。 本组说明介绍了如何通过更改命令的提示文本来修改 review.ts 命令。 如需准备修改 review.ts 命令,请执行以下操作: 如需修改 review.ts 命令的行为,请执行以下操作: 如需测试修改后的命令,请执行以下操作: 您可以通过创建使用 Gemini API 执行全新任务的新命令来扩展 Pipet。每个命令文件(comment.ts 和 review.ts)在很大程度上都是独立的,其中包含用于从当前编辑器收集文本、撰写提示、连接到 Gemini API、发送提示和处理响应的代码。 图 2. VS Code 扩展程序开发主机窗口中新增了函数名称建议命令。 本组说明介绍了如何使用现有命令 comment.ts 的代码作为模板构建新命令。 如需创建用于为函数推荐名称的命令,请执行以下操作: 完成新命令的代码后,您需要将其与扩展程序的其余部分集成。更新 extension.ts 和 package.json 文件,使新命令成为扩展程序的一部分,并让 VS Code 能够调用新命令。 如需将 name 命令与扩展程序代码集成,请执行以下操作: 如需将 name 命令与扩展程序软件包集成,请执行以下操作: 完成命令编码并将其与扩展程序集成后,您就可以对其进行测试了。您的新命令仅适用于 VS Code 的 Extension Development Host 窗口,而不适用于您修改扩展程序代码的 VS Code 窗口。 如需测试修改后的命令,请执行以下操作: 如需详细了解 Pipet Code Agent 项目,请参阅代码库。如果您在构建应用时需要帮助,或者正在寻找开发者协作者,请访问 Google 开发者社区 Discord 服务器。 如果您打算面向大量受众群体部署 Google 文档客服助手,请注意,您在使用 Google Gemini API 时可能会受到速率限制和其他使用限制。如果您考虑使用 Gemini API 构建生产应用(例如 Google 文档客服),请查看 Google Cloud Vertex AI 服务,以提高应用的可伸缩性和可靠性。 如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。 最后更新时间 (UTC):2025-02-25。