Python SDK
The official way to call ThankYou from Python
The Python SDK is the recommended integration path for Python applications. It wraps the Open API with typed model inputs, file uploads, polling helpers, quotes, usage, and webhook verification.
The package is published to PyPI as thankyouai.
pip install thankyouaithankyouai>=0.1.0,<0.2.0pdm add thankyouaiThe SDK requires Python 3.11 or newer.
Create a client
The package is published as thankyouai, and the client is imported from the thankyou module:
import os
from thankyou import ThankYou
thankyou = ThankYou(api_key=os.environ["THANKYOU_API_KEY"])The default base URL is https://api.thankyouai.com/open/v1.
REST endpoints remain fully supported. Use the SDK when you want typed model inputs, automatic polling helpers, and fewer hand-written request wrappers.
Generate and wait
import asyncio
import os
from thankyou import ThankYou
thankyou = ThankYou(api_key=os.environ["THANKYOU_API_KEY"])
async def main():
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"])
asyncio.run(main())thankyou.run() creates a generation and waits until it reaches a terminal status. Use thankyou.generations.create() and thankyou.generations.wait() separately when you want to control the polling loop.
Upload a reference image
Inside an async function, upload the file first, then pass the returned URL into a model input:
file = await thankyou.files.upload(file="./photo.jpg")
result = await thankyou.run(
model="google/nano-banana/edit",
input={
"prompt": "Keep the original composition, but render it as a polished 3D app icon",
"reference_assets": [{"role": "reference", "url": file.url}],
},
)
print(result.output[0]["url"])Quote before execute
Use quotes when you need the estimated cost before starting a generation.
quote = await thankyou.generations.quote(
model="bytedance/seedance/v2/video",
input={
"prompt": "A koi fish swimming through a moonlit pond",
"duration": 4,
"resolution": "720p",
},
)
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)Discover model input schemas
models = await thankyou.models.list()
detail = await thankyou.models.detail("google/nano-banana/edit")
print(len(models.models))
print(detail.input_schema)Use models.detail() as the source of truth for a model's supported input fields and reference_assets[].role values.