Skip to main content

Hudsonly AI Python SDK

Official Python SDK for the Hudsonly AI API — Text-to-Speech, Speech-to-Text, Text Embeddings, and Avatar Video Generation.

Installation

pip install hudsonly

Quick Start

from hudsonly import HudsonlyAI

client = HudsonlyAI(api_key="your-api-token")

# Text to Speech
result = client.tts.generate(text="Hello world", voice="af_heart")
print(result.audio_url)

# Speech to Text
result = client.transcription.generate(audio="recording.mp3")
print(result.text)

# Text Embeddings
result = client.embeddings.generate(texts=["Hello", "World"])
print(result.embeddings)

# Avatar Video (auto-polls until complete)
result = client.avatar.generate(
    image="photo.jpg",
    audio="speech.mp3",
    model="sadtalker",
)
print(result.video_url)

Services

Text to Speech

Convert text to natural-sounding speech.

result = client.tts.generate(
    text="Hello world",
    voice="af_heart",    # Voice identifier
    format="mp3",        # "mp3" or "wav"
    speed=1.0,           # 0.5 to 2.0
)
print(result.audio_url)
print(result.duration_seconds)

Speech to Text (Transcription)

Transcribe audio files to text with timestamps.

# From a local file
result = client.transcription.generate(
    audio="recording.mp3",
    model="base",        # "tiny", "base", "small", "medium"
    language="en",       # Optional, auto-detected if omitted
)
print(result.text)

for segment in result.segments:
    print(f"[{segment.start:.1f}s - {segment.end:.1f}s] {segment.text}")

# From a URL
result = client.transcription.generate(
    audio_url="https://example.com/audio.mp3",
)

Text Embeddings

Generate vector embeddings for text.

result = client.embeddings.generate(texts=["Hello", "World"])
print(result.embeddings)   # [[0.1, 0.2, ...], [0.3, 0.4, ...]]
print(result.dimension)    # 1024
print(result.model)        # "bge-m3"

Avatar Video Generation

Generate animated portrait videos. This is an async service — generate() submits the task and polls until complete.

# Auto-poll (recommended)
result = client.avatar.generate(
    image="photo.jpg",
    audio="speech.mp3",
    model="sadtalker",       # "sadtalker" or "liveportrait"
    poll_interval=5,         # Seconds between polls
    timeout=600,             # Max wait time
)
print(result.video_url)

# Manual polling
task = client.avatar.create(image="photo.jpg", audio="speech.mp3")
print(task.id, task.status)  # "pending"

# Poll manually
task = client.tasks.get(task.id)
if task.is_completed:
    print(task.output["video_url"])

LivePortrait (video-driven):

result = client.avatar.generate(
    image="photo.jpg",
    video="driving_video.mp4",
    model="liveportrait",
    flag_stitching=True,
    flag_relative_motion=True,
)

Resources

Tasks

List and retrieve async tasks.

# List tasks
tasks = client.tasks.list(service="avatar", status="completed")
for task in tasks.data:
    print(task.id, task.status)

# Get a specific task
task = client.tasks.get("task-uuid")
print(task.output)

Credits

Check balance and transaction history.

# Get balance
balance = client.credits.balance()
print(balance.balance)

# Transaction history
history = client.credits.history(type="usage", per_page=50)
for txn in history.data:
    print(txn.amount, txn.description)

Other Methods

# List available services
services = client.services()
for svc in services:
    print(svc.slug, svc.name, svc.min_credits)

# Check rate limits
limits = client.rate_limits()
for limit in limits:
    print(f"{limit.service}: {limit.remaining}/{limit.limit}")

Error Handling

from hudsonly import (
    HudsonlyAI,
    AuthenticationError,
    InsufficientCreditsError,
    RateLimitError,
    ValidationError,
    TaskError,
    TaskTimeoutError,
)

client = HudsonlyAI(api_key="your-token")

try:
    result = client.tts.generate(text="Hello")
except AuthenticationError:
    print("Invalid API key")
except InsufficientCreditsError:
    print("Not enough credits")
except RateLimitError as e:
    print(f"Rate limited, retry after {e.retry_after}s")
except ValidationError as e:
    print(f"Validation failed: {e.errors}")
except TaskError as e:
    print(f"Task {e.task_id} failed: {e}")
except TaskTimeoutError:
    print("Task polling timed out")

Context Manager

with HudsonlyAI(api_key="your-token") as client:
    result = client.tts.generate(text="Hello")

Requirements

  • Python 3.9+
  • httpx (installed automatically)

License

MIT

Metadata

Release files for hudsonly-ai 0.1.0

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

Source distribution (sdist)

Source distribution for hudsonly-ai 0.1.0
File Size Uploaded Provenance Actions
hudsonly_ai-0.1.0.tar.gz 14.7 kB Without provenance Details for hudsonly_ai-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hudsonly-ai 0.1.0
File Interpreter ABI Platform Actions
hudsonly_ai-0.1.0-py3-none-any.whl Python 3 none any Details for hudsonly_ai-0.1.0-py3-none-any.whl

Total release size: 30.4 kB

Release files / hudsonly_ai-0.1.0.tar.gz

Download URL hudsonly_ai-0.1.0.tar.gz
Size 14.7 kB
Tags Source
SHA-256 checksum
How to use checksums
073cb4c03fd727c04ce60d8aae31c34e3174acf02f879dac40f383b7787f803a
BLAKE2b-256 checksum
How to use checksums
9d9dc9f4e44a85b92655bf98b6827642ee19b2d8cb3a8d8975a576c4d63be099
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.16

Release files / hudsonly_ai-0.1.0-py3-none-any.whl

Download URL hudsonly_ai-0.1.0-py3-none-any.whl
Size 15.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
37837ef033901c9de68aaaaa93989839c383d4feebfce400809f6ed52644cd73
BLAKE2b-256 checksum
How to use checksums
f08c0b3dae8987665b70d675895a789fe1f743e7d9b896fef7e12940765d5816
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.16

Security for hudsonly-ai 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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