Skip to main content

MediaRuntime Python SDK

Official synchronous Python client for the MediaRuntime asynchronous media API.

Status: stable 0.2.1, published on PyPI with GitHub trusted publishing.

Install

pip install mediaruntime

Set MEDIARUNTIME_API_KEY; the production API URL is built in. Pass the server-held key explicitly when you want the credential source to be visible in application code.

import os

from mediaruntime import MediaRuntime

media = MediaRuntime(api_key=os.environ["MEDIARUNTIME_API_KEY"])
job = media.jobs.create(
    source="./video.mp4",
    outputs=["video.web"],
    idempotency_key="video:vid_123:v1",
)

# Polling is convenient for scripts, tests, and first-run verification.
result = job.wait(timeout=300)
bundle_url = result.bundle.get("download_url")
if result.status != "COMPLETED" or not bundle_url:
    raise RuntimeError(f"MediaRuntime job ended with {result.status}")
print(bundle_url)

bundle_url is a short-lived URL for the canonical ZIP containing every requested deliverable. One job can place a video, poster, subtitles, multiple renditions, or a complete HLS directory tree in that bundle; the SDK does not model those files as separate delivery URLs.

In production, persist job.id and complete the workflow from the signed terminal webhook sent to the destination configured under Account → Webhooks. Redeem delivery.bundle.download.url from that event for the same ZIP. A job submission does not supply or override the webhook URL.

MediaRuntime() without arguments is equivalent: it reads MEDIARUNTIME_API_KEY automatically. Never put the key in frontend code or commit its literal value.

Aliases are frozen gateway contracts: video.web, video.streaming, video.social, audio.web, audio.transcription, and image.web. The gateway materializes them before validation, estimation, billing, and persistence. Explicit { "type": ..., "preset": ... } output dictionaries remain supported and may be mixed with aliases.

HTTP(S) and gs:// sources are submitted directly. Other strings and pathlib.Path instances are treated as local files and uploaded through MediaRuntime's signed upload flow.

Batch inputs

Use source on every batch item. Each value accepts the same HTTP(S), gs://, local-path, or pathlib.Path forms as a single job; the SDK uploads local files before submission.

batch = media.jobs.create(
    inputs=[
        {"source": "https://cdn.example.com/a.mp4", "input_id": "asset-a"},
        {"source": "./b.mp4", "input_id": "asset-b", "metadata": {"position": 1}},
    ],
    outputs=["video.web"],
)

Moderation

Enable report-only moderation when creating a visual-media job, then retrieve its result after completion:

job = media.jobs.create(
    source="https://cdn.example.com/photo.jpg",
    outputs=["image.web"],
    moderation={
        "enabled": True,
        "mode": "report",
        "checks": ["sexual", "violence", "dangerous"],
    },
    idempotency_key="image:photo_123:v1",
)

result = job.wait()
moderation = media.jobs.get_moderation(result.id)
print(result.status, moderation.verdict, moderation.flagged_checks)

Verify webhooks

event = media.webhooks.verify(raw_body, request.headers)
print(event.id, event.job_id, event.status)

media.webhooks.flask(handler), fastapi(handler), and django(handler) provide optional framework adapters without making those frameworks package dependencies. Persist and deduplicate event.id in your own datastore before acknowledging a delivery.

See the software design document for boundaries, retry safety, security behavior, compatibility, and release gates.

Metadata

Release files for mediaruntime 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mediaruntime 0.2.2
File Size Uploaded
mediaruntime-0.2.2.tar.gz 33.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mediaruntime 0.2.2
File Interpreter ABI Platform
mediaruntime-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 51.0 kB

Release files / mediaruntime-0.2.2.tar.gz

Download URL mediaruntime-0.2.2.tar.gz
Size 33.0 kB
Tags Source
SHA-256 checksum
How to use checksums
fb4fa1a16542e315974312c51beaf221ecea430a0061ec2d3aa571f0e0d7ac0e
BLAKE2b-256 checksum
How to use checksums
6822bc665c840607230d296800c2d6681d401b39bf860cd33f41bb103a0a0116
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release files / mediaruntime-0.2.2-py3-none-any.whl

Download URL mediaruntime-0.2.2-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa7a875a159e795f4f6c35d88265895cfe7ecc3c86224ecc44ca67025202ba4e
BLAKE2b-256 checksum
How to use checksums
a225ab67c01ef40b28b7a64508bf5745f0c3e454d3565c9cc9e066a5297045fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release history Release notifications | RSS feed

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page