Fittins AI for Python
The official library for the Fittins AI API. Fittins AI is a premium AI fashion generation service: studio-quality on-model photos up to 8K and fashion videos up to 4K, made from your product photos.
The API is included in the Pro, Business and Enterprise plans and uses the same credits as the website. Create a key in Profile → API keys on fittins.ai.
pip install fittins
Needs Python 3.10 or later, and has no dependencies. Use it on your server: never put an API key in a web page or an app.
Create a photo
from fittins import Fittins
fittins = Fittins() # reads FITTINS_API_KEY
generation = fittins.images.create(
product_images=[{"url": "https://cdn.mystore.com/p/dress.jpg"}],
model_id="mdl_lib_DM5rQvl3KtlR7nqumd6I",
prompt="full body, soft studio light, front view",
aspect_ratio="3:4",
quality="4k",
metadata={"sku": "DRESS-RED-M"},
)
done = fittins.generations.wait(generation["id"])
if done["status"] == "succeeded":
print(done["output"]["url"]) # a download link, valid for 24 hours
else:
print(done["error"]["code"], done["error"]["message"])
What's included
images.create · videos.create |
Start a photo or a video |
generations.get · list · list_all · wait · delete |
Follow, list and delete results |
uploads.create |
Upload a product photo (a path, bytes or an open file) |
files.download |
Get a result's bytes |
models · locations |
list, get, and create a custom one |
webhook_endpoints |
create, list, delete, rotate_secret |
usage.get · account.get |
Calls and credits per day, and plan and balance |
Answers are plain dictionaries, with type hints in fittins.types. Field names are the same as in the API reference.
Retries and safe creates
Failed requests are sent up to 2 more times, with a growing pause. After a 429, the library waits for the time in Retry-After.
Each create gets an Idempotency-Key that its retries reuse, so a retry can't charge twice. To protect against your own job running twice, pass a key you can repeat:
fittins.images.create(idempotency_key=f"photo-{sku}", **params)
Uploads, webhook endpoint changes and deletes are only retried after a 429, because sending them twice could do the work twice.
Set your own limits with Fittins(max_retries=4, timeout=60.0).
Errors
from fittins import APIError
try:
fittins.images.create(**params)
except APIError as error:
if error.code == "insufficient_credits":
... # error.status, error.code, error.message, error.param, error.request_id
else:
raise
APIConnectionError means no answer arrived. WaitTimeoutError means generations.wait ran out of time; the generation may still finish. A generation that fails after being accepted isn't raised: check status and error.
Webhooks
import os
from flask import Flask, request
from fittins import WebhookVerificationError, verify_webhook
app = Flask(__name__)
@app.post("/webhooks/fittins")
def fittins_webhook():
try:
event = verify_webhook(
request.get_data(),
request.headers.get("Fittins-Signature"),
os.environ["FITTINS_WEBHOOK_SECRET"],
)
except WebhookVerificationError:
return "", 400
if event["type"] == "generation.succeeded":
print(event["data"]["object"]["output"]["url"])
return "", 200
Pass the body exactly as received, before any JSON parsing.
Testing without credits
Keys that start with fit_test_ run the checks on your request and return a sample result, without using the AI or any credits.
More
Metadata
Release files for fittins 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fittins-1.0.0.tar.gz | 17.9 kB | Without provenance | Details for fittins-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fittins-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for fittins-1.0.0-py3-none-any.whl |
Total release size: 31.4 kB
Release files / fittins-1.0.0.tar.gz
| Download URL | fittins-1.0.0.tar.gz |
|---|---|
| Size | 17.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
768e04e813edb6ae0de6db9be3bab30699b6a63ed3e7cbcd052e9361052950df
|
|
BLAKE2b-256 checksum How to use checksums |
aef4ceb7eeebfbe9dcb441a88b4d81d5d7fdf196b3929aaa7682f934686dce6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.2
|
Release files / fittins-1.0.0-py3-none-any.whl
| Download URL | fittins-1.0.0-py3-none-any.whl |
|---|---|
| Size | 13.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8fa491a00d987e298b581dc4f3edc435a02169875287906005bb39ed5e73baf5
|
|
BLAKE2b-256 checksum How to use checksums |
d35e1b1a4686147579bde9a0a2f1bdc5a5a57f1c9d165e3776f9d4c1e5927a3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.2
|
Security for fittins 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.