跳至主要內容
API 參考
API 參考

Gemini Omni 創建音訊

使用建立音訊端點,在同一回應中接收結果。

01

概覽

使用建立音訊端點,並從同一回應中讀取結果。

快速入門

  1. 建立 API 金鑰並將其設定為 RUNAPI_API_KEY。
  2. 傳送主體符合請求 Schema 的 POST 請求。
  3. 從成功的回應主體中讀取結果。

端點

POST /api/v1/gemini_omni/create_audio
基礎 URL
https://runapi.ai
API 版本
v1
身份驗證
Authorization: Bearer YOUR_API_TOKEN
02

支援的模型

開啟模型頁面以查看當前定價、速率限制及商業用途詳情。

03

請求結構

JSON 內容

僅傳送此端點宣告的欄位。

gemini-omni-audio4 個欄位
audio_idstring
必填

用於音頻預設的聲音身份。

example_dialoguestring
選填

展示語音風格的示例對話。

邊界值: 120
namestring
必填

音訊預設顯示名稱。

邊界值: 210
voice_descriptionstring
選填

聲音特徵,例如音調、音色或口音。

邊界值: 20000
04

成功回應

HTTP 200

POST /api/v1/gemini_omni/create_audio

回應結構
JSON
{
  "properties": {
    "audio": {
      "properties": {
        "id": {
          "description": "已建立的音訊預設識別符。",
          "type": "string"
        },
        "name": {
          "description": "音訊預設顯示名稱。",
          "type": "string"
        }
      },
      "required": [
        "id"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    "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
    },
    "id": {
      "description": "已建立的音訊預設識別符。",
      "type": "string"
    }
  },
  "required": [
    "id",
    "audio",
    "billing"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

回應範例

JSON
{
  "audio": {
    "id": "aud_reference_narrator",
    "name": "Studio Narrator"
  },
  "billing": {
    "refund": null,
    "reservation": null,
    "settlement": null
  },
  "id": "aud_reference_narrator"
}
05

錯誤

HTTP 401

POST /api/v1/gemini_omni/create_audio

回應結構
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_audio

回應結構
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": {
    "audio_id": [
      "is required"
    ]
  }
}
07

錯誤

HTTP 402

POST /api/v1/gemini_omni/create_audio

回應結構
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_audio

回應結構
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_audio

回應結構
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_audio

回應結構
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_audio

回應結構
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_audio

回應結構
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_audio.run(
  audio_id="achernar",
  name="Studio Narrator",
  voice_description="A calm and clear narration voice.",
  example_dialogue="Welcome to the studio."
)