כשמפתחים פתרונות AI גנרטיבי באמצעות Gemini, Google מציעה שני מוצרי API: Gemini Developer API ו-Gemini platform API.
Gemini Developer API הוא הדרך המהירה ביותר לבנות אפליקציות מבוססות-Gemini, להעביר אותן לייצור ולהרחיב אותן. רוב המפתחים צריכים להשתמש ב-Gemini Developer API, אלא אם יש צורך באמצעי בקרה ספציפיים ברמת הארגון.
פלטפורמת Gemini מציעה מערכת אקולוגית מקיפה של תכונות ושירותים שמוכנים לשימוש בארגונים, ליצירה ולפריסה של אפליקציות AI גנרטיבי שמגובות על ידי Google Cloud.
לאחרונה פישטנו את תהליך ההעברה בין השירותים האלה. Gemini Developer API ו-Gemini platform API זמינים עכשיו דרך Google GenAI SDK המאוחד ו-Interactions API.
השוואת קוד: Interactions API (מומלץ)
Interactions API היא הדרך המומלצת לבנות באמצעות מודלים וסוכנים של Gemini. בדוגמאות הבאות מוצגת השוואה בין יצירת טקסט באמצעות Gemini Developer API ופלטפורמת Gemini.
Python
אפשר לגשת גם אל Gemini Developer API וגם אל שירותי פלטפורמת Gemini באמצעות ספריית 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)
Gemini 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 ו-TypeScript
אפשר לגשת גם אל Gemini Developer API וגם אל שירותי פלטפורמת Gemini באמצעות ספריית @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);
Gemini 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);
השוואת קוד: generateContent API
מומלץ להשתמש ב-API של אינטראקציות בפרויקטים חדשים, אבל עדיין יש תמיכה ב-API של generateContent.
Python
אפשר לגשת גם ל-Gemini Developer API וגם לשירותי פלטפורמת Gemini דרך ספריית google-genai. הוראות להתקנה של google-genai מופיעות בדף libraries (ספריות).
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 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 ו-TypeScript
אפשר לגשת גם ל-Gemini Developer API וגם לשירותי פלטפורמת Gemini דרך ספריית @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();
Gemini 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
אפשר לגשת גם ל-Gemini Developer API וגם לשירותי פלטפורמת Gemini דרך ספריית 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)
}
Gemini 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)
}
תרחישי שימוש ופלטפורמות אחרים
בתיעוד של Gemini Developer API ובתיעוד של פלטפורמת Gemini אפשר למצוא מדריכים ספציפיים לתרחישי שימוש בפלטפורמות אחרות.
שיקולים לגבי מיגרציה
כשמבצעים העברה:
תצטרכו להשתמש בחשבונות שירות של Google Cloud כדי לבצע אימות. מידע נוסף מופיע במסמכי התיעוד של פלטפורמת Gemini.
אפשר להשתמש בפרויקט קיים ב-Google Cloud (אותו פרויקט שבו השתמשתם כדי ליצור את מפתח ה-API) או ליצור פרויקט חדש ב-Google Cloud.
יכול להיות שיהיו הבדלים באזורים הנתמכים בין Gemini Developer API לבין Gemini platform API. במהלך תקופת התצוגה המקדימה, Interactions API בפלטפורמת Gemini תומך רק בנקודת הקצה
global(location="global"). אפשר לעיין ברשימת האזורים הנתמכים ל-AI גנרטיבי ב-Google Cloud.צריך לאמן מחדש בפלטפורמת Gemini את כל המודלים שיצרתם ב-Google AI Studio.
אם אתם לא צריכים יותר להשתמש במפתח Gemini API עבור Gemini Developer API, מומלץ למחוק אותו בהתאם לשיטות המומלצות לאבטחה.
כדי למחוק מפתח API:
פותחים את הדף Google Cloud API Credentials.
מאתרים את מפתח ה-API שרוצים למחוק ולוחצים על סמל הפעולות.
בוחרים באפשרות מחיקת מפתח API.
בחלון מחיקת פרטי כניסה, לוחצים על מחיקה.
תהליך המחיקה של מפתח API יכול להימשך כמה דקות. אחרי שההפצה מסתיימת, כל התנועה שמשתמשת במפתח ה-API שנמחק נדחית.
השלבים הבאים
- מומלץ לעיין במדריך למפתחים בנושא Interactions API בפלטפורמת Gemini.
- בסקירה הכללית על פלטפורמת Gemini עם AI גנרטיבי אפשר לקרוא מידע נוסף על פתרונות AI גנרטיבי בפלטפורמת Gemini.