Gemini Developer API 与 Gemini Enterprise Agent Platform 的对比

Google 在使用 Gemini 开发生成式 AI 解决方案时提供了两种 API 产品: Gemini Developer APIGemini Enterprise Agent Platform API

Gemini Developer API 可帮助您以最快的速度构建、生产化和扩缩由 Gemini 提供支持的应用。大多数开发者都应使用 Gemini Developer API,除非需要特定的企业控制。

Gemini Enterprise Agent Platform 提供了一个全面的生态系统,其中包含企业就绪型功能和服务,可用于构建和部署由 Google Cloud Platform 提供支持的生成式 AI 应用。

我们最近简化了在这些服务之间迁移的过程。现在,您可以通过统一的 Google Gen AI SDK访问 Gemini Developer API 和 Gemini Enterprise Agent Platform API。

代码比较

本页并排比较了 Gemini Developer API 和 Gemini Enterprise Agent Platform 文本生成快速入门的代码。

Python

您可以通过 google-genai 库访问 Gemini Developer API 和 Gemini Enterprise Agent Platform 服务。如需了解如何安装 google-genai,请参阅 页面 。

Gemini Developer API

from google import genai

client = genai.Client()

response = client.models.generate_content(
    model="gemini-3-flash-preview", contents="Explain how AI works in a few words"
)
print(response.text)

Gemini Enterprise Agent Platform API

from google import genai

client = genai.Client(
    vertexai=True, project='your-project-id', location='us-central1'
)

response = client.models.generate_content(
    model="gemini-3-flash-preview", contents="Explain how AI works in a few words"
)
print(response.text)

JavaScript 和 TypeScript

您可以通过 @google/genai 库访问 Gemini Developer API 和 Gemini Enterprise Agent Platform 服务。如需了解如何安装 @google/genai,请参阅 页面。

Gemini Developer API

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

async function main() {
  const response = await ai.models.generateContent({
    model: "gemini-3-flash-preview",
    contents: "Explain how AI works in a few words",
  });
  console.log(response.text);
}

main();

Gemini Enterprise Agent Platform API

import { GoogleGenAI } from '@google/genai';
const ai = new GoogleGenAI({
  vertexai: true,
  project: 'your_project',
  location: 'your_location',
});

async function main() {
  const response = await ai.models.generateContent({
    model: "gemini-3-flash-preview",
    contents: "Explain how AI works in a few words",
  });
  console.log(response.text);
}

main();

Go

您可以通过 google.golang.org/genai 库访问 Gemini Developer API 和 Gemini Enterprise Agent Platform 服务。如需了解如何安装 google.golang.org/genai,请参阅 页面。

Gemini Developer API

import (
  "context"
  "encoding/json"
  "fmt"
  "log"
  "google.golang.org/genai"
)

// Your Google API key
const apiKey = "your-api-key"

func main() {
  ctx := context.Background()
  client, err := genai.NewClient(ctx, nil)
  if err != nil {
      log.Fatal(err)
  }

  // Call the GenerateContent method.
  result, err := client.Models.GenerateContent(ctx, "gemini-3-flash-preview", genai.Text("Tell me about New York?"), nil)

}

Gemini Enterprise Agent Platform API

import (
  "context"
  "encoding/json"
  "fmt"
  "log"
  "google.golang.org/genai"
)

// Your GCP project
const project = "your-project"

// A GCP location like "us-central1"
const location = "some-gcp-location"

func main() {
  ctx := context.Background()
  client, err := genai.NewClient(ctx, &genai.ClientConfig
  {
        Project:  project,
      Location: location,
      Backend:  genai.BackendVertexAI,
  })

  // Call the GenerateContent method.
  result, err := client.Models.GenerateContent(ctx, "gemini-3-flash-preview", genai.Text("Tell me about New York?"), nil)

}

其他用例和平台

如需了解其他平台和用例,请参阅 Gemini Developer API 文档Gemini Enterprise Agent Platform 文档 中特定于用例的指南。

迁移注意事项

迁移时:

  • 您需要使用 Google Cloud 服务账号进行身份验证。如需了解详情,请参阅 Gemini Enterprise Agent Platform 文档

  • 您可以使用现有的 Google Cloud 项目 (即用于生成 API 密钥的项目),也可以 创建新的 Google Cloud 项目

  • Gemini Developer API 和 Gemini Enterprise Agent Platform API 支持的区域可能会有所不同。请参阅 Google Cloud 上的生成式 AI 支持的区域列表

  • 您在 Google AI Studio 中创建的任何模型都需要在 Gemini Enterprise Agent Platform 中重新训练。

如果您不再需要使用 Gemini Developer API 的 Gemini API 密钥,请遵循安全性最佳实践并将其删除。

如需删除 API 密钥,请执行以下操作:

  1. 打开 Google Cloud API 凭据 页面。

  2. 找到您要删除的 API 密钥,然后点击操作 图标。

  3. 选择删除 API 密钥

  4. 删除凭据模态框中,选择删除

    删除 API 密钥的操作需要几分钟时间才能生效。生效后,任何使用已删除的 API 密钥的流量都将遭到拒绝。

后续步骤