Skip to main content

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"])

Any create request can also take webhook_url: an address we call once when that generation ends, with only its id and status. Read the result with generations.get.

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 and get; create and delete your custom ones
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

API documentation · Support

Metadata

Release files for fittins 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fittins 1.1.0
File Size Uploaded Provenance Actions
fittins-1.1.0.tar.gz 18.3 kB Without provenance Details for fittins-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fittins 1.1.0
File Interpreter ABI Platform Actions
fittins-1.1.0-py3-none-any.whl Python 3 none any Details for fittins-1.1.0-py3-none-any.whl

Total release size: 32.2 kB

Release files / fittins-1.1.0.tar.gz

Download URL fittins-1.1.0.tar.gz
Size 18.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6b4b5cdf634e1fd684a0344a714d07b19c521c96c33dfcb66dfa893aa96fff3d
BLAKE2b-256 checksum
How to use checksums
2167ffe2674ef84982853fb02810da248165c9426457a2a6bd9a1a12a816beae
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.1.0-py3-none-any.whl

Download URL fittins-1.1.0-py3-none-any.whl
Size 13.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3ce10eacd468d490b6ba2059bdbe0b3676a3d3eead82280a921fcb9d33b6c407
BLAKE2b-256 checksum
How to use checksums
8789e86a40810333c71cc1a7081e63d734631d1072c798ff5c15aa5aed01a130
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.1.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.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page