مقارنة بين Gemini Developer API وVertex AI

عند تطوير حلول الذكاء الاصطناعي التوليدي باستخدام Gemini، تقدّم Google منتجَين من واجهات برمجة التطبيقات: Gemini Developer API وVertex AI Gemini API.

يوفر Gemini Developer API أسرع طريقة لإنشاء تطبيقات مستندة إلى Gemini، وتحويلها إلى منتجات، وتوسيع نطاقها. على معظم المطوّرين استخدام واجهة برمجة التطبيقات Gemini Developer API ما لم تكن هناك حاجة إلى عناصر تحكّم محدّدة للمؤسسات.

توفّر Vertex AI منظومة متكاملة شاملة من الميزات والخدمات الجاهزة للاستخدام في المؤسسات لإنشاء تطبيقات الذكاء الاصطناعي التوليدي ونشرها، وهي تستند إلى "منصة Google Cloud".

لقد بسّطنا مؤخرًا عملية نقل البيانات بين هاتين الخدمتين. يمكن الآن الوصول إلى كل من واجهة Gemini Developer API وواجهة Vertex AI Gemini API من خلال حزمة تطوير البرامج (SDK) الموحّدة من Google للذكاء الاصطناعي التوليدي.

مقارنة الرموز

تعرض هذه الصفحة مقارنات بين الرموز البرمجية جنبًا إلى جنب بين Gemini Developer API و<0x0A>برامج التشغيل السريع لإنشاء النصوص في Vertex AI.

Python

يمكنك الوصول إلى كل من Gemini Developer API وخدمات Vertex AI من خلال مكتبة google-genai. راجِع صفحة المكتبات للحصول على تعليمات حول كيفية تثبيت google-genai.

Gemini Developer API

from google import genai

client = genai.Client()

response = client.models.generate_content(
    model="gemini-2.0-flash", contents="Explain how AI works in a few words"
)
print(response.text)

Vertex AI Gemini API

from google import genai

client = genai.Client(
    vertexai=True, project='your-project-id', location='us-central1'
)

response = client.models.generate_content(
    model="gemini-2.0-flash", contents="Explain how AI works in a few words"
)
print(response.text)

‫JavaScript وTypeScript

يمكنك الوصول إلى كلّ من Gemini Developer API وخدمات Vertex AI من خلال @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-2.0-flash",
    contents: "Explain how AI works in a few words",
  });
  console.log(response.text);
}

main();

Vertex AI Gemini 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-2.0-flash",
    contents: "Explain how AI works in a few words",
  });
  console.log(response.text);
}

main();

انتقال

يمكنك الوصول إلى كلّ من Gemini Developer API وخدمات Vertex AI من خلال 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-2.0-flash", genai.Text("Tell me about New York?"), nil)

}

Vertex AI Gemini 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-2.0-flash", genai.Text("Tell me about New York?"), nil)

}

حالات الاستخدام والمنصات الأخرى

يمكنك الرجوع إلى الأدلة الخاصة بحالات الاستخدام على مستندات Gemini Developer API ومستندات Vertex AI لمزيد من المعلومات حول المنصات وحالات الاستخدام الأخرى.

اعتبارات نقل البيانات

عند نقل البيانات:

إذا لم تعُد بحاجة إلى استخدام مفتاح Gemini API لواجهة Gemini Developer API، اتّبِع أفضل ممارسات الأمان واحذفه.

لحذف مفتاح واجهة برمجة التطبيقات، اتّبِع الخطوات التالية:

  1. افتح صفحة بيانات الاعتماد من Google Cloud API.

  2. ابحث عن مفتاح واجهة برمجة التطبيقات الذي تريد حذفه وانقر على رمز الإجراءات.

  3. انقر على حذف مفتاح واجهة برمجة التطبيقات.

  4. في النافذة المنبثقة حذف بيانات الاعتماد، انقر على حذف.

    تستغرق عملية حذف مفتاح واجهة برمجة التطبيقات بضع دقائق لنشره. بعد اكتمال عملية النقل، سيتم رفض أي زيارات تستخدم مفتاح واجهة برمجة التطبيقات المحذوف.

الخطوات التالية