Skip to main content

Official Python SDK for the Xysera API

Project description

xysera

Official Python SDK for the Xysera API.

Installation

pip install xysera

Requires Python 3.10+ and installs httpx automatically.

Quick start

import xysera

client = xysera.Client("xys_your_api_key_here")
result = client.upscale("https://example.com/video.mp4")
print(result.result_url)       # download before it expires (1 hour)
print(result.credits_charged)  # credits deducted for this job

Endpoints

Upscale a video or image

result = client.upscale(
    "https://example.com/video.mp4",
    scale=4,                            # 2 or 4 (default 4)
    model="RealESRGAN_x4plus",          # see models below
    quality="balanced",
    input_duration_seconds=120.5,       # optional — used for preflight credit estimate
)

print(result.job_id)
print(result.result_url)        # pre-signed URL, valid for 1 hour
print(result.width)
print(result.height)
print(result.size_bytes)
print(result.credits_charged)
print(result.processing_time)
print(result.cold_start_time)
print(result.inference_time)
print(result.status)            # "complete"
print(result.hit_cold_start)    # True if the worker cold-started (cold_start_time > 0)

Available models

Model Best for
RealESRGAN_x4plus (default) General photos and video
RealESRGAN_x2plus 2× upscaling
realesr-animevideov3 Anime / animation

Note: result_url is a pre-signed download URL that expires 1 hour after the job completes. Download the file promptly — calling get_job later will return the same URL, but it may have expired.

Cold starts: When a model worker hasn't been used recently it may need to cold-start before your job runs. result.hit_cold_start is True when this happened. Cold starts are reflected in cold_start_time (seconds) and are included in processing_time.

The upscale endpoint is synchronous — it holds the connection open until the job completes (up to 16 minutes). The SDK sets a 960-second timeout automatically.


Check credits

credits = client.get_credits()
print(credits.credits_balance)  # float
print(credits.key_label)        # str | None — human-readable label for the key

Retrieve a job

job = client.get_job("job_abc123")
print(job.job_id)
print(job.status)           # "complete" or "failed"
print(job.result_url)       # None if failed
print(job.credits_charged)  # None if failed

Async usage

import asyncio
import xysera

async def main():
    async with xysera.AsyncClient("xys_your_api_key_here") as client:
        result = await client.upscale("https://example.com/video.mp4", scale=4)
        print(result.result_url)

        credits = await client.get_credits()
        print(credits.credits_balance)

        job = await client.get_job(result.job_id)
        print(job.status)

asyncio.run(main())

Error handling

import xysera

client = xysera.Client("xys_your_api_key_here")

try:
    result = client.upscale("https://example.com/video.mp4")
except xysera.AuthenticationError:
    print("Invalid or missing API key.")
except xysera.InsufficientCreditsError:
    print("Not enough credits — top up your account.")
except xysera.ValidationError as e:
    print(f"Bad request: {e}")
except xysera.RateLimitError:
    print("Rate limit hit — slow down requests.")
except xysera.JobFailedError:
    print("Processing failed on the server. No credits were charged.")
except xysera.ModelUnavailableError:
    print("The requested model is not yet deployed.")
except xysera.XyseraError as e:
    print(f"Unexpected API error (HTTP {e.status_code}): {e}")

All exceptions inherit from xysera.XyseraError and expose a status_code attribute with the HTTP status code returned by the API.

Exception HTTP status Description
AuthenticationError 401 Invalid or missing API key
InsufficientCreditsError 402 Account has insufficient credits
ValidationError 422 Invalid request parameters
RateLimitError 429 Too many requests
JobFailedError 502 Upstream processing failed; no credits charged
ModelUnavailableError 503 Model not yet deployed

Rate limits

Endpoint Limit
POST /upscale 5 req / min
GET /credits 60 req / min
GET /jobs/{job_id} 60 req / min

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xysera-0.1.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xysera-0.1.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file xysera-0.1.0.tar.gz.

File metadata

  • Download URL: xysera-0.1.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for xysera-0.1.0.tar.gz
Algorithm Hash digest
SHA256 845eade186663793c6663994ab7f9d7f70314073fb1b5c41d31e0ed1508b9127
MD5 d629affa12d5d0ab8ae51eb24639b991
BLAKE2b-256 95f672e5f81a8623e29f594638577bc0bd4e2537664fe78a8ad7d0f399572959

See more details on using hashes here.

File details

Details for the file xysera-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: xysera-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for xysera-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f1fa50f885174f02ab2a6f8e38c8878d5989f93f8a523a198ee46fd21bb0ecc
MD5 78e731ce094d38d988d1e8dcb4db9c49
BLAKE2b-256 9318a1b94040d2fc80976c7580b396cf66e0d7aa170512dac5c038f03de051a5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page