> For the complete documentation index, see [llms.txt](https://diffio.ai/llms.txt). This page is also available as HTML at https://diffio.ai/docs/developers/guides/compare-flash-and-pro/.

# Compare Flash and Pro on one recording

Restore one recording with both models, listen to them side by side, and see what each one cost.

## How it works

1. Your code → Diffio API: `POST /projects`, generation diffio-flash
2. Your code → Diffio API: `upload`, once
3. Your code → Diffio API: `POST …/generations`, diffio-pro, same upload
4. Diffio API → Your code: `two generations complete`, price_per_hour_usd each
5. Your code → Diffio API: `GET …/media`, once per generation
6. Your code: `compare.html`, original, Flash, Pro

**Two generations of one project share its upload; only the restore runs twice.**

## Build it

### 1. One project, a Flash generation

Create the project with `generation: {"model": "diffio-flash"}` and upload the file once.

### 2. A Pro generation on the same upload

`POST …/generations` with `diffio-pro`. Nothing is uploaded again; each generation has its own status, files and price.

### 3. Work out the cost

Each generation reports `price_per_hour_usd` (the same list prices as [GET /models](https://diffio.ai/docs/api-reference/list-models/)). A restore bills whole seconds of the recording with a 60 second minimum; [GET /usage](https://diffio.ai/docs/api-reference/usage-summary/) reports what was billed.

### 4. Listen side by side

Each generation's media grant has `files.audio`; the owner's grant also has `files.original`.

### The complete script

Pass an audio or video file; it writes `compare.html`.

**compare.py**

```python
"""Restore one recording with Flash and Pro, then write compare.html to hear them side by side.

python compare.py interview.mp3
"""
import html
import math
import os
import sys

from diffio import DiffioClient

path = sys.argv[1]
client = DiffioClient()  # reads DIFFIO_API_KEY

# 1. One project and one upload, with a Flash generation...
project = client.projects.create(file_name=os.path.basename(path), size_bytes=os.path.getsize(path),
                                 generation={"model": "diffio-flash"})
client.projects.upload(project, path)
# 2. ...and a Pro generation on the same upload.
pro = client.generations.create(project.id, model="diffio-pro")

# 3. Wait for both; work out each one's cost at list price.
players = []
for generation_id in (project.latest_generation.id, pro.id):
    generation = client.generations.wait(project.id, generation_id, timeout=3600)
    media = client.generations.media(project.id, generation.id)
    seconds = max(60, math.ceil(generation.duration_seconds or 0))  # whole seconds, 60 second minimum
    cost = seconds * (generation.price_per_hour_usd or 0) / 3600
    print(f"{generation.model}: {seconds} s at ${generation.price_per_hour_usd}/h = ${cost:.2f}")
    players.append((f"{generation.model} (${cost:.2f})", media.files["audio"]))
players.insert(0, ("Original", media.files["original"]))

# 4. One page with all three; the URLs work for 6 hours.
with open("compare.html", "w") as page:
    page.write("<!doctype html><title>Flash and Pro</title>")
    for label, url in players:
        page.write(f'<h2>{html.escape(label)}</h2><audio controls src="{html.escape(url)}"></audio>')
print("open compare.html")
```

**compare.mjs**

```javascript
// Restore one recording with Flash and Pro, then write compare.html to hear them side by side.
// node compare.mjs interview.mp3
import { writeFile } from "node:fs/promises";
import { DiffioClient } from "diffio";

const path = process.argv[2];
const client = new DiffioClient(); // reads DIFFIO_API_KEY
const escape = (text) => String(text).replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]);

// 1. One project and one upload, with a Flash generation...
const project = await client.projects.create({ file_name: path.split("/").pop(), generation: { model: "diffio-flash" } });
await client.projects.upload(project, path);
// 2. ...and a Pro generation on the same upload.
const pro = await client.generations.create(project.id, { model: "diffio-pro" });

// 3. Wait for both; work out each one's cost at list price.
const players = [];
let media;
for (const generationId of [project.latest_generation.id, pro.id]) {
  const generation = await client.generations.wait(project.id, generationId, { timeout: 3600 });
  media = await client.generations.media(project.id, generation.id);
  const seconds = Math.max(60, Math.ceil(generation.duration_seconds ?? 0)); // whole seconds, 60 second minimum
  const cost = (seconds * (generation.price_per_hour_usd ?? 0)) / 3600;
  console.log(`${generation.model}: ${seconds} s at $${generation.price_per_hour_usd}/h = $${cost.toFixed(2)}`);
  players.push([`${generation.model} ($${cost.toFixed(2)})`, media.files.audio]);
}
players.unshift(["Original", media.files.original]);

// 4. One page with all three; the URLs work for 6 hours.
const body = players.map(([label, url]) => `<h2>${escape(label)}</h2><audio controls src="${escape(url)}"></audio>`).join("");
await writeFile("compare.html", `<!doctype html><title>Flash and Pro</title>${body}`);
console.log("open compare.html");
```

## What you get

![The finished Diffio 4.7 Pro project of the same lecture in the Diffio app](https://diffio.ai/media/recording-rescue/pro-result.jpg)

Uploaded

[Uploaded (MP3)](https://diffio.ai/media/recording-rescue/original.mp3)

Diffio 4.7 Flash

[Diffio 4.7 Flash (MP3)](https://diffio.ai/media/recording-rescue/flash.mp3)

Diffio 4.7 Pro

[Diffio 4.7 Pro (MP3)](https://diffio.ai/media/recording-rescue/pro.mp3)

**The same 60 seconds of an archival lecture, as uploaded and restored by each model. [How this recording was restored](https://diffio.ai/recording-rescue/).**

- `compare.html`: the original and both results on one page, each with its cost.
- Both generations stay on the project: keep the one you prefer, or let your users choose.

**Output of `python compare.py interview.mp3`**

**Terminal**

```bash
diffio-4.7-flash: 60 s at $5.0/h = $0.08
diffio-4.7-pro: 60 s at $10.0/h = $0.17
open compare.html
```

## API reference

- POST [Create a project](https://diffio.ai/docs/api-reference/create-project/) (`/projects`): The project and its Flash generation.
- POST [Create a generation](https://diffio.ai/docs/api-reference/create-generation/) (`/projects/{project_id}/generations`): The Pro generation.
- GET [Get a playback grant](https://diffio.ai/docs/api-reference/get-generation-media/) (`/projects/{project_id}/generations/{generation_id}/media`): audio and original URLs.
- GET [List models](https://diffio.ai/docs/api-reference/list-models/) (`/models`): Every model and its price per hour.

## Related pages

- Previous: [Restore a video and stream it](https://diffio.ai/docs/developers/guides/restore-video-and-stream/): Video upload → HLS stream
- Next: [Clean up a back catalogue](https://diffio.ai/docs/developers/guides/clean-up-a-back-catalogue/): Folder → restores → usage
