Gemini Developer API so với Nền tảng tác nhân Gemini Enterprise

Khi phát triển các giải pháp AI tạo sinh bằng Gemini, Google cung cấp 2 sản phẩm API: Gemini Developer API và Gemini Enterprise Agent Platform API.

Gemini Developer API cung cấp cách nhanh nhất để tạo, sản xuất và mở rộng quy mô các ứng dụng dựa trên Gemini. Hầu hết nhà phát triển nên sử dụng Gemini Developer API, trừ phi cần có các chế độ kiểm soát cụ thể dành cho doanh nghiệp.

Nền tảng Tác nhân Gemini Enterprise cung cấp một hệ sinh thái toàn diện gồm các tính năng và dịch vụ sẵn sàng cho doanh nghiệp để xây dựng và triển khai các ứng dụng AI tạo sinh được hỗ trợ bởi Google Cloud Platform.

Gần đây, chúng tôi đã đơn giản hoá quy trình di chuyển giữa các dịch vụ này. Giờ đây, bạn có thể truy cập cả Gemini Developer API và Gemini Enterprise Agent Platform API thông qua Google GenAI SDK hợp nhất và Interactions API.

So sánh mã: Interactions API (nên dùng)

Interactions API là cách nên dùng để tạo ứng dụng bằng các mô hình và tác nhân Gemini. Các ví dụ sau đây so sánh khả năng tạo văn bản giữa Gemini Developer API và Nền tảng Tác nhân Gemini Enterprise.

Python

Bạn có thể truy cập cả Gemini Developer API và các dịch vụ Nền tảng Tác nhân Gemini Enterprise thông qua thư viện google-genai (>= 2.3.0). Hãy xem trang thư viện để biết hướng dẫn về cách cài đặt google-genai.

Gemini Developer API

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-3.8-flash",
    input="Explain how AI works in a few words",
)
print(interaction.output_text)

Gemini Enterprise Agent Platform API

from google import genai

client = genai.Client(
    enterprise=True, project="your-project-id", location="global"
)

interaction = client.interactions.create(
    model="gemini-3.8-flash",
    input="Explain how AI works in a few words",
)
print(interaction.output_text)

JavaScript và TypeScript

Bạn có thể truy cập cả API Gemini dành cho nhà phát triển và các dịch vụ Nền tảng Tác nhân Gemini Enterprise thông qua thư viện @google/genai (>= 2.3.0). Hãy xem trang thư viện để biết hướng dẫn về cách cài đặt @google/genai.

Gemini Developer API

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

const ai = new GoogleGenAI({});

const interaction = await ai.interactions.create({
  model: "gemini-3.8-flash",
  input: "Explain how AI works in a few words",
});
console.log(interaction.output_text);

Gemini Enterprise Agent Platform API

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

const ai = new GoogleGenAI({
  enterprise: true,
  project: "your_project",
  location: "global",
});

const interaction = await ai.interactions.create({
  model: "gemini-3.8-flash",
  input: "Explain how AI works in a few words",
});
console.log(interaction.output_text);

So sánh mã: generateContent API

Mặc dù bạn nên dùng Interactions API cho các dự án mới, nhưng generateContent API vẫn được hỗ trợ.

Python

Bạn có thể truy cập cả Gemini Developer API và các dịch vụ của Nền tảng Tác nhân Gemini Enterprise thông qua thư viện google-genai. Hãy xem trang thư viện để biết hướng dẫn về cách cài đặt google-genai.

Gemini Developer API

from google import genai

client = genai.Client()

response = client.models.generate_content(
    model="gemini-3.8-flash", 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.8-flash", contents="Explain how AI works in a few words"
)
print(response.text)

JavaScript và TypeScript

Bạn có thể truy cập cả Gemini Developer API và các dịch vụ của Nền tảng Tác nhân Gemini Enterprise thông qua thư viện @google/genai. Hãy xem trang thư viện để biết hướng dẫn về cách cài đặt @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.8-flash",
    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.8-flash",
    contents: "Explain how AI works in a few words",
  });
  console.log(response.text);
}

main();

Go

Bạn có thể truy cập cả Gemini Developer API và các dịch vụ của Nền tảng Tác nhân Gemini Enterprise thông qua thư viện google.golang.org/genai. Hãy xem trang thư viện để biết hướng dẫn về cách cài đặt 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.8-flash", genai.Text("Tell me about New York?"), nil)

}

Gemini Enterprise Agent Platform API

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

// Your Google Cloud project
const project = "your-project"

// A Google Cloud 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.8-flash", genai.Text("Tell me about New York?"), nil)

}

Các trường hợp sử dụng và nền tảng khác

Hãy tham khảo hướng dẫn dành riêng cho từng trường hợp sử dụng trên Tài liệu về Gemini Developer API và Tài liệu về Nền tảng Tác nhân Gemini Enterprise cho các nền tảng và trường hợp sử dụng khác.

Những điều cần cân nhắc khi di chuyển

Khi bạn di chuyển:

Nếu không cần dùng khoá Gemini API cho Gemini Developer API nữa, hãy làm theo các phương pháp bảo mật hay nhất và xoá khoá đó.

Cách xoá khoá API:

  1. Mở trang Thông tin đăng nhập API Google Cloud.

  2. Tìm khoá API mà bạn muốn xoá rồi nhấp vào biểu tượng Hành động.

  3. Chọn Xoá khoá API.

  4. Trong cửa sổ Xoá thông tin đăng nhập, hãy chọn Xoá.

    Quá trình xoá khoá API sẽ mất vài phút để truyền dữ liệu. Sau khi quá trình truyền dữ liệu hoàn tất, mọi lưu lượng truy cập sử dụng khoá API đã bị xoá đều sẽ bị từ chối.

Các bước tiếp theo