Developers

The Femimg API and CLI: generate images and video from your own code

Femimg has a public API and a command-line tool. Create a key, start a render, poll it and download the file from code, paid from the studio balance.

5 min read
A dark desk at night with a slim laptop showing a soft pearl gradient of lilac, rose and mint, a keyboard with pastel keys, a pearlescent mug and a small succulent, and a blurred wall of fashion photographs and a city window behind

Until now the studio was something you opened in a browser. It is also something you can call from a script. Femimg has a public API and a command-line tool, so a shop, a script or a coding agent can start renders and collect the files without anyone clicking Generate. Here is the short tour.

Who it is for

Anyone who would otherwise repeat the same studio steps by hand. A few honest examples:

  • A shop that needs product pictures in bulk. A script reads a spreadsheet of garments and renders one frame per row.
  • A nightly job. A cron task renders the next day's social posts and drops the files in a folder.
  • A coding agent. It asks for the price of a render first, stays under a cap you set, then fetches the result.

If you make a handful of pictures a week, the studio is faster. The API pays off when the same job repeats.

How the key works

Authentication is one header. In the studio, open Settings, create an API key, give it a name and copy it right away: it is shown once. Every request then carries it as a Bearer token in the Authorization header. Treat it like a password: keep it in an environment variable, never in a repository or browser code, and delete it in Settings if it leaks. The examples below use the placeholder YOUR_API_KEY.

One round trip: start, poll, download

A render is not instant, so the API works in three calls. First, pick a model: the list of models returns every id with its fields, and the detail call shows what one model accepts. Then start the render by sending the model id and its inputs. You get a generation back at once with the status queued. Poll that generation until its status is succeeded, then download the file.

Prompt
export FEMIMG_API_KEY="YOUR_API_KEY" curl -X POST https://femimg.com/api/v1/api/catalog/generations \ -H "Authorization: Bearer $FEMIMG_API_KEY" \ -H 'Content-Type: application/json' \ -H "Idempotency-Key: $(uuidgen)" \ -d '{"modelId": "MODEL_ID", "inputs": {"prompt": "Linen shirt on a cutting table, soft window light"}}' curl https://femimg.com/api/v1/api/catalog/generations/ID \ -H "Authorization: Bearer $FEMIMG_API_KEY" curl https://femimg.com/api/v1/api/catalog/generations/ID/content \ -H "Authorization: Bearer $FEMIMG_API_KEY" -o result.jpeg
MODEL_ID comes from the models list, ID is the id the first call returned. The fields inside inputs follow the model, so check the detail call before you copy a prompt field from another model.

Other routes return your key's limit and balance, list recent generations and delete one. The full list is on the developers page.

Price first, and retries that never charge twice

Two small features matter once a script runs unattended. A quote call returns the exact price for a set of inputs without starting anything, so a job can refuse to run when the price is above what you allow. And the Idempotency-Key header, a string you choose for each logical job, means a retried request after a network error does not create a second render or a second charge.

The command line, if you would rather not write curl

The CLI wraps the same API with the same keys and the same balance. It needs Node and installs from npm.

Prompt
npm i -g femimg femimg login femimg models --search portrait femimg run MODEL_ID -p "Linen shirt on a cutting table, soft window light" -o ./out/
Add --dry-run to see the price without rendering, --max-price to refuse anything above a limit you pick, and --json to get one JSON object per run for the next step in your pipeline.

For automation, export FEMIMG_API_KEY instead of running login. A render that fails is not charged, and the CLI exits with a non-zero code so your script can see it.

Same balance, pay per render

There is no separate developer plan. API and CLI renders draw on the same balance as the studio, each charged by what that model costs for those inputs. Top up in Billing and the money is available to both. If a render fails, it is refunded to your balance automatically. The pricing page lists model costs and the quote call gives the exact amount for your inputs.

What it cannot do

  • No push notifications. There are no webhooks: you poll the generation until it finishes.
  • No client library. There is no official SDK for a programming language. The API is plain HTTP and JSON, so any language with an HTTP client works.
  • Rate limits. Each key has a per-minute request limit. Go over it and you get a 429 error, so back off and retry.
  • Every model has its own fields. A prompt that works for one model may need different inputs for another, so check the detail call first.

Where to go next

Open the developers page for the endpoint list and ready examples, then compare what the models can do on the models page. The lookbook guide shows how to keep one fictional model consistent across a run, and virtual try-on is a good second job for a script. Test a prompt by eye first in the studio.

Questions

How do I authenticate with the Femimg API?

Create a key in Settings and send it as a Bearer token in the Authorization header of every request. The key is shown once, so copy it into an environment variable or a secret store.

Do API renders cost extra compared with the studio?

No separate plan and no seat fee. API and CLI renders use the same balance as the studio and each is charged by the model and inputs. A failed render is refunded automatically.

Is there an SDK or webhooks?

No. The API is plain HTTP and JSON, and a render is finished by polling it until its status is succeeded. The CLI wraps the same calls for terminals, scripts and agents.

How do I avoid being charged twice when a request is retried?

Send an Idempotency-Key header with a unique value for each job. A retry with the same value does not start a second render or charge you again.

#Developers#API#CLI

Keep reading

All articles →