sophon-sdk
Official Python SDK for the SOPHON Encoding API.
This repository is generated from Liqhtworks/sophon-api. The curated
README.md and examples/ directory are preserved across SDK regeneration.
Install
pip install sophon-sdk
Requires Python 3.9+.
Get an API key
- Sign in at https://liqhtworks.xyz/account/general.
- In API keys, create a key for your server-side integration.
- Copy the
xt_live_...token when it is shown. It is only shown once. - Store it as an environment variable:
export SOPHON_API_KEY=xt_live_...
export SOPHON_BASE_URL=https://api.liqhtworks.xyz
Keep API keys on the server. Do not ship them in client apps, public repos, logs, or analytics events.
Quick Start
This is the smallest complete server-side flow: upload a local video, create an encode job, wait for completion, and download the MP4 output.
import os
import urllib.parse
import urllib.request
import uuid
from pathlib import Path
import sophon_sdk
from sophon_sdk.models.create_job_request import CreateJobRequest
api_key = os.environ["SOPHON_API_KEY"]
base_url = os.getenv("SOPHON_BASE_URL", "https://api.liqhtworks.xyz")
input_path = Path("source.mov")
mime_type = "video/quicktime" if input_path.suffix == ".mov" else "video/mp4"
class NoRedirectHandler(urllib.request.HTTPRedirectHandler):
def http_error_302(self, req, fp, code, msg, headers):
response = urllib.request.addinfourl(fp, headers, req.get_full_url())
response.code = code
return response
http_error_301 = http_error_303 = http_error_307 = http_error_302
configuration = sophon_sdk.Configuration(
host=base_url,
access_token=api_key,
)
with sophon_sdk.ApiClient(configuration) as api_client:
uploads = sophon_sdk.UploadsApi(api_client)
jobs = sophon_sdk.JobsApi(api_client)
result = sophon_sdk.upload_file(
uploads,
input_path,
file_name=input_path.name,
mime_type=mime_type,
concurrency=4,
)
job = sophon_sdk.create_job(
jobs,
idempotency_key=str(uuid.uuid4()),
create_job_request=CreateJobRequest(
source=sophon_sdk.JobSource.upload(result.upload_id),
profile="sophon-espresso",
),
)
final = sophon_sdk.wait_for_job(
jobs,
job.id,
timeout_seconds=30 * 60,
)
if final.status != "completed":
raise RuntimeError(f"job ended in {final.status}")
req = urllib.request.Request(
f"{base_url}/v1/jobs/{final.id}/output",
headers={"Authorization": f"Bearer {api_key}"},
method="GET",
)
opener = urllib.request.build_opener(NoRedirectHandler())
redirect = opener.open(req)
location = redirect.headers.get("Location")
if not location:
raise RuntimeError("missing output redirect")
download_url = urllib.parse.urljoin(base_url.rstrip("/") + "/", location)
with urllib.request.urlopen(download_url, timeout=60) as download:
Path("sophon-output.mp4").write_bytes(download.read())
print(f"wrote sophon-output.mp4 from {final.id}")
For a runnable copy of this flow, see
examples/encode_file.py.
Profile choice
Use sophon-auto for production unless you need deterministic encoder
settings. The quickstart uses sophon-espresso because it is the fastest
smoke-test profile and always produces a new encoded output.
Upload Input Forms
upload_file accepts all common server-side input forms:
from io import BytesIO
from pathlib import Path
# 1. Path-like input.
sophon_sdk.upload_file(
uploads,
Path("source.mov"),
file_name="source.mov",
mime_type="video/quicktime",
)
# 2. Bytes input.
data = Path("source.mov").read_bytes()
sophon_sdk.upload_file(
uploads,
data,
file_name="source.mov",
mime_type="video/quicktime",
)
# 3. Binary file-like input. The object must support seek().
with open("source.mov", "rb") as fh:
sophon_sdk.upload_file(
uploads,
fh,
file_name="source.mov",
mime_type="video/quicktime",
)
# BytesIO works too.
buf = BytesIO(data)
sophon_sdk.upload_file(
uploads,
buf,
file_name="source.mov",
mime_type="video/quicktime",
)
Webhooks
Use verify_webhook_signature with the raw request body before JSON parsing.
See examples/webhook-server for a FastAPI route
that reads the raw body, verifies X-Turbo-Signature-256, and only then parses
JSON.
Helpers
| Helper | Purpose |
|---|---|
upload_file |
Chunked upload orchestration with bounded concurrency, retries, resume, and progress callbacks. |
wait_for_job |
Poll until terminal status with timeout and typed errors. |
verify_webhook_signature |
Constant-time HMAC verification plus replay-window enforcement. |
API Docs
Generated endpoint/model docs live under docs/.
Versioning
sophon-sdk follows SemVer, with one pre-1.0
caveat: while we are at v0.x, minor bumps may include breaking
changes. Pin a compatible range until 1.0:
pip install "sophon-sdk~=0.1"
# or in pyproject.toml: "sophon-sdk>=0.1,<0.2"
Patch releases (0.1.x) are always backward-compatible — they ship bug
fixes, helper-layer improvements, and additive types. Once we cut
v1.0.0, regular SemVer applies and breaking changes only land on
major bumps. See CHANGELOG.md for the per-release
log.
License
Proprietary. See LICENSE.
Metadata
Release files for sophon-sdk 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sophon_sdk-0.1.5.tar.gz | 77.4 kB | With provenance | Details for sophon_sdk-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sophon_sdk-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for sophon_sdk-0.1.5-py3-none-any.whl |
Total release size: 261.2 kB
Release files / sophon_sdk-0.1.5.tar.gz
| Download URL | sophon_sdk-0.1.5.tar.gz |
|---|---|
| Size | 77.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
597777d7bcf47ce69e7a17fa16d64f193e21dd4e04d8ef45014bc12d4dbcd922
|
|
BLAKE2b-256 checksum How to use checksums |
5d5cc700c3a6d27c0ff90f771c17c91aa5385d5da176411940662cfb32cd4411
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 8, 2026.
Transparency logRelease files / sophon_sdk-0.1.5-py3-none-any.whl
| Download URL | sophon_sdk-0.1.5-py3-none-any.whl |
|---|---|
| Size | 183.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eaf32462a2973c8848245bb46aee8cb4faa839127e5db48a8ffc913d1aa64045
|
|
BLAKE2b-256 checksum How to use checksums |
c2d7e045752699e73df878f4b072b8cd28e400ce13f37b324c2bc20714fd9648
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 8, 2026.
Transparency logSecurity for sophon-sdk 0.1.5
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for sophon_sdk-0.1.5.tar.gz
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 May 8, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.