Skip to main content

Official Python SDK for the ThankYou unified creative generation API.

Project description

ThankYou Python SDK

Official Python SDK for the ThankYou unified creative generation API.

pip install thankyouai

Create a Client

from thankyou import ThankYou

thankyou = ThankYou(api_key="tk_...")

The default base URL is https://api.thankyouai.com/open/v1.

Text to Image

result = await thankyou.run(
    model="flux/v2/pro/text-to-image",
    input={
        "prompt": "A mountain landscape at golden hour",
        "aspect_ratio": "16:9",
    },
)

print(result.output[0]["url"])

Image to Video with an Uploaded File

file = await thankyou.files.upload(file="./photo.jpg")

generation = await thankyou.generations.create(
    model="wan/v2.6/image-to-video",
    input={
        "prompt": "Gentle camera movement with soft evening light",
        "reference_assets": [{"url": file.url}],
    },
)

result = await thankyou.generations.wait(
    generation.id,
    interval=3.0,
    timeout=10 * 60,
)

Quote Before Execute

Use a quote when you want to estimate the cost and check whether a request can run before starting the generation. A quote returns the resolved input, estimated cost, blocking reasons, and an expiration time.

quote = await thankyou.generations.quote(
    model="wan/v2.6/text-to-video",
    input={"prompt": "A koi fish swimming", "duration": 5},
)

if quote.blocking_reasons:
    raise RuntimeError(", ".join(quote.blocking_reasons))

print(quote.estimated_cost, quote.currency, quote.expires_at)

generation = await thankyou.generations.create(quote_id=quote.quote_id)

Models

models = await thankyou.models.list()
detail = await thankyou.models.detail("wan/v2.6/text-to-video")

print(len(models.models))
print(detail.input_schema)

Model IDs can contain /, so models.detail() calls GET /models/detail?model_id=....

Webhook Verification

event = thankyou.webhooks.verify(
    raw_body=raw_body,
    signature=request.headers["x-thankyou-signature"],
    timestamp=request.headers["x-thankyou-timestamp"],
    secret="whsec_...",
)

if event.event == "generation.completed":
    print(event.generation.output[0]["url"] if event.generation else None)

The signature is HMAC-SHA256 over {timestamp}.{raw_body} and is formatted as sha256=<hex>.

Error Handling

from thankyou import (
    ThankYouAPIError,
    ThankYouAuthenticationError,
    ThankYouRateLimitError,
    ThankYouValidationError,
)

try:
    await thankyou.generations.create(
        model="wan/v2.6/text-to-video",
        input={"prompt": "test"},
    )
except ThankYouRateLimitError as error:
    print("Rate limited", error.code, error.details)
except ThankYouValidationError as error:
    print("Invalid request", error.details)
except ThankYouAuthenticationError:
    print("Check your API key")
except ThankYouAPIError as error:
    print(error.status, error.code, error.retryable, error.details)

Type Strategy

The SDK keeps generation request and response types close to the public API contract:

  • top-level fields are model, input, webhook, idempotency_key, and quote_id;
  • input includes common hints such as prompt, text, negative_prompt, reference_assets, aspect_ratio, duration, and num_images;
  • generation responses use one common GenerationOutput item with url, mime_type, width, height, duration, and fps;
  • model-specific fields should be discovered with thankyou.models.detail(model_id).input_schema and passed as a normal dict.

This keeps newly released model fields and model-specific output fields usable without waiting for an SDK release.

from thankyou import GenerationInput, GenerationOutput, JsonObject, ThankYou

client = ThankYou(api_key="tk_test")

common_input: GenerationInput = {
    "prompt": "A mountain landscape at golden hour",
    "aspect_ratio": "16:9",
}

generation = await client.generations.create(
    model="google/nano-banana/text-to-image",
    input=common_input,
)
output: GenerationOutput = generation.output[0]
print(output.get("url"))

detail = await client.models.detail("wan/v2.6/text-to-video")
print(detail.input_schema)

model_specific_input: JsonObject = {
    "prompt": "Cinematic drone shot of a mountain lake at sunrise",
    "duration": "5",
    "resolution": "1080P",
    "camera_fixed": False,
}

quote = await client.generations.quote(
    model="wan/v2.6/text-to-video",
    input=model_specific_input,
)

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

thankyouai-0.1.0.tar.gz (28.9 kB view details)

Uploaded Source

Built Distribution

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

thankyouai-0.1.0-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file thankyouai-0.1.0.tar.gz.

File metadata

  • Download URL: thankyouai-0.1.0.tar.gz
  • Upload date:
  • Size: 28.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for thankyouai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7a247eac66a826fb4f3631710fdefed57160e4366aba0066ba9285324cccd666
MD5 66a878cf5ada521acc1cd5c0a50336fc
BLAKE2b-256 a303007fba139b5ab24396367e038b86d81447c21aebfc9d3ce1d5f60a3ed777

See more details on using hashes here.

Provenance

The following attestation bundles were made for thankyouai-0.1.0.tar.gz:

Publisher: publish.yml on 39-ai/thankyouai-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file thankyouai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: thankyouai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for thankyouai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b0bf4c6f219fa93e7b41ab159fcbaa21501f5c43fc5ac35d6799fc7134e8e13
MD5 7097113dc1fee88801e5487292bef704
BLAKE2b-256 a630a109d77838d21d25cad7457f0fac8beb27b9d959c27e3ef02d8ed6544956

See more details on using hashes here.

Provenance

The following attestation bundles were made for thankyouai-0.1.0-py3-none-any.whl:

Publisher: publish.yml on 39-ai/thankyouai-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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