Przejdź do treści
Dokumentacja API
Dokumentacja API

OpenAI Live

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

01

Omówienie

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

Szybki start

  1. Utwórz klucz API i ustaw go jako RUNAPI_API_KEY.
  2. Wybierz zgodny model, a następnie wyślij udokumentowane parametry ścieżki i treść JSON.
  3. Odczytaj odpowiedź JSON lub zdarzenia wysyłane przez serwer pokazane dla tej operacji i obsłuż błędy protokołu.

Punkt końcowy

POST /v1/live/webrtc
Bazowy URL
https://runapi.ai
Wersja kontraktu
v1
Preferowane uwierzytelnianie
Authorization: Bearer YOUR_API_TOKEN
02

Nośniki uwierzytelniania

RunAPI akceptuje każdy z wymienionych poniżej protokołów. Wygenerowane przykłady używają preferowanego nagłówka danego protokołu.

header - Preferowane
Authorization: Bearer YOUR_API_TOKEN
header
x-api-key: YOUR_API_TOKEN
03

Zgodne modele

Otwórz stronę modelu, aby zapoznać się z aktualnymi cenami, limitami żądań i szczegółami dotyczącymi użytku komercyjnego.

Pokaż 1 kompatybilny model
04

Kontrakt żądania

Treść JSON

Wymieniane są tylko pola mające zarówno publiczną dokumentację protokołu, jak i potwierdzenie obsługi przez RunAPI. Dodatkowe pola treści JSON są przekazywane bez zmian.

Treść JSON15 pola
delegation["object", "null"]
Opcjonalne

Optional client or Responses delegation contract.

delegation.instructionsstring
Opcjonalne

Backend prompt for delegated work when type is responses.

delegation.max_output_tokensinteger
Opcjonalne

Output token budget for the delegated response.

delegation.modelstring
Opcjonalne

Responses model that runs delegated work when type is responses.

delegation.parallel_tool_callsboolean
Opcjonalne

Allow independent delegated tool calls in one turn.

delegation.reasoningobject
Opcjonalne

Reasoning settings for the delegated model.

delegation.service_tierstring
Opcjonalne

Service tier requested for the delegated response.

delegation.textobject
Opcjonalne

Text output settings for the delegated response.

delegation.tool_choice["string", "object"]
Opcjonalne

Which delegated tools the backend may use.

delegation.toolsarray
Opcjonalne

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

delegation.tools[].typestring
Wymagane
delegation.typestring
Opcjonalne Dozwolone wartości: client, responses
modelstring
Wymagane

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

sdpstring
Wymagane

Client SDP offer for the WebRTC session.

transportstring
Wymagane

WebRTC session negotiation transport.

Przykład żądania

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

Odpowiedź synchroniczna

HTTP 201

Schemat

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

Przykład

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

Błąd protokołu: invalid_request

HTTP 400

Schemat

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"
}

Przykład

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

Użycie

Schemat

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

Przykład

JSON
{
  "duration_seconds": 3
}
08

Wygenerowane przykłady kodu

Każdy przykład cURL, JavaScript i Python wysyła zwalidowane żądanie z tej specyfikacji bez konieczności używania SDK właściwego dla protokołu.

Instalacja

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())