跳到正文
API 参考
API 参考

OpenAI Live

通过 RunAPI 的 OpenAI 兼容 Live operation 发送请求。

01

概览

使用兼容模型和对应协议的请求、响应结构调用 RunAPI 的 OpenAI 兼容 Live operation。

快速开始

  1. 创建 API Key,并将其设置为 RUNAPI_API_KEY。
  2. 选择兼容模型,然后发送文档所列的路径参数和 JSON 请求体。
  3. 读取此 operation 展示的 JSON 响应或服务器发送事件,并处理协议错误。

端点

POST /v1/live/webrtc
基础 URL
https://runapi.ai
Contract 版本
v1
首选身份验证
Authorization: Bearer YOUR_API_TOKEN
02

身份验证载体

RunAPI 接受下列每种载体;生成的示例使用该协议的首选请求头。

header - 首选
Authorization: Bearer YOUR_API_TOKEN
header
x-api-key: YOUR_API_TOKEN
03

兼容模型

打开模型页可查看当前价格、限流和商业使用详情。

展开 1 个兼容模型
04

请求 Contract

JSON 请求体

这里只列出同时具有公共协议与 RunAPI 支持证据的字段;其他 JSON 请求体字段会原样传递。

JSON 请求体15 个字段
delegation["object", "null"]
可选

Optional client or Responses delegation contract.

delegation.instructionsstring
可选

Backend prompt for delegated work when type is responses.

delegation.max_output_tokensinteger
可选

Output token budget for the delegated response.

delegation.modelstring
可选

Responses model that runs delegated work when type is responses.

delegation.parallel_tool_callsboolean
可选

Allow independent delegated tool calls in one turn.

delegation.reasoningobject
可选

Reasoning settings for the delegated model.

delegation.service_tierstring
可选

Service tier requested for the delegated response.

delegation.textobject
可选

Text output settings for the delegated response.

delegation.tool_choice["string", "object"]
可选

Which delegated tools the backend may use.

delegation.toolsarray
可选

Hosted Responses tools, or client-owned function tools when type is client.

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": {
    "model": "gpt-5.6-terra",
    "tools": [
      {
        "type": "web_search_preview"
      }
    ],
    "type": "responses"
  },
  "model": "gpt-live-1",
  "sdp": "v=0",
  "transport": "webrtc"
}
05

同步响应

HTTP 201

Schema

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

Schema

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

Usage

Schema

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

示例

JSON
{
  "duration_seconds": 3
}
08

生成的代码示例

每个 cURL、JavaScript 和 Python 示例都会发送此 Contract 中经过验证的请求,无需协议专用 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", "model": "gpt-5.6-terra", "tools": [{"type": "web_search_preview"}]}}
)
response.raise_for_status()
print(response.json())