Loading...
Loading...
Integrate FASHN generative image & video models for fashion into a project, or run it inline. Use for virtual try-on, product-to-model, model create/swap, face-to-model, edit, reframe, background removal, and image-to-video, via the FASHN REST API, the TypeScript SDK (fashn npm), or the Python SDK (fashn pip).
npx skill4agent add fashn-ai/fashn-skill fashnmodel_nameinputsfashnfashnFull per-endpoint parameter tables, the error catalog, webhooks, and credits live in reference.md. Load it when you need exactfor a giveninputs.model_name
Authorization: Bearer $FASHN_API_KEYFASHN_API_KEYFASHN_API_KEYecho "${FASHN_API_KEY:+set}"~/.fashn/.envset -a; [ -f ~/.fashn/.env ] && . ~/.fashn/.env; set +a~/.fashn/.envrm ~/.fashn/.envumask 077; mkdir -p ~/.fashn; printf 'FASHN_API_KEY=%s\n' '<key>' > ~/.fashn/.env; chmod 600 ~/.fashn/.env.env~/.fashn/.env{ model_name, inputs }model_name| Category | | Required inputs |
|---|---|---|
| Virtual try-on (flagship) | | |
| Virtual try-on (legacy/fast) | | |
| Product → person wearing it | | |
| Generate a model from a prompt | | |
| Change a model's identity | | |
| Headshot → upper-body avatar | | |
| Freeform edit | | |
| Change aspect ratio (outpaint/crop) | | |
| Remove background → transparent PNG | | |
| Animate an image → video | | |
subscriberunstatusrunidstatus(id)completedfailed{ "id": "...", "status": "completed", "output": ["https://cdn.fashn.ai/.../output_0.png"], "error": null }statusstartingin_queueprocessingcompletedfailedsubscribecanceledtime_outoutputreturn_base64: trueimage-to-videoerrornull{ name, message }x-fashn-credits-usedcreditsUsedcredits_usedgeneration_moderesolutionGET /v1/creditsAPIError{ "error": "<Code>", "message": "..." }status: "failed"error: { name, message }ImageLoadErrorContentModerationErrorPoseErrorstatus429fashnnpm install fashnimport Fashn from 'fashn';
const client = new Fashn(); // reads FASHN_API_KEY from env
// Recommended: submit + auto-poll to completion
const result = await client.predictions.subscribe({
model_name: 'tryon-max',
inputs: {
model_image: 'https://example.com/person.jpg',
product_image: 'https://example.com/garment.jpg',
},
// optional: pollInterval (ms, default 1000), timeout (ms, default 300000),
onEnqueued: (id) => console.log('queued', id),
onQueueUpdate: (s) => console.log('status', s.status),
});
if (result.status === 'completed') {
console.log(result.output, 'credits:', result.creditsUsed);
} else {
console.error('failed:', result.status, result.error?.name, result.error?.message);
}const { id } = await client.predictions.run({ model_name: 'tryon-max', inputs: { /* ... */ } });
const status = await client.predictions.status(id); // poll until terminaltry {
const r = await client.predictions.subscribe({ model_name: 'tryon-max', inputs: { /* ... */ } });
if (r.status !== 'completed') console.error('runtime error:', r.error?.name, r.error?.message);
} catch (err) {
if (err instanceof Fashn.APIError) console.error('API error:', err.status, err.message);
else throw err;
}fashnpip install fashnimport fashn
from fashn import Fashn
client = Fashn() # reads FASHN_API_KEY from env
result = client.predictions.subscribe(
model_name="tryon-max",
inputs={
"model_image": "https://example.com/person.jpg",
"product_image": "https://example.com/garment.jpg",
},
)
if result.status == "completed":
print(result.output, "credits:", result.credits_used)
else:
print("failed:", result.status, result.error)client.predictions.run(...)client.predictions.status(prediction_id)from fashn import AsyncFashnawait client.predictions.subscribe(...)fashn.APIErrore.status_codee.messageresult.status == "failed"result.errorhttps://api.fashn.ai/v1# Submit → returns {"id": "...", "error": null}
curl -s -X POST https://api.fashn.ai/v1/run \
-H "Authorization: Bearer $FASHN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model_name":"tryon-max","inputs":{
"model_image":"https://example.com/person.jpg",
"product_image":"https://example.com/garment.jpg"}}'
# Poll → repeat until status is "completed" or "failed"
curl -s https://api.fashn.ai/v1/status/<id> -H "Authorization: Bearer $FASHN_API_KEY" -i
# read x-fashn-credits-used from the response headers
# Balance
curl -s https://api.fashn.ai/v1/credits -H "Authorization: Bearer $FASHN_API_KEY"?webhook_url=/runcompletedfailed~/.fashnls ~/.fashn/node_modules/fashn 2>/dev/null || npm install --prefix ~/.fashn fashn[ -z "$FASHN_API_KEY" ] && { set -a; . ~/.fashn/.env 2>/dev/null; set +a; }$cd ~/.fashnfashnNODE_PATH[ -z "$FASHN_API_KEY" ] && { set -a; . ~/.fashn/.env 2>/dev/null; set +a; }
cd ~/.fashn && node --input-type=module <<'NODE'
import Fashn from 'fashn';
const r = await new Fashn().predictions.subscribe({
model_name: 'tryon-max',
inputs: {
model_image: 'https://example.com/person.jpg',
product_image: 'https://example.com/garment.jpg',
},
timeout: 120000, // ms
});
if (r.status !== 'completed') { console.error('Failed:', r.status, r.error); process.exit(1); }
console.log(JSON.stringify({ output: r.output, creditsUsed: r.creditsUsed }, null, 2));
NODEreadFile(path, { encoding: 'base64' })node:fs/promisesproduct_image: 'data:image/jpeg;base64,' + b64fetch(r.output[0])429inputs