A lightweight async Python client for the Yetter image generation API. It supports simple one-shot runs, subscription-style polling, and server-sent events (SSE) streaming.
pip install yetterIf the package is not yet published to PyPI, install from the repository:
pip install "yetter @ git+https://github.com/SqueezeBits/yetter-client"Provide your API key in one of the following ways:
- Environment variable (preferred):
export YTR_API_KEY="YOUR_API_KEY"- Programmatically via
configure:
import asyncio
import yetter
async def main():
yetter.configure(api_key="YOUR_API_KEY")
# Optionally override endpoint:
# yetter.configure(api_key="YOUR_API_KEY", api_endpoint="https://api.yetter.ai")
asyncio.run(main())Use yetter.run() for a convenient "submit + wait for completion" flow powered by streaming under the hood.
import asyncio
import yetter
async def main():
yetter.configure(api_key="YOUR_API_KEY")
result = await yetter.run(
"ytr-ai/qwen/image/t2i",
args={"prompt": "A beautiful landscape with a river and mountains"},
)
# result is dict('images':..., 'prompt':...)
print(result)
asyncio.run(main())yetter.subscribe() submits a request and polls status until completion. You can pass a callback to receive queue/status updates.
import asyncio
import yetter
from yetter.types import GetStatusResponse
async def on_update(status: GetStatusResponse):
print("status:", status.status)
async def main():
yetter.configure(api_key="YOUR_API_KEY")
result = await yetter.subscribe(
"ytr-ai/qwen/image/t2i",
args={
"prompt": "A beautiful landscape with a river and mountains",
"num_images": 2,
},
on_queue_update=on_update,
)
print("final images:", result.images)
asyncio.run(main())Upload files to Yetter using presigned URLs. Supports both single-part upload for small files and automatic multipart upload for large files.
import asyncio
import yetter
async def main():
yetter.configure(api_key="YOUR_API_KEY")
# Simple upload
result = await yetter.upload_file("./my_image.jpg")
print(f"Uploaded: {result.url}")
# Upload with progress tracking
def on_progress(percent: int):
print(f"Upload progress: {percent}%")
result = await yetter.upload_file(
"./large_file.png",
on_progress=on_progress,
)
print(f"Uploaded: {result.url}")
asyncio.run(main())The upload_file function returns an UploadCompleteResponse containing:
url: Public URL to access the uploaded filekey: S3 object key for referencemetadata: Optional metadata (size, content_type, uploaded_at)
See the examples/ directory:
examples/run.py: minimal one-shot runexamples/subscribe.py: subscription with updates