OpenAI Live
通过 RunAPI 的 OpenAI 兼容 Live operation 发送请求。
概览
使用兼容模型和对应协议的请求、响应结构调用 RunAPI 的 OpenAI 兼容 Live operation。
快速开始
- 创建 API Key,并将其设置为 RUNAPI_API_KEY。
- 选择兼容模型,然后发送文档所列的路径参数和 JSON 请求体。
- 读取此 operation 展示的 JSON 响应或服务器发送事件,并处理协议错误。
端点
- 基础 URL
https://runapi.ai- Contract 版本
v1- 首选身份验证
Authorization: Bearer YOUR_API_TOKEN
身份验证载体
RunAPI 接受下列每种载体;生成的示例使用该协议的首选请求头。
- header - 首选
Authorization: Bearer YOUR_API_TOKEN- header
x-api-key: YOUR_API_TOKEN
兼容模型
打开模型页可查看当前价格、限流和商业使用详情。
展开 1 个兼容模型
请求 Contract
这里只列出同时具有公共协议与 RunAPI 支持证据的字段;其他 JSON 请求体字段会原样传递。
JSON 请求体15 个字段
delegation["object", "null"]Optional client or Responses delegation contract.
delegation.instructionsstringBackend prompt for delegated work when type is responses.
delegation.max_output_tokensintegerOutput token budget for the delegated response.
delegation.modelstringResponses model that runs delegated work when type is responses.
delegation.parallel_tool_callsbooleanAllow independent delegated tool calls in one turn.
delegation.reasoningobjectReasoning settings for the delegated model.
delegation.service_tierstringService tier requested for the delegated response.
delegation.textobjectText output settings for the delegated response.
delegation.tool_choice["string", "object"]Which delegated tools the backend may use.
delegation.toolsarrayHosted Responses tools, or client-owned function tools when type is client.
delegation.tools[].typestringdelegation.typestringclient, responses
modelstringRunAPI model identifier; Live currently supports gpt-live-1.
sdpstringClient SDP offer for the WebRTC session.
transportstringWebRTC session negotiation transport.
请求示例
{
"delegation": {
"model": "gpt-5.6-terra",
"tools": [
{
"type": "web_search_preview"
}
],
"type": "responses"
},
"model": "gpt-live-1",
"sdp": "v=0",
"transport": "webrtc"
}
同步响应
Schema
{
"additionalProperties": true,
"properties": {
"session": {
"additionalProperties": true,
"type": "object"
},
"transport": {
"additionalProperties": true,
"type": "object"
}
},
"required": [
"session",
"transport"
],
"type": "object"
}
示例
{
"session": {
"id": "live_123"
},
"transport": {
"sdp": "answer",
"type": "webrtc"
}
}
协议错误:invalid_request
Schema
{
"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"
}
示例
{
"error": {
"code": null,
"message": "Invalid Live session request",
"param": "sdp",
"type": "invalid_request_error"
}
}
Usage
Schema
{
"additionalProperties": true,
"properties": {
"duration_seconds": {
"type": "number"
}
},
"required": [
"duration_seconds"
],
"type": "object"
}
示例
{
"duration_seconds": 3
}
生成的代码示例
每个 cURL、JavaScript 和 Python 示例都会发送此 Contract 中经过验证的请求,无需协议专用 SDK。
安装
pip install requests
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())