# FASHN Agent API recipe: a lookbook in one call (v1)

A four-look lookbook of one model in one location, from six photos, in one call to the FASHN Agent API. The same method as FASHN's lookbook guide for the app: https://help.fashn.ai/using-fashn/guides/agent-workflows/create-a-fashion-lookbook

## Instructions for Claude Code

The user pasted a line asking you to follow this file. They don't need to read it. Follow these steps in order, and don't skip the questions.

"This folder" always means the folder you are running in (your working directory), never the folder this file came from. Look for the photos and the `.env` there, and save the looks there.

### 1. The API key
- Look for `FASHN_API_KEY` in the environment, then in a `.env` file in your working directory.
- If it's missing: if there's no `.env` in your working directory, create one containing exactly one line, `FASHN_API_KEY=`. If a `.env` already exists, leave everything in it unchanged and add the line `FASHN_API_KEY=` at the end, unless an empty `FASHN_API_KEY=` line is already there. Then open the `.env` file in the user's default text editor (on a Mac `open -e .env`, on Windows `notepad .env`, on Linux `xdg-open .env`). If it won't open, tell them where the file is.
- Then stop and tell the user, in plain words: go to https://app.fashn.ai/api, click Create new API key, copy it, paste it right after `FASHN_API_KEY=` in the file that just opened, save it, and reply "done".
- Never ask the user to paste the key into the chat. Never print the key, and never write it anywhere else.

### 2. Which photo is which
- List the images in your working directory (jpg, png, webp). Files over 10 MB are fine: you resize them in step 3.
- Look at the photos and their names, and propose in one message: which photo is the model's face, which is the location, and the four outfits in the order of the looks. Ask the user to reply "yes" or change it. Wait for the answer. If you can't tell, ask instead of guessing.
- If they have more than four outfits, ask which four go in this lookbook. One call makes up to four looks.

### 3. Prepare the images
- Turn each image into a base64 data URI (`data:image/jpeg;base64,...`). Resize anything over about 4 megapixels first. Never change the original files.

### 4. Make one call (start the job, then check on it)
- Start the job: `POST https://api.fashn.ai/v1/agent/images/run`
- Header: `Authorization: Bearer <FASHN_API_KEY>`. Use curl, or set a normal `User-Agent` header if you use Python.
- Body:
  ```json
  {
    "prompt": "<the prompt below, word for word>",
    "images": ["<face>", "<location>", "<outfit 1>", "<outfit 2>", "<outfit 3>", "<outfit 4>"],
    "resolution": "2k",
    "aspect_ratio": "2:3",
    "generation_mode": "quality"
  }
  ```
- The images go in exactly that order: the prompt refers to them by number.
- It answers at once with `{"id": "..."}`. Tell the user the id and that it takes about 5 minutes.
- Check on it every 10 seconds: `GET https://api.fashn.ai/v1/agent/status/<id>`, with the same header. While it runs, `status` is `processing`.
- When `status` is `completed`, the same response has the `predictions` and `credits_used`. If it's `failed`, show the user the `error` and stop.
- Never wait on one open connection for the whole job. If checking stops working, the user can check the same id later; never start a second job without asking.

The prompt, word for word:

> Make a lookbook of four full body photos. Image 1 is the model, image 2 is the location, and images 3 to 6 are four outfits, one per look. Make look 1 first. Then make looks 2, 3 and 4, each one directly from look 1, in a different pose, head angle and expression. In every look, use the face from image 1, so the model matches image 1 exactly.

### 5. Save the looks
- The completed status has `predictions`, each with `results` (image URLs). Download them in order into a folder named `lookbook`, as `look-1.png` to `look-4.png`.
- Never overwrite: if `lookbook` already exists, use `lookbook-2`, `lookbook-3` and so on.

### 6. Report
- Tell the user where the four looks are and how many credits the call used (`credits_used`; 12 at these settings).
- Suggest they compare each face with the face photo. If one drifted, they can run the call again or repair that face in the FASHN app.

## Why the wording matters
- "Looks 2, 3 and 4, each one directly from look 1" keeps the location and light the same and stops the Agent from chaining look to look (making look 3 from look 2), where the face drifts a little more each time. The shorter "make each other look directly from look 1" can let it chain.
- "In every look, use the face from image 1, so the model matches image 1 exactly" makes the Agent send the face photo into every look, not only look 1. With a shorter line, it makes looks 2 to 4 as edits of look 1 and the same face and pose repeat.
- "A different pose, head angle and expression" keeps the looks from feeling static.

## Notes
- Up to 6 images in and 4 looks out per call. For more looks, make more calls.
- For print, change `resolution` to `4k` (costs more credits per look).
- The Agent doesn't send back text or ask questions; it only returns the images.
