Vai al contenuto
Riferimento API
Riferimento API

OpenAI Live

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

01

Panoramica

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

Avvio rapido

  1. Crea una Chiave API e impostala come RUNAPI_API_KEY.
  2. Scegli un modello compatibile, quindi invia i parametri di percorso e il corpo JSON documentati.
  3. Leggi la risposta JSON o gli eventi inviati dal server mostrati per questa operazione e gestisci gli errori di protocollo.

Endpoint

POST /v1/live/webrtc
URL di base
https://runapi.ai
Versione del contratto
v1
Autenticazione preferita
Authorization: Bearer YOUR_API_TOKEN
02

Vettori di autenticazione

RunAPI accetta ciascun protocollo elencato di seguito. I campioni generati utilizzano l'header preferito del protocollo.

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

Modelli compatibili

Apri la pagina di un modello per i prezzi correnti, i limiti di frequenza e i dettagli sull'uso commerciale.

Mostra 1 modello compatibile
04

Contratto della richiesta

Corpo JSON

Sono elencati solo i campi con evidenza di supporto sia del protocollo pubblico che di RunAPI. I campi aggiuntivi del corpo JSON vengono trasmessi senza modifiche.

Corpo JSON18 campi
delegation["object", "null"]
Opzionale

Contratto facoltativo di delega client o Responses, nel formato del provider.

delegation.responsesobject
Opzionale

Impostazioni di backend del lavoro delegato quando type è responses.

delegation.responses.instructionsstring
Opzionale

Prompt di backend per il lavoro delegato.

delegation.responses.max_output_tokensinteger
Opzionale

Budget di token di output della risposta delegata; almeno 16.

delegation.responses.modelstring
Obbligatorio

Modello Responses che esegue il lavoro delegato.

delegation.responses.parallel_tool_callsboolean
Opzionale

Allow independent delegated tool calls in one turn.

delegation.responses.reasoningobject
Opzionale

Reasoning settings for the delegated model.

delegation.responses.service_tierstring
Opzionale

Service tier requested for the delegated response.

delegation.responses.textobject
Opzionale

Text output settings for the delegated response.

delegation.responses.tool_choice["string", "object"]
Opzionale

Which delegated tools the backend may use.

delegation.responses.toolsarray
Opzionale

Strumenti Responses ospitati che la chiamata delegata può usare.

delegation.responses.tools[].typestring
Obbligatorio Valori consentiti: web_search, web_search_preview, file_search, computer_use_preview
delegation.toolsarray
Opzionale

Strumenti function di proprietà del client quando type è client.

delegation.tools[].typestring
Obbligatorio
delegation.typestring
Opzionale Valori consentiti: client, responses
modelstring
Obbligatorio

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

sdpstring
Obbligatorio

Client SDP offer for the WebRTC session.

transportstring
Obbligatorio

WebRTC session negotiation transport.

Esempio di richiesta

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

Risposta sincrona

HTTP 201

Schema

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

Esempio

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

Errore di protocollo: 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"
}

Esempio

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

Utilizzo

Schema

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

Esempio

JSON
{
  "duration_seconds": 3
}
08

Esempi di Codice Generati

Ogni esempio cURL, JavaScript e Python invia la richiesta validata di questo contratto senza richiedere un SDK specifico per il protocollo.

Installa

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