تخطَّ إلى المحتوى
مرجع 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

النماذج المتوافقة

افتح صفحة النموذج للاطلاع على التسعير الحالي وحدود المعدل وتفاصيل الاستخدام التجاري.

عرض نموذج متوافق واحد
04

عقد الطلب

نص JSON

تُدرج فقط الحقول التي تتوفر لها أدلة دعم من بروتوكول عام ومن RunAPI. تُمرَّر حقول نص JSON الإضافية كما هي.

جسم JSON15 حقل
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

المخطط

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", "model": "gpt-5.6-terra", "tools": [{"type": "web_search_preview"}]}}
)
response.raise_for_status()
print(response.json())