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

OpenAI Live

Send a request through RunAPI's OpenAI-compatible Live operation.

01

概覽

Use RunAPI's OpenAI-compatible Live operation with a compatible model and the protocol's request and response shapes.

快速入門

  1. 建立 API 金鑰並將其設定為 RUNAPI_API_KEY。
  2. 選擇相容的模型,然後發送文檔中的路徑參數和 JSON 主體。
  3. 讀取此操作所示的 JSON 回應或伺服器推送事件,並處理協定錯誤。

端點

POST /v1/live/webrtc
基礎 URL
https://runapi.ai
合約版本
v1
建議的身份驗證方式
Authorization: Bearer YOUR_API_TOKEN
02

身份驗證載體

RunAPI 接受以下列出的每種載體。生成的範例使用協議的首選標頭。

header - 建議
Authorization: Bearer YOUR_API_TOKEN
header
x-api-key: YOUR_API_TOKEN
03

相容模型

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

顯示 1 個相容模型
04

請求合約

JSON 內容

僅列出同時具有公開協議和 RunAPI 支援證明的欄位。額外的 JSON 主體欄位將直接傳遞。

JSON 內文18 個欄位
delegation["object", "null"]
選填

可選的 client 或 Responses 委託契約,採用提供方的原始結構。

delegation.responsesobject
選填

當 type 為 responses 時,委託工作的後端設定。

delegation.responses.instructionsstring
選填

用於委託工作的後端 prompt。

delegation.responses.max_output_tokensinteger
選填

委託回應的輸出 token 預算;最小值為 16。

delegation.responses.modelstring
必填

執行委託工作的 Responses 模型。

delegation.responses.parallel_tool_callsboolean
選填

Allow independent delegated tool calls in one turn.

delegation.responses.reasoningobject
選填

Reasoning settings for the delegated model.

delegation.responses.service_tierstring
選填

Service tier requested for the delegated response.

delegation.responses.textobject
選填

Text output settings for the delegated response.

delegation.responses.tool_choice["string", "object"]
選填

Which delegated tools the backend may use.

delegation.responses.toolsarray
選填

委託調用可使用的託管 Responses 工具。

delegation.responses.tools[].typestring
必填 允許值: web_search, web_search_preview, file_search, computer_use_preview
delegation.toolsarray
選填

當 type 為 client 時,由客戶端持有的 function 工具。

delegation.tools[].typestring
必填
delegation.typestring
選填 允許值: client, responses
modelstring
必填

RunAPI model identifier; Live currently supports gpt-live-1.

sdpstring
必填

Client SDP offer for the WebRTC session.

transportstring
必填

WebRTC session negotiation transport.

請求範例

JSON
{
  "delegation": {
    "responses": {
      "model": "gpt-5.6-terra",
      "tools": [
        {
          "type": "web_search"
        }
      ]
    },
    "type": "responses"
  },
  "model": "gpt-live-1",
  "sdp": "v=0",
  "transport": "webrtc"
}
05

同步回應

HTTP 201

結構描述

JSON
{
  "additionalProperties": true,
  "properties": {
    "session": {
      "additionalProperties": true,
      "type": "object"
    },
    "transport": {
      "additionalProperties": true,
      "type": "object"
    }
  },
  "required": [
    "session",
    "transport"
  ],
  "type": "object"
}

範例

JSON
{
  "session": {
    "id": "live_123"
  },
  "transport": {
    "sdp": "answer",
    "type": "webrtc"
  }
}
06

協定錯誤:invalid_request

HTTP 400

結構描述

JSON
{
  "additionalProperties": true,
  "properties": {
    "error": {
      "additionalProperties": true,
      "properties": {
        "code": {
          "type": [
            "string",
            "null"
          ]
        },
        "message": {
          "type": "string"
        },
        "param": {
          "type": [
            "string",
            "null"
          ]
        },
        "type": {
          "type": "string"
        }
      },
      "required": [
        "message",
        "type"
      ],
      "type": "object"
    }
  },
  "required": [
    "error"
  ],
  "type": "object"
}

範例

JSON
{
  "error": {
    "code": null,
    "message": "Invalid Live session request",
    "param": "sdp",
    "type": "invalid_request_error"
  }
}
07

用量

結構描述

JSON
{
  "additionalProperties": true,
  "properties": {
    "duration_seconds": {
      "type": "number"
    }
  },
  "required": [
    "duration_seconds"
  ],
  "type": "object"
}

範例

JSON
{
  "duration_seconds": 3
}
08

已生成的程式碼範例

每個 cURL、JavaScript 及 Python 範例均透過此合約發送已驗證的請求,無需使用特定協議的 SDK。

安裝

Shell
pip install requests
PYTHON
import requests

response = requests.post(
    "https://runapi.ai/v1/live/webrtc",
    headers={"Authorization": "Bearer YOUR_API_TOKEN", "Content-Type": "application/json"},
    json={"model": "gpt-live-1", "transport": "webrtc", "sdp": "v=0", "delegation": {"type": "responses", "responses": {"model": "gpt-5.6-terra", "tools": [{"type": "web_search"}]}}}
)
response.raise_for_status()
print(response.json())