Skip to content
StatusSupportDashboard

Add frame

streams.add_frame(strnamespace, StreamAddFrameParams**kwargs) -> StreamAddFrameResponse
POST/v1/streams/{namespace}/frames

Ingest a single livestream frame as an image data URI plus relative timestamp in milliseconds. The stream does not need to be created beforehand. Only image/jpeg, image/png, and image/webp are accepted. The decoded bytes must match the declared mime type, decode as a valid image, stay within 5 MB, and stay within 4096x4096 / 16,000,000 total pixels. Timestamps are relative milliseconds from stream start and must be unique and strictly increasing within a stream. Duplicate or out-of-order frame timestamps are accepted at the API boundary but ignored by downstream processing. This method returns immediately after the frame has been accepted for processing.

ParametersExpand Collapse
namespace: str

The namespace to ingest stream data into

image_data_uri: str

A data URI containing a base64-encoded frame image. Only image/jpeg, image/png, and image/webp are accepted. The decoded bytes must match the declared mime type, decode as a valid image, stay within 5 MB, and stay within 4096x4096 / 16,000,000 total pixels.

stream_id: str
timestamp: int
minimum0
ReturnsExpand Collapse
class StreamAddFrameResponse:

Stream ingestion request accepted for asynchronous processing.

request_id: str
status: Literal["accepted"]

Add frame

import os
from safetykit import Safetykit

client = Safetykit(
    api_key=os.environ.get("SAFETYKIT_API_KEY"),  # This is the default and can be omitted
)
response = client.streams.add_frame(
    namespace="namespace",
    image_data_uri="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoQABAAPm02mUmkIyIh...",
    stream_id="YOUR_STREAM_ID",
    timestamp=1000,
)
print(response.request_id)
{
  "requestId": "req_01h2m7qdmdjckc30e1mnq6xqfd",
  "status": "accepted"
}
Returns Examples
{
  "requestId": "req_01h2m7qdmdjckc30e1mnq6xqfd",
  "status": "accepted"
}