API 參考
Gemini Omni 建立角色
使用 create character 端點,在同一回應中接收結果。
01
概覽
使用 create character 端點,並從同一回應中讀取結果。
快速入門
- 建立 API 金鑰並將其設定為 RUNAPI_API_KEY。
- 傳送一個 POST 請求,其主體符合請求結構描述。
- 從成功的回應主體中讀取結果。
端點
- 基礎 URL
https://runapi.ai- API 版本
v1- 身分驗證
Authorization: Bearer YOUR_API_TOKEN
02
支援的模型
開啟模型頁面以查看目前的定價、速率限制及商業用途詳情。
03
JSON 請求內文請求綱要
僅傳送此端點宣告的欄位。
gemini-omni-character5 個欄位
audio_idsarray
選填
由 create-audio 返回的音訊預設 ID。
body_reference_image_urlstring
選填
選填的公開全身參考圖片 URL;reference_image_url 必須提供肖像圖。
character_namestring
選填
角色顯示名稱。
邊界:210
descriptionsstring
必填
角色的外觀、身份、風格、服裝或個性描述。
邊界:20000
reference_image_urlstring
必填
公開肖像參考圖片 URL。
04
HTTP 200成功回應
POST /api/v1/gemini_omni/create_character
回應綱要
JSON
{
"properties": {
"billing": {
"properties": {
"refund": {
"oneOf": [
{
"properties": {
"refunded_at": {
"type": "string"
}
},
"required": [
"refunded_at"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
},
"reservation": {
"oneOf": [
{
"properties": {
"amount_cents": {
"type": "integer"
}
},
"required": [
"amount_cents"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
},
"settlement": {
"oneOf": [
{
"properties": {
"amount_micro_cents": {
"type": "integer"
},
"charged_amount_cents": {
"type": "integer"
}
},
"required": [
"charged_amount_cents",
"amount_micro_cents"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
}
},
"required": [
"reservation",
"settlement",
"refund"
],
"type": "object",
"unevaluatedProperties": false
},
"character": {
"properties": {
"id": {
"description": "已建立的角色識別碼。",
"type": "string"
},
"images": {
"description": "依序排列的角色參考圖片;第一張為肖像圖,第二張為選填的全身圖。",
"items": {
"properties": {
"url": {
"type": "string",
"x-runapi-generated-media": true
}
},
"required": [
"url"
],
"type": "object",
"unevaluatedProperties": false
},
"maxItems": 2,
"type": "array"
},
"name": {
"description": "角色顯示名稱。",
"type": "string"
}
},
"required": [
"id"
],
"type": "object",
"unevaluatedProperties": false
},
"id": {
"description": "已建立的角色識別碼。",
"type": "string"
}
},
"required": [
"id",
"character",
"billing"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
JSON
{
"billing": {
"refund": null,
"reservation": null,
"settlement": null
},
"character": {
"id": "chr_reference_presenter",
"images": [
{
"url": "https://cdn.runapi.ai/public/samples/portrait.jpg"
},
{
"url": "https://cdn.runapi.ai/public/samples/image.jpg"
}
],
"name": "Studio Presenter"
},
"id": "chr_reference_presenter"
}
05
HTTP 401錯誤
POST /api/v1/gemini_omni/create_character
回應綱要
JSON
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
JSON
{
"error": "Authentication required"
}
06
HTTP 400錯誤
POST /api/v1/gemini_omni/create_character
回應綱要
JSON
{
"oneOf": [
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
},
{
"properties": {
"error": {
"description": "人類可讀的驗證摘要。",
"type": "string"
},
"errors": {
"additionalProperties": {
"items": {
"type": "string"
},
"type": "array"
},
"description": "以公開請求欄位為索引鍵的驗證訊息,每個欄位包含一組人類可讀的字串陣列。",
"type": "object"
}
},
"required": [
"error",
"errors"
],
"type": "object",
"unevaluatedProperties": false
}
]
}
回應範例
JSON
{
"error": "Validation failed",
"errors": {
"descriptions": [
"is required"
]
}
}
07
HTTP 402錯誤
POST /api/v1/gemini_omni/create_character
回應綱要
JSON
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
JSON
{
"error": "Insufficient balance"
}
08
HTTP 429錯誤
POST /api/v1/gemini_omni/create_character
回應綱要
JSON
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
JSON
{
"error": "API key credit limit exceeded"
}
09
HTTP 409錯誤
POST /api/v1/gemini_omni/create_character
回應綱要
JSON
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
JSON
{
"error": "The request uses features that are not supported for the selected model"
}
10
HTTP 429錯誤
POST /api/v1/gemini_omni/create_character
回應綱要
JSON
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
JSON
{
"error": "Rate limit reached. Please retry later."
}
11
HTTP 503錯誤
POST /api/v1/gemini_omni/create_character
回應綱要
JSON
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
JSON
{
"error": "Service under maintenance, please try again later"
}
12
HTTP 504錯誤
POST /api/v1/gemini_omni/create_character
回應綱要
JSON
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
JSON
{
"error": "The request timed out"
}
13
產生的程式碼範例
直接使用 cURL,或為您的程式語言安裝 SDK。每個範例均會提交本參考中所示的已驗證請求。
安裝
Shell
pip install runapi-gemini-omni
PYTHON
import os
from runapi.gemini_omni import GeminiOmniClient
client = GeminiOmniClient(api_key=os.environ["RUNAPI_API_KEY"])
result = client.create_character.run(
descriptions="A presenter wearing a blue jacket in a bright studio.",
reference_image_url="https://cdn.runapi.ai/public/samples/portrait.jpg",
body_reference_image_url="https://cdn.runapi.ai/public/samples/image.jpg",
character_name="Studio Presenter"
)