אתם יכולים להשתמש בפקודות curl כדי לשלוח בקשות לנקודת הקצה של Gemini Enterprise Agent Platform באמצעות שמות המודלים הבאים:
- ב-Llama 4 Maverick 17B-128E, משתמשים ב-
llama-4-maverick-17b-128e-instruct-maas - ב-Llama 4 Scout 17B-16E, משתמשים ב-
llama-4-scout-17b-16e-instruct-maas
במאמר שליחת קריאות ל-MaaS API למודלים פתוחים מוסבר איך שולחים קריאות בסטרימינג וללא סטרימינג למודלים של Llama.
לפני שמתחילים
כדי להשתמש במודלים של Llama עם Gemini Enterprise Agent Platform, צריך לבצע את השלבים הבאים. כדי להשתמש במודלים של Llama ב-Gemini Enterprise Agent Platform, צריך להפעיל את Agent Platform API (aiplatform.googleapis.com) ואת Cloud Commerce Consumer Procurement API (cloudcommerceconsumerprocurement.googleapis.com). אם כבר יש לכם פרויקט שבו ממשקי ה-API האלה מופעלים, אתם יכולים להשתמש בו במקום ליצור פרויקט חדש.
- נכנסים לחשבון Google Cloud . אנחנו ממליצים למשתמשים חדשים ב- Google Cloud ליצור חשבון כדי שיוכלו להעריך את הביצועים של המוצרים שלנו בתרחישים מהעולם האמיתי. לקוחות חדשים מקבלים בחינם גם קרדיט בשווי 300$ להרצה, לבדיקה ולפריסה של עומסי העבודה.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Gemini Enterprise Agent Platform and Cloud Commerce Consumer Procurement APIs, if any are not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Gemini Enterprise Agent Platform and Cloud Commerce Consumer Procurement APIs, if any are not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.- עוברים לאחד מכרטיסי המודלים הבאים ב-Model Garden ולוחצים על Enable:
התפקידים הנדרשים
כדי לקבל את ההרשאות שדרושות להפעלה ולשימוש במודלים של Llama, בקשו מהאדמין לתת לכם את התפקידים הבאים ב-IAM בפרויקט:
- Agent Platform User (
roles/aiplatform.user) - ניהול הרשאות רכש לצרכנים (
roles/consumerprocurement.entitlementManager)
להסבר על מתן תפקידים, ראו איך מנהלים את הגישה ברמת הפרויקט, התיקייה והארגון.
יכול להיות שאפשר לקבל את ההרשאות הנדרשות גם באמצעות תפקידים בהתאמה אישית או תפקידים מוגדרים מראש.
מידע נוסף על מתן הרשאות והגדרת מדיניות ארגונית למודלים של שותפים זמין במאמר מתן גישה למשתמשים למודלים של שותפים.
איך שולחים קריאה בסטרימינג למודל Llama
הדוגמה הבאה מבצעת קריאה בסטרימינג למודל Llama.
REST
אחרי שמגדירים את הסביבה, אפשר להשתמש ב-REST כדי לבדוק פרומפט טקסטואלי. הדוגמה הבאה שולחת בקשה לנקודת הקצה של המודל של בעל התוכן הדיגיטלי.
לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:
- LOCATION: אזור שתומך במודלים של Llama, לדוגמה
us-east5. - MODEL: שם המודל שבו רוצים להשתמש, לדוגמה
llama-4-maverick-17b-128e-instruct-maas. - ROLE: התפקיד שמשויך להודעה. אפשר לציין
userאוassistant. ההודעה הראשונה חייבת להשתמש בתפקידuser. המודלים פועלים בתורות, פעםuserופעםassistant. אם ההודעה האחרונה משתמשת בתפקידassistant, תוכן התשובה ממשיך מיד מהתוכן של ההודעה הזו. אפשר להשתמש בזה כדי להגביל חלק מהתשובה של המודל. - CONTENT: התוכן, כמו טקסט, של ההודעה ב-
userאו ב-assistant. - MAX_OUTPUT_TOKENS:
המספר המקסימלי של טוקנים שאפשר ליצור בתשובה. טוקן הוא בערך ארבעה תווים. 100 טוקנים שווים בערך ל-60 עד 80 מילים.
כדי לקבל תשובות קצרות יותר, מציינים ערך נמוך יותר. כדי לקבל תשובות ארוכות יותר, מציינים ערך גבוה יותר.
- STREAM: ערך בוליאני שמציין אם התשובה מועברת בסטרימינג או לא. כדאי להעביר את התשובה בסטרימינג כדי לצמצם את זמן האחזור שמשתמשי הקצה חווים. מגדירים את הערך
trueכדי להציג את התשובה באופן שוטף, ואת הערךfalseכדי להציג את התשובה בבת אחת.
ה-method של ה-HTTP וכתובת ה-URL:
POST https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/endpoints/openapi/chat/completions
גוף בקשת JSON:
{
"model": "meta/MODEL",
"messages": [
{
"role": "ROLE",
"content": "CONTENT"
}
],
"max_tokens": MAX_OUTPUT_TOKENS,
"stream": true
}
כדי לשלוח את הבקשה עליכם לבחור אחת מהאפשרויות הבאות:
curl
שומרים את גוף הבקשה בקובץ בשם request.json ומריצים את הפקודה הבאה:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/endpoints/openapi/chat/completions"
PowerShell
שומרים את גוף הבקשה בקובץ בשם request.json ומריצים את הפקודה הבאה:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/endpoints/openapi/chat/completions" | Select-Object -Expand Content
אתם אמורים לקבל תגובת JSON שדומה לזו:
שליחת קריאה אונארית למודל Llama
הדוגמה הבאה מבצעת קריאה אונארית למודל Llama.
REST
אחרי שמגדירים את הסביבה, אפשר להשתמש ב-REST כדי לבדוק פרומפט טקסטואלי. הדוגמה הבאה שולחת בקשה לנקודת הקצה של המודל של בעל התוכן הדיגיטלי.
לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:
- LOCATION: אזור שתומך במודלים של Llama, לדוגמה
us-east5. - MODEL: שם המודל שבו רוצים להשתמש, לדוגמה
llama-4-maverick-17b-128e-instruct-maas. - ROLE: התפקיד שמשויך להודעה. אפשר לציין
userאוassistant. ההודעה הראשונה חייבת להשתמש בתפקידuser. המודלים פועלים בתורות, פעםuserופעםassistant. אם ההודעה האחרונה משתמשת בתפקידassistant, תוכן התשובה ממשיך מיד מהתוכן של ההודעה הזו. אפשר להשתמש בזה כדי להגביל חלק מהתשובה של המודל. - CONTENT: התוכן, כמו טקסט, של ההודעה ב-
userאו ב-assistant. - MAX_OUTPUT_TOKENS:
המספר המקסימלי של טוקנים שאפשר ליצור בתשובה. טוקן הוא בערך ארבעה תווים. 100 טוקנים שווים בערך ל-60 עד 80 מילים.
כדי לקבל תשובות קצרות יותר, מציינים ערך נמוך יותר. כדי לקבל תשובות ארוכות יותר, מציינים ערך גבוה יותר.
- STREAM: ערך בוליאני שמציין אם התשובה מועברת בסטרימינג או לא. כדאי להעביר את התשובה בסטרימינג כדי לצמצם את זמן האחזור שמשתמשי הקצה חווים. מגדירים את הערך
trueכדי להציג את התשובה באופן שוטף, ואת הערךfalseכדי להציג את התשובה בבת אחת.
ה-method של ה-HTTP וכתובת ה-URL:
POST https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/endpoints/openapi/chat/completions
גוף בקשת JSON:
{
"model": "meta/MODEL",
"messages": [
{
"role": "ROLE",
"content": "CONTENT"
}
],
"max_tokens": MAX_OUTPUT_TOKENS,
"stream": false
}
כדי לשלוח את הבקשה עליכם לבחור אחת מהאפשרויות הבאות:
curl
שומרים את גוף הבקשה בקובץ בשם request.json ומריצים את הפקודה הבאה:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/endpoints/openapi/chat/completions"
PowerShell
שומרים את גוף הבקשה בקובץ בשם request.json ומריצים את הפקודה הבאה:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/endpoints/openapi/chat/completions" | Select-Object -Expand Content
אתם אמורים לקבל תגובת JSON שדומה לזו:
שימוש ב-Agent Studio
במודלים של Llama, אתם יכולים להשתמש ב-Agent Studio כדי ליצור במהירות אב טיפוס ולבדוק מודלים של AI גנרטיבי במסוף Google Cloud . לדוגמה, אתם יכולים להשתמש ב-Agent Studio כדי להשוות בין התשובות של מודל Llama לבין מודלים נתמכים אחרים, כמו Gemini של Google.
זמינות ומכסות של מודל Llama לפי אזור
במודלים של Llama, המכסה חלה על כל אזור שבו המודל זמין. המכסה מצוינת בשאילתות לדקה (QPM).
| דגם | אזור | מכסות | חלון ההקשר |
|---|---|---|---|
| Llama 4 Maverick 17B-128E | |||
us-east5 |
|
524,288 | |
| Llama 4 Scout 17B-16E | |||
us-east5 |
|
1,310,720 |
אם אתם רוצים להגדיל את אחת מהמכסות של Agent Platform, אתם יכולים להשתמש במסוף Google Cloud כדי לבקש הגדלה של המכסה. לסקירה כללית על מכסות ב-Cloud