Skip to main content

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 file
  • key: S3 object key for reference
  • metadata: Optional metadata (size, content_type, uploaded_at)

Examples

See the examples/ directory:

  • examples/run.py: minimal one-shot run
  • examples/subscribe.py: subscription with updates

Development Notes

When contributing to this repository, use TDD by default:

  • add or update a failing test first
  • implement the smallest change that makes it pass
  • refactor only after the test suite is green again

Recommended local test command:

uv run --extra dev pytest -q

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

yetter-0.0.5.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

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

yetter-0.0.5-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file yetter-0.0.5.tar.gz.

File metadata

  • Download URL: yetter-0.0.5.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for yetter-0.0.5.tar.gz
Algorithm Hash digest
SHA256 20d860db78b4c9869c0cadb81f6b728e06168ac9b790980f635ecb5c1cfd0bc2
MD5 b8173aee6baf45dfe719c88f5cbda265
BLAKE2b-256 d1840197f7ec70a520207ba497907ea2c1dd1b1d802014d7eaa5f992ba0adba6

See more details on using hashes here.

File details

Details for the file yetter-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: yetter-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for yetter-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 798fec7eaf582f545ed1eca43f415334485e0301132bfd01fb028fa99475c18d
MD5 666b3900cbc4168f728c625b5f57d7d0
BLAKE2b-256 a1c034e33060207f569bc4b8109fbd4e46f8e4549da430ac73361f6dc77aad7c

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