-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
58 lines (49 loc) · 2.1 KB
/
example.py
File metadata and controls
58 lines (49 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""
Xysera SDK — quick-start example.
1. Install: pip install xysera
2. Set your API key:
export XYSERA_API_KEY="xys_..."
or replace os.environ["XYSERA_API_KEY"] below with your key string.
3. Run: python example.py
"""
import os
import xysera
# ---------------------------------------------------------------------------
# Configuration — edit these two values before running
# ---------------------------------------------------------------------------
API_KEY = os.environ.get("XYSERA_API_KEY", "xys_your_api_key_here")
INPUT_URL = "https://www.w3schools.com/html/mov_bbb.mp4"
# ---------------------------------------------------------------------------
client = xysera.Client(API_KEY)
# Check your credit balance
credits = client.get_credits()
print(f"Credits remaining: {credits.credits_balance} (key: {credits.key_label})")
# Upscale a video or image
# scale=4 and model="RealESRGAN_x4plus" are the defaults — shown here explicitly
print("\nSubmitting upscale job (this may take a few minutes)...")
try:
result = client.upscale(
INPUT_URL,
scale=4,
model="RealESRGAN_x4plus",
)
except xysera.AuthenticationError:
raise SystemExit("Invalid API key — check your XYSERA_API_KEY.")
except xysera.InsufficientCreditsError:
raise SystemExit("Not enough credits — top up at xysera.com.")
except xysera.JobFailedError:
raise SystemExit("Processing failed — no credits were charged. Try again.")
except xysera.ModelUnavailableError:
raise SystemExit("Model is not yet available. Try RealESRGAN_x4plus.")
except xysera.XyseraError as e:
raise SystemExit(f"API error (HTTP {e.status_code}): {e}")
print("Done!")
print(f" job_id: {result.job_id}")
print(f" credits_charged: {result.credits_charged}")
print(f" processing_time: {result.processing_time}s")
if result.hit_cold_start:
print(f" cold_start_time: {result.cold_start_time}s (endpoint was cold — not billed)")
print(f" result_url: {result.result_url} (valid for 1 hour)")
# Download the result to disk
output_path = result.download("output.mp4")
print(f"\nSaved to: {output_path}")