Gemini Developer API กับแพลตฟอร์ม Agent ของ Gemini Enterprise

เมื่อพัฒนาโซลูชัน Generative AI ด้วย Gemini นั้น Google มีผลิตภัณฑ์ API 2 รายการ: ได้แก่ Gemini Developer API และ Gemini Enterprise Agent Platform API

Gemini Developer API เป็นเส้นทางที่เร็วที่สุดในการสร้าง พัฒนาให้พร้อมใช้งานจริง และปรับขนาดแอปพลิเคชันที่ขับเคลื่อนโดย Gemini นักพัฒนาแอปส่วนใหญ่ควรใช้ Gemini Developer API เว้นแต่จะมีความต้องการการควบคุมระดับองค์กรที่เฉพาะเจาะจง

Gemini Enterprise Agent Platform มีระบบนิเวศที่ครอบคลุมของฟีเจอร์และบริการที่พร้อมใช้งานระดับองค์กรสำหรับการสร้างและติดตั้งใช้งานแอปพลิเคชัน Generative AI ที่สนับสนุนโดย Google Cloud Platform

เมื่อเร็วๆ นี้ เราได้ทำให้การย้ายข้อมูลระหว่างบริการเหล่านี้ง่ายขึ้น ตอนนี้คุณเข้าถึงทั้ง Gemini Developer API และ Gemini Enterprise Agent Platform API ได้แล้วผ่าน Google Gen AI SDK แบบรวม

การเปรียบเทียบโค้ด

หน้านี้มีการเปรียบเทียบโค้ดแบบเคียงข้างกันระหว่าง Gemini Developer API กับ Gemini Enterprise Agent Platform Quickstart สำหรับการสร้างข้อความ

Python

คุณสามารถเข้าถึงทั้งบริการ Gemini Developer API และ Gemini Enterprise Agent Platform ผ่านไลบรารี google-genai ดูวิธีการติดตั้ง 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

คุณสามารถเข้าถึงทั้งบริการ Gemini Developer API และ Gemini Enterprise Agent Platform ผ่านไลบรารี @google/genai ดูวิธีการติดตั้ง @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

คุณสามารถเข้าถึงทั้งบริการ Gemini Developer API และ Gemini Enterprise Agent Platform ผ่านไลบรารี google.golang.org/genai ดูวิธีการติดตั้ง 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 ดูรายการ ภูมิภาคที่รองรับ Generative AI ใน Google Cloud

  • คุณต้องฝึกโมเดลที่สร้างใน Google AI Studio ใหม่ใน Gemini Enterprise Agent Platform

หากไม่จำเป็นต้องใช้คีย์ Gemini API สำหรับ Gemini Developer API อีกต่อไป ให้ทำตามแนวทางปฏิบัติแนะนำด้านความปลอดภัยและลบคีย์ดังกล่าว

วิธีลบคีย์ API

  1. เปิดหน้า ข้อมูลเข้าสู่ระบบ API ของ Google Cloud

  2. ค้นหาคีย์ API ที่ต้องการลบ แล้วคลิกไอคอนการดำเนินการ

  3. เลือกลบคีย์ API

  4. ในโมดัลลบข้อมูลเข้าสู่ระบบ ให้เลือกลบ

    ระบบจะใช้เวลาสักครู่ในการเผยแพร่การลบคีย์ API เมื่อการเผยแพร่เสร็จสมบูรณ์ ระบบจะปฏิเสธการรับส่งข้อมูลทั้งหมดที่ใช้คีย์ API ที่ลบ

ขั้นตอนถัดไป