เมื่อพัฒนาโซลูชัน 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 GenAI SDK แบบรวมและ Interactions API
การเปรียบเทียบโค้ด: Interactions API (แนะนํา)
Interactions API เป็นวิธีที่แนะนําในการสร้างด้วยโมเดลและเอเจนต์ของ Gemini ตัวอย่างต่อไปนี้ เปรียบเทียบการสร้างข้อความระหว่าง Gemini Developer API กับแพลตฟอร์ม Agent ของ Gemini Enterprise
Python
คุณสามารถเข้าถึงทั้ง Gemini Developer API และบริการแพลตฟอร์มเอเจนต์ Gemini Enterprise ได้ผ่านไลบรารี google-genai (>= 2.3.0) ดูวิธีการติดตั้ง 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)
API แพลตฟอร์ม Agent ของ Gemini Enterprise
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 และ TypeScript
คุณสามารถเข้าถึงทั้ง Gemini Developer API และแพลตฟอร์ม Agent ของ Gemini Enterprise
ได้ผ่านไลบรารี @google/genai (>= 2.3.0) ดูวิธีการติดตั้ง
@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);
API แพลตฟอร์ม Agent ของ Gemini Enterprise
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);
การเปรียบเทียบโค้ด: API ของ generateContent
แม้ว่าเราจะแนะนำให้ใช้ Interactions API สำหรับโปรเจ็กต์ใหม่ แต่ระบบจะยังคงรองรับ generateContent API ต่อไป
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.8-flash", 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.8-flash", 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.8-flash",
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.8-flash",
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.8-flash", genai.Text("Tell me about New York?"), nil)
}
API แพลตฟอร์ม Agent ของ Gemini Enterprise
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)
}
กรณีการใช้งานและแพลตฟอร์มอื่นๆ
ดูคำแนะนำเฉพาะสำหรับ 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 ในระหว่างเวอร์ชันตัวอย่าง Interactions API ในแพลตฟอร์ม Gemini Enterprise Agent จะรองรับเฉพาะปลายทาง
global(location="global") ดูรายการ ภูมิภาคที่รองรับสำหรับ Generative AI ใน Google Cloudโมเดลที่คุณสร้างใน Google AI Studio จะต้องได้รับการฝึกอีกครั้งใน Gemini Enterprise Agent Platform
หากไม่จำเป็นต้องใช้คีย์ Gemini API สำหรับ Gemini Developer API อีกต่อไป โปรดทำตามแนวทางปฏิบัติแนะนำด้านความปลอดภัยและลบคีย์ดังกล่าว
วิธีลบคีย์ API
ค้นหาคีย์ API ที่ต้องการลบ แล้วคลิกไอคอนการดำเนินการ
เลือกลบคีย์ API
ในโมดัลลบข้อมูลเข้าสู่ระบบ ให้เลือกลบ
การลบคีย์ API จะใช้เวลาสักครู่ในการเผยแพร่ หลังจาก การเผยแพร่เสร็จสมบูรณ์แล้ว ระบบจะปฏิเสธการเข้าชมที่ใช้คีย์ API ที่ลบไปแล้ว
ขั้นตอนถัดไป
- สำรวจคู่มือนักพัฒนาซอฟต์แวร์ Interactions API ในแพลตฟอร์ม Agent ของ Gemini Enterprise
- ดูข้อมูลเพิ่มเติมเกี่ยวกับโซลูชัน Generative AI ในแพลตฟอร์ม Agent ของ Gemini Enterprise ได้ที่ ภาพรวมของ Generative AI ในแพลตฟอร์ม Agent ของ Gemini Enterprise