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 APIGemini Enterprise Agent Platform API.

Gemini Developer API cung cấp cách nhanh nhất để tạo, phát hành công khai 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ể 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 Gen AI SDK hợp nhất.

So sánh mã

Trang này có các đoạn mã so sánh song song giữa Gemini Developer API và hướng dẫn nhanh về Nền tảng tác nhân Gemini Enterprise để tạo văn bản.

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-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 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-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

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-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)

}

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 APITà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 Thao tác.

  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 để có hiệu lực. 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 đã xoá đều bị từ chối.

Các bước tiếp theo