Skip to content

Realtime comms

Realtime audio/video rooms, per-participant access tokens, server-side recording and participant management across LiveKit / Agora / Zego.

Overview

Base path: https://api.infrai.cc/v1/rtc
Auth header: Authorization: Bearer $INFRAI_API_KEY
bash
# Call any /v1/rtc capability over raw HTTP — no SDK to install.
# curl:
curl https://api.infrai.cc/v1/rtc/... \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json"

Methods

rtc.room.create

POST /v1/rtc/room/create

Create a live audio/video room on the selected RTC vendor. Some vendors (Agora/Zego) have no persistent room object — the room materializes on first join and the record is synthesized.

Parameters

NameTypeRequiredDescription
namestring
Required
Room name (unique per account).
max_participantsnumberOptionalMaximum concurrent participants.
empty_timeout_snumberOptionalAuto-close after this many seconds empty.
metadataRecord<string, unknown>OptionalArbitrary key/value metadata.
enable_recordingbooleanOptionalEnable recording for the room.
regionstringOptionalEdge region to host the room.
vendorstringOptionalExplicit vendor pin.
idempotency_keystringOptionalClient-supplied key to make the call idempotent.

Returns

Room { room, name, max_participants, created_at }

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/rtc/room/create \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "..."}'

rtc.room.get

GET /v1/rtc/room/get/{room}

Fetch a single RTC room's state and live occupancy.

Parameters

NameTypeRequiredDescription
roomstring
Required
The room id.

Returns

Room

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X GET https://api.infrai.cc/v1/rtc/room/get/ROOM \
  -H "Authorization: Bearer $INFRAI_API_KEY"

rtc.room.list

GET /v1/rtc/room/list

List active RTC rooms / channels for the account.

Parameters

NameTypeRequiredDescription
cursorstringOptionalOpaque pagination cursor.
limitnumberOptionalMaximum number of items to return.

Returns

{ items: Room[], next_cursor?: string }

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X GET https://api.infrai.cc/v1/rtc/room/list \
  -H "Authorization: Bearer $INFRAI_API_KEY"

rtc.room.delete

DELETE /v1/rtc/room/delete/{room}

Close an RTC room (vendors without a delete API auto-close when empty).

Parameters

NameTypeRequiredDescription
roomstring
Required
The room id.

Returns

{ ok: boolean }

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X DELETE https://api.infrai.cc/v1/rtc/room/delete/ROOM \
  -H "Authorization: Bearer $INFRAI_API_KEY"

rtc.token.issue

POST /v1/rtc/token/issue

Mint a per-participant join token (vendor-native JWT/AccessToken2/token04, signed locally). Billed per participant-minute conceptually; bandwidth/egress floored at cost.

Parameters

NameTypeRequiredDescription
roomstring
Required
The room id.
identitystring
Required
Unique per-participant identity / uid.
display_namestringOptionalHuman-readable participant name.
ttl_snumberOptionalToken time-to-live in seconds.
can_publishbooleanOptionalAllow the participant to publish media.
can_subscribebooleanOptionalAllow the participant to subscribe to media.
can_publish_databooleanOptionalAllow the participant to publish data messages.
is_adminbooleanOptionalGrant the participant admin privileges.
vendorstringOptionalExplicit vendor pin.
metadataRecord<string, unknown>OptionalArbitrary key/value metadata.

Returns

AccessToken { token, room, identity, expires_at }

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/rtc/token/issue \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"room": "...", "identity": "..."}'

rtc.recording.start

POST /v1/rtc/recording/start

Start a server-side composite recording of a room (LiveKit Egress); other vendors return an honest unsupported error.

Parameters

NameTypeRequiredDescription
roomstring
Required
The room id.
layoutstringOptionalRecording composition layout.
audio_onlybooleanOptionalRecord audio only.
output_uristringOptionalStorage destination (s3://, gs://, ...).
vendorstringOptionalExplicit vendor pin.
metadataRecord<string, unknown>OptionalArbitrary key/value metadata.
idempotency_keystringOptionalClient-supplied key to make the call idempotent.

Returns

Recording { recording, room, status }

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/rtc/recording/start \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"room": "..."}'

rtc.recording.stop

POST /v1/rtc/recording/stop/{recording}

Stop an in-progress recording.

Parameters

NameTypeRequiredDescription
recordingstring
Required
The recording id.

Returns

Recording { recording, status, output_uri? }

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/rtc/recording/stop/RECORDING \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

rtc.participant.list

GET /v1/rtc/participant/list/{room}

List participants currently in a room.

Parameters

NameTypeRequiredDescription
roomstring
Required
The room id.

Returns

{ items: Array<{ identity, display_name?, joined_at }> }

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X GET https://api.infrai.cc/v1/rtc/participant/list/ROOM \
  -H "Authorization: Bearer $INFRAI_API_KEY"

rtc.participant.kick

POST /v1/rtc/participant/kick/{room}

Forcibly remove (kick) a participant from a room.

Parameters

NameTypeRequiredDescription
roomstring
Required
The room id.
identitystring
Required
Unique per-participant identity / uid.
vendorstringOptionalExplicit vendor pin.

Returns

{ ok: boolean }

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/rtc/participant/kick/ROOM \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"room": "...", "identity": "..."}'
Advanced: pin a vendor

By default infrai routes each call to the best available provider — you do not pick a vendor. As an escape hatch, this capability accepts an optional vendor parameter to pin one specific provider. Every live vendor for this capability is available in real time from the discovery endpoint for the capability id — see the discovery API.

GET /v1/discovery/{capability}

rtc.room.create

rtc.token.issue

rtc.recording.start

rtc.participant.kick

All capabilities

Every routed capability in this module — the complete public REST contract. The methods above are the guided walkthrough; this index is the full reference.

CapabilityEndpointDescription
rtc.participant.kickPOST /v1/rtc/participant/kick/{room}Forcibly remove (kick) a participant from a room.
rtc.participant.listGET /v1/rtc/participant/list/{room}List participants currently in a room.
rtc.recording.startPOST /v1/rtc/recording/startStart a server-side composite recording of a room (LiveKit Egress); other vendors return an honest unsupported error.
rtc.recording.stopPOST /v1/rtc/recording/stop/{recording}Stop an in-progress recording.
rtc.room.createPOST /v1/rtc/room/createCreate a live audio/video room on the selected RTC vendor. Some vendors (Agora/Zego) have no persistent room object — the room materializes on first join and the record is synthesized.
rtc.room.deleteDELETE /v1/rtc/room/delete/{room}Close an RTC room (vendors without a delete API auto-close when empty).
rtc.room.getGET /v1/rtc/room/get/{room}Fetch a single RTC room's state and live occupancy.
rtc.room.listGET /v1/rtc/room/listList active RTC rooms / channels for the account.
rtc.token.issuePOST /v1/rtc/token/issueMint a per-participant join token (vendor-native JWT/AccessToken2/token04, signed locally). Billed per participant-minute conceptually; bandwidth/egress floored at cost.

End-to-end example

A production-style walkthrough of this module: configure once, then run the flow. It exercises most of the module's APIs.

A copy-paste-runnable single-file Python program (stdlib only, no SDK): set your INFRAI_API_KEY, run it, and walk this module's core flow with REAL billed calls — later steps reuse real fields returned by earlier ones. The 12-line helper is the entire integration.

python
#!/usr/bin/env python3
"""Infrai · rtc — runnable real-app example (single file, zero deps).

Copy this file, set your key, run it: every step is a REAL call to
api.infrai.cc, billed at the real (tiny) per-call price, printing the
live JSON response. Get a key at https://console.infrai.cc (Google/
GitHub sign-in grants $2 free credit). No SDK — the 12-line helper
below is the entire integration."""
import json
import os
from urllib import error, request

KEY = os.environ.get("INFRAI_API_KEY") or "ifr_pk_proj_..."  # <- your key
BASE = "https://api.infrai.cc"


# Same raw HTTPS POST/GET as every per-method example on this page —
# wrapped once for reuse. There is nothing else to it: no SDK.
def infrai(method, path, body=None):
    req = request.Request(
        BASE + path, method=method,
        data=json.dumps(body).encode() if body is not None else None,
        headers={"Authorization": f"Bearer {KEY}",
                 "Content-Type": "application/json"})
    try:
        with request.urlopen(req, timeout=60) as r:
            return json.loads(r.read())
    except error.HTTPError as e:
        return json.loads(e.read())


def show(label, resp):
    print(f"\n== {label} ==")
    print(json.dumps(resp, indent=2, ensure_ascii=False))
    return resp


# 1) rtc.room.create — POST /v1/rtc/room/create · Create a live audio/video room on the selected RTC vendor. Some vendors (Agora/Zego) have no persistent room object — the room materializes on first join and the record is synthesized.
r1 = show("rtc.room.create", infrai("POST", "/v1/rtc/room/create", {"name":"..."}))

# 2) rtc.token.issue — POST /v1/rtc/token/issue · Mint a per-participant join token (vendor-native JWT/AccessToken2/token04, signed locally). Billed per participant-minute conceptually; bandwidth/egress floored at cost.
r2 = show("rtc.token.issue", infrai("POST", "/v1/rtc/token/issue", {"room":"...","identity":"..."}))

# 3) rtc.recording.start — POST /v1/rtc/recording/start · Start a server-side composite recording of a room (LiveKit Egress); other vendors return an honest unsupported error.
r3 = show("rtc.recording.start", infrai("POST", "/v1/rtc/recording/start", {"room":"..."}))

# 4) rtc.room.list — GET /v1/rtc/room/list · List active RTC rooms / channels for the account.
r4 = show("rtc.room.list", infrai("GET", "/v1/rtc/room/list"))