Yetter Python Client
Project description
Yetter Python Client
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.
Installation
pip install yetter
If the package is not yet published to PyPI, install from the repository:
pip install "yetter @ git+https://github.com/SqueezeBits/yetter-client"
Authentication & Configuration
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())
Quick start: one-shot run
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())
Subscribe: polling with optional queue updates
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())
File Upload
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)
Examples
See the examples/ directory:
examples/run.py: minimal one-shot runexamples/subscribe.py: subscription with updates
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yetter-0.0.4.tar.gz.
File metadata
- Download URL: yetter-0.0.4.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
831ef5b1f1df5d2abbc017594a47ab6c2a4c077681eb03ba21b1fb8508495211
|
|
| MD5 |
62ad6c56cd154bf7726c570929c85dd0
|
|
| BLAKE2b-256 |
11a050d8f96e5adc79e2fac562c7afda60340037b7c07df6f45e3e3464699e0d
|
File details
Details for the file yetter-0.0.4-py3-none-any.whl.
File metadata
- Download URL: yetter-0.0.4-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f924a7c1295d498de37175996615de73e3d9e7577bd47e595acdb5a00c1e1f4d
|
|
| MD5 |
fdab37566d0cba7cfb9b5d3d957b1049
|
|
| BLAKE2b-256 |
83a908401df6ecdde707e3ea23ce49d3f7a2f12e9a32f410198d5c960b08d620
|