เมื่อพัฒนาโซลูชัน Generative AI ด้วย Gemini ทาง Google มีผลิตภัณฑ์ API 2 รายการ ได้แก่ Gemini Developer API และ Gemini Enterprise Agent Platform API
Gemini Developer API เป็นเส้นทางที่เร็วที่สุดในการสร้าง ทำให้พร้อมใช้งานจริง และปรับขนาดแอปพลิเคชันที่ทำงานด้วย Gemini นักพัฒนาแอปส่วนใหญ่ควรใช้ Gemini Developer API เว้นแต่จะมีความจำเป็นต้องใช้การควบคุมเฉพาะสำหรับองค์กร
แพลตฟอร์ม Agent ของ Gemini Enterprise มีระบบนิเวศที่ครอบคลุมของฟีเจอร์และบริการที่พร้อมใช้งานในองค์กร สำหรับการสร้างและติดตั้งใช้งานแอปพลิเคชัน Generative AI ที่ขับเคลื่อนโดย Google Cloud Platform
เมื่อเร็วๆ นี้เราได้ปรับปรุงการย้ายข้อมูลระหว่างบริการเหล่านี้ให้ง่ายขึ้น ตอนนี้คุณเข้าถึงทั้ง Gemini Developer API และ Gemini Enterprise Agent Platform API ได้แล้วผ่าน Google Gen AI SDK แบบรวม
การเปรียบเทียบโค้ด
หน้านี้มีการเปรียบเทียบโค้ดแบบเคียงข้างกันระหว่าง Gemini Developer API กับ การเริ่มต้นใช้งานแพลตฟอร์ม Agent ของ Gemini Enterprise อย่างรวดเร็วสำหรับการสร้างข้อความ
Python
คุณสามารถเข้าถึงทั้งบริการ Gemini Developer API และแพลตฟอร์ม Agent ของ Gemini Enterprise ผ่านไลบรารี 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)
API ของแพลตฟอร์ม Agent ของ Gemini Enterprise
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 และแพลตฟอร์ม Agent ของ Gemini Enterprise ผ่าน@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();
API ของแพลตฟอร์ม Agent ของ Gemini Enterprise
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 และแพลตฟอร์ม Agent ของ Gemini Enterprise ผ่าน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)
}
API ของแพลตฟอร์ม Agent ของ Gemini Enterprise
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)
}
กรณีการใช้งานและแพลตฟอร์มอื่นๆ
ดูคำแนะนำเฉพาะสำหรับ Use Case ในเอกสารประกอบเกี่ยวกับ Gemini Developer API และเอกสารประกอบเกี่ยวกับแพลตฟอร์ม Agent ของ Gemini Enterprise สำหรับแพลตฟอร์มและ Use Case อื่นๆ
ข้อควรพิจารณาในการย้ายข้อมูล
สิ่งที่จะเกิดขึ้นเมื่อคุณย้ายข้อมูล
คุณจะต้องใช้บัญชีบริการ Google Cloud เพื่อตรวจสอบสิทธิ์ ดูข้อมูลเพิ่มเติมได้ที่เอกสารประกอบของแพลตฟอร์ม Agent ของ Gemini Enterprise
คุณสามารถใช้โปรเจ็กต์ 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
เปิดหน้า ข้อมูลเข้าสู่ระบบ Google Cloud API
ค้นหาคีย์ API ที่ต้องการลบ แล้วคลิกไอคอนการดำเนินการ
เลือกลบคีย์ API
เลือกลบในโมดัลลบข้อมูลเข้าสู่ระบบ
การลบคีย์ API จะใช้เวลาสักครู่จึงจะมีผล หลังจาก การเผยแพร่เสร็จสมบูรณ์แล้ว ระบบจะปฏิเสธการเข้าชมใดๆ ที่ใช้คีย์ API ที่ลบไปแล้ว
ขั้นตอนถัดไป
- ดูข้อมูลเพิ่มเติมเกี่ยวกับโซลูชัน Generative AI ในแพลตฟอร์ม Agent ของ Gemini Enterprise ได้ที่ ภาพรวมของ Generative AI ในแพลตฟอร์ม Agent ของ Gemini Enterprise