# Frameport Replace 1 API

> Up to four people in your clip replaced by the faces you send: moves, lips, scene and sound kept.

Frameport Replace 1, a Frameport engine, called with one API key: from $0.12 per second of clip, charged only when the edit succeeds.

- Model id: `fp-replace-1`
- Type: video, a clip editor: it changes a clip you send
- Maker: Frameport
- Tasks: Face swap
- Endpoint: `POST https://frameport.ai/v1/videos/edits`
- Page: https://frameport.ai/models/fp-replace-1
- Every model, as JSON: https://frameport.ai/models.json

## Pricing

| Resolution | Per second of clip |
| --- | --- |
| 768p (default) | $0.12 |
| 1080p | $0.25 |

- Charged once, and only when the edit succeeds. A failed job costs $0.00: its hold is released in full.
- The exact price is known before the run: the API returns it as `reserved_usd` when it accepts the job.
- Billed on the length of the clip you send, rounded up to the second (0.15 s over is not counted). The price of the longest clip (10 s) is held first, then brought down to your clip's once it is measured.

## Options

| Option | Value |
| --- | --- |
| Tasks | Face swap |
| Resolutions | 768p, 1080p |
| Clip length | 2 to 10 seconds |
| Clip file | MP4 or MOV, up to 64 MB, 24 fps |
| Faces | 1 to 4, one per person replaced |
| Outfits | The clip's, or each picture's |
| Note | Optional, up to 500 characters |
| Sound | Kept from the clip |
| Output | A video file, signed link valid about an hour |
| Billing unit | Per second of clip |
| Model id | `fp-replace-1` |

## Frameport Replace 1 API parameters

`POST https://frameport.ai/v1/videos/edits` with a JSON body and your key as a Bearer token:

| Field | Values | Notes |
| --- | --- | --- |
| `model` (required) | "fp-replace-1" | Required. |
| `video` (required) | an https URL, or a file id | Required: the clip, MP4 or MOV, up to 64 MB, 24 fps, 2 to 10 seconds. A public https link we download, or one of your video outputs (file_…). |
| `resolution` | 768p and 1080p | 768p when left out. A second of clip costs 768p $0.12, 1080p $0.25. |
| `faces` (required) | 1 to 4 pictures | Required: one face per person replaced, left to right. An https URL, a base64 data URI or one of your image outputs (file_…): PNG, JPEG or WebP, up to 10 MB. |
| `targets` | one text per face | Who each face replaces, in the same order ("the woman on the left"). Required with several faces. |
| `keep_outfit` | true or false | true when left out: the clip's clothes stay. false dresses each person as in their picture. |
| `prompt` | text, up to 500 characters | Optional: a note on the edit. |

## Frameport Replace 1 request bodies, one per mode

### One face, a 5 s clip · $0.60

```json
{
  "model": "fp-replace-1",
  "video": "https://example.com/dance.mp4",
  "faces": [
    "https://example.com/me.jpg"
  ]
}
```

### Two faces, a 5 s clip · $0.60

```json
{
  "model": "fp-replace-1",
  "video": "https://example.com/duet.mp4",
  "faces": [
    "https://example.com/ana.jpg",
    "https://example.com/ben.jpg"
  ],
  "targets": [
    "the woman on the left",
    "the man on the right"
  ],
  "keep_outfit": false,
  "resolution": "768p"
}
```

## Submit, poll, download

### cURL

```bash
# 1. Submit: the price is held on your balance (reserved_usd)
curl https://frameport.ai/v1/videos/edits \
  -H "Authorization: Bearer $FRAMEPORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "fp-replace-1",
    "video": "https://example.com/dance.mp4",
    "faces": [
      "https://example.com/me.jpg"
    ]
  }'

# 2. Poll with the id it returns, until "succeeded" or "failed"
curl https://frameport.ai/v1/videos/edits/$GENERATION_ID \
  -H "Authorization: Bearer $FRAMEPORT_API_KEY"

# 3. Download outputs[0].url once it has succeeded (a signed link, no key needed)
curl -L "$OUTPUT_URL" -o out.mp4
```

### Python

```python
import os, time
import requests

API = "https://frameport.ai/v1"
headers = {"Authorization": f"Bearer {os.environ['FRAMEPORT_API_KEY']}"}

# 1. Submit: the price is held on your balance (reserved_usd)
gen = requests.post(f"{API}/videos/edits", headers=headers, json={
    "model": "fp-replace-1",
    "video": "https://example.com/dance.mp4",
    "faces": [
        "https://example.com/me.jpg",
    ],
}).json()
if gen.get("error"):
    raise SystemExit(gen["error"]["message"])

# 2. Poll until it succeeds or fails
while gen["status"] in ("queued", "running"):
    time.sleep(3)
    gen = requests.get(f"{API}/videos/edits/{gen['id']}", headers=headers).json()

# A failed generation costs nothing: the hold is released
if gen["status"] == "failed":
    raise SystemExit(gen["error"]["message"])

# 3. Download the file (a signed link, no key needed)
file = requests.get(gen["outputs"][0]["url"])
open("out.mp4", "wb").write(file.content)
print("saved out.mp4", gen["cost_usd"])
```

### JavaScript

```js
import { writeFile } from 'node:fs/promises'

const API = 'https://frameport.ai/v1'
const headers = {
  'Authorization': `Bearer ${process.env.FRAMEPORT_API_KEY}`,
  'Content-Type': 'application/json',
}

// 1. Submit: the price is held on your balance (reserved_usd)
let gen = await fetch(`${API}/videos/edits`, {
  method: 'POST',
  headers,
  body: JSON.stringify({
    model: 'fp-replace-1',
    video: 'https://example.com/dance.mp4',
    faces: [
      'https://example.com/me.jpg',
    ],
  }),
}).then(res => res.json())
if (gen.error) throw new Error(gen.error.message)

// 2. Poll until it succeeds or fails
while (gen.status === 'queued' || gen.status === 'running') {
  await new Promise(resolve => setTimeout(resolve, 3000))
  gen = await fetch(`${API}/videos/edits/${gen.id}`, { headers }).then(res => res.json())
}
// A failed generation costs nothing: the hold is released
if (gen.status === 'failed') throw new Error(gen.error.message)

// 3. Download the file (a signed link, no key needed)
const file = await fetch(gen.outputs[0].url)
await writeFile('out.mp4', Buffer.from(await file.arrayBuffer()))
console.log('saved out.mp4', gen.cost_usd)
```

## What Frameport Replace 1 is good at

Up to four people in your clip replaced by the faces you send: moves, lips, scene and sound kept.

## About the Frameport Replace 1 API

### How much does the Frameport Replace 1 API cost?

Frameport Replace 1 is billed per second of the clip you send: $0.12 at 768p and $0.25 at 1080p. A 5-second clip at 768p costs $0.60. The price of the longest clip is held first and brought down to your clip's once it is measured; you are charged once, only when the edit succeeds.

### How do I call Frameport Replace 1 from code?

Send POST /v1/videos/edits with "model": "fp-replace-1" and the clip in video, the faces in faces, your API key as a Bearer token. The answer is a generation with an id: poll GET /v1/videos/edits/{id} until its status is succeeded, then download outputs[0].url.

### What happens if a Frameport Replace 1 generation fails?

Nothing is charged. The price is held on your balance when the job starts and released in full if it fails: cost_usd stays at 0.

### Which clips does Frameport Replace 1 take?

MP4 or MOV, up to 64 MB, 24 fps, 2 to 10 seconds: a public https link, or one of your own video outputs by its file id. A clip it cannot use is refused with invalid_video, and nothing is charged.

### How many people can Frameport Replace 1 replace?

Up to 4: send one face per person, left to right. With several faces, say who each one replaces in targets ("the woman on the left"). The clip's clothes stay unless keep_outfit is false.

### Do I need a subscription?

No. You top up a prepaid balance in dollars, from $10, and it never expires. Every model runs on the same balance and the same API key.
