> 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/api-reference/introduction/.

# Diffio API reference: base URL, auth and errors

Use this reference to integrate the Diffio API. Every endpoint speaks JSON over HTTPS at `https://api.diffio.ai/v2`.

Check your key with a first request (`pip install diffio` or `npm install diffio`). It lists your account's projects; see [List projects](https://diffio.ai/docs/api-reference/list-projects/) for the response shape.

**Python**

```python
import os
from diffio import DiffioClient

key = os.environ["DIFFIO_API_KEY"]
client = DiffioClient(api_key=key)

page = client.projects.list()
```

**Node.js**

```javascript
import { DiffioClient } from "diffio"

const client = new DiffioClient({
  apiKey: process.env.DIFFIO_API_KEY,
})

const page = await client.projects.list()
```

**cURL**

```bash
curl "https://api.diffio.ai/v2/projects" \
  -H "Authorization: Bearer $DIFFIO_API_KEY"
```

1. URL base URL + resource path
2. Header `Authorization: Bearer <apiKey>`
3. Response `snake_case` JSON resource or page

## API reference essentials

1. Your code or SDK `GET · POST · PUT · DELETE` resource path, Bearer key header
2. Success `200` `201` `202` `JSON` `snake_case` fields for each resource
3. Error `4xx` `{"error": {...}}` `code`, `message`, `request_id`, optional `details`

### 1. Base URL and OpenAPI spec

Append each endpoint path to the production base URL.

`https://api.diffio.ai/v2`

Fetch the machine-readable OpenAPI 3.1.0 specification at `GET https://api.diffio.ai/v2/openapi.json` (public, no API key required).

The API version is in the path; within it, changes only add. Releases and the versioning rules are in the [Changelog](https://diffio.ai/docs/overview/changelog/#versioning).

### 2. Authentication

Send your API key in the `Authorization` header on every non-public request. Create and manage keys on the [API keys](https://diffio.ai/developers/api-keys/) page in the developer dashboard.

- `Authorization: Bearer <apiKey>`

Each endpoint page lists the scope it requires (`projects:read`, `projects:write`, `generations:read`, `generations:write`, `artifacts:read`, `usage:read`, or `webhooks:write`). [List models](https://diffio.ai/docs/api-reference/list-models/), [Get a share](https://diffio.ai/docs/api-reference/get-share/), and `GET /openapi.json` are public and need no key.

### 3. Request conventions

- `snake_case` JSON fields
- `Content-Type: application/json`
- `Idempotency-Key`
- `Diffio-End-User`
- `limit` and `cursor` pagination
- `X-Request-Id` response header
- `OPTIONS` for CORS preflight

- **JSON bodies:** `POST` and `PUT` calls that take fields accept a JSON object (`{...}`) with `snake_case` keys such as `file_name`, `size_bytes`, and `preview_seconds`.
- **`Idempotency-Key`:** Optional header (up to 255 characters) honoured on [Create a project](https://diffio.ai/docs/api-reference/create-project/), [Create a generation](https://diffio.ai/docs/api-reference/create-generation/), and [Edit a generation's transcript](https://diffio.ai/docs/api-reference/create-transcript-edit/). Repeating the same request returns the original resource without charging twice; changing any body field returns `409` with code `idempotency_key_conflict`. Both SDKs send an `Idempotency-Key` automatically when you omit one.
- **`Diffio-End-User`:** Optional header (up to 128 characters) for multi-tenant apps. Requests carrying this header assign new projects to that `end_user` and scope project reads, generations, shares, and [Get usage](https://diffio.ai/docs/api-reference/usage-summary/) reports to that end user. Omit it on account-wide calls such as [Open the webhook portal](https://diffio.ai/docs/api-reference/open-webhook-portal/).
- **Cursor pagination:** [List projects](https://diffio.ai/docs/api-reference/list-projects/) and [List a project's generations](https://diffio.ai/docs/api-reference/list-project-generations/) return `{"object": "list", "data": [...], "next_cursor": "..."}` newest first. Pass `limit` (`1` to `100`, default `20`) and pass `next_cursor` as `cursor` until `next_cursor` is `null`.

**Uploads, playback URLs, and models**

- [Create a project](https://diffio.ai/docs/api-reference/create-project/) returns `upload.requests` (`start`, `part` in 32 MiB chunks, `complete`, and `abort`) authenticated with `Authorization: Bearer {upload.upload_token}` (valid for 24 hours). Files can be up to 2 GB (`2,147,483,648` bytes) with no media length limit. Call [Complete a project's upload](https://diffio.ai/docs/api-reference/complete-project-upload/) for immediate readiness, or let the upload edge report completion after about 30 seconds. Both official SDKs handle multipart uploads and retries automatically.
- [Get a playback grant](https://diffio.ai/docs/api-reference/get-generation-media/) returns signed media URLs in `files` (`audio`, `video`, `hls_master`, `transcript`, `stems_manifest`, `original`, and waveforms) valid for 6 hours until `expires_at`, with no API key required. Append `?download=<filename>` to a media URL to trigger a browser file download.
- [List models](https://diffio.ai/docs/api-reference/list-models/) returns hosted models (`diffio-4.7-flash` at $5/hour and `diffio-4.7-pro` at $10/hour), rolling tier aliases (`diffio-flash` and `diffio-pro`), and retired model names. Retired model names run on the current hosted model of the same tier (`substituted: true`) at the lower of the two list prices ([Models](https://diffio.ai/docs/overview/models/)).

### 4. Error responses

Every 4xx and 5xx response returns one JSON shape: `error.code` (stable `snake_case` identifier to branch on), `error.message`, `error.request_id` (also sent in the `X-Request-Id` header), and an optional `error.details` object when structured context applies.

**Error response shape**

```json
{
  "error": {
    "code": "unknown_model",
    "message": "nope is not a Diffio model. See GET /v2/models.",
    "request_id": "f064e4099097414da3fb5b37684ab1bb",
    "details": {
      "field": "model",
      "models": [
        "diffio-4.7-flash",
        "diffio-4.7-pro",
        "diffio-flash",
        "diffio-pro"
      ]
    }
  }
}
```

#### Common error codes

| Status and `code` | When it happens |
| --- | --- |
| `400` `invalid_field` · `missing_field` | Malformed JSON (`invalid_json`), missing or invalid body field (`details.field`), bad query parameter (`invalid_parameter`, `details.parameter`), oversized header (`invalid_header`), or unknown model (`unknown_model`). |
| `401` `missing_api_key` · `invalid_api_key` | No API key was sent, or the API key was not recognized. |
| `403` `permission_denied` | The key is inactive, lacks the required scope, or sent `Diffio-End-User` to an account-only route. |
| `404` `*_not_found` | Unknown resource for this account or end user (`project_not_found`, `generation_not_found`, `export_not_found`, `share_not_found`, `transcript_not_found`, `route_not_found`). |
| `405` `method_not_allowed` | The path exists, but does not accept this HTTP method; check the `Allow` header. |
| `409` `not_ready` · `not_available` · `revision_conflict` | State conflict: prerequisite still running (`not_ready`), permanently unavailable (`not_available`), stale save revision (`revision_conflict`, `details.current_revision`), or reused `Idempotency-Key` with a different body (`idempotency_key_conflict`). |
| `413` `upload_too_large` · `415` `unsupported_media_type` | File exceeds 2 GB (`upload_too_large`), draft JSON exceeds 900,000 bytes (`transcript_draft_too_large`), or file extension/MIME type is not supported audio or video (`unsupported_media_type`). |
| `429` `rate_limited` | Too many requests of this kind in a short time (for example, more than 10 [assistant feedback](https://diffio.ai/docs/api-reference/create-transcript-assistant-feedback/) reports in an hour); retry later with backoff, honouring `Retry-After` when sent. |
| `500` `internal_error` · `503` `unavailable` | A transient server error occurred (`internal_error`, `generation_start_failed`, `unavailable`); retry with exponential backoff. |

Every code, with its retry rule and the codes a failed resource reports: [Errors](https://diffio.ai/docs/api-reference/errors/).

#### Billing error codes (`402`)

| Status and `code` | Meaning | What to do |
| --- | --- | --- |
| `402` `insufficient_credit` | Your API credit is used up, or cannot cover this file. | Add credit on the Billing page. |
| `402` `needs_payment_method` | The credit is used up, or cannot cover this file, and no payment method is saved. | Add a payment method on the Billing page. |
| `402` `payment_failed` | A payment for API usage failed, or the last invoice of ended card billing is unpaid. | On the Billing page, select Update payment method and choose a card for your subscription, or Pay invoice once card billing has ended. |
| `402` `usage_limit_reached` | Unbilled usage reached $100; it is being charged now. | Wait for the charge to complete; the API continues as soon as it does. |

`needs_payment_method`, `payment_failed` and `usage_limit_reached` reach only accounts with card billing (a card added before prepaid credit).

**Example 402 responses and billing details**

**402 insufficient_credit**

```json
{
  "error": {
    "code": "insufficient_credit",
    "message": "This file needs about $1.25 of API credit and your balance is $0.40. Add credit in the developer dashboard to continue.",
    "request_id": "f064e4099097414da3fb5b37684ab1bb",
    "details": {
      "estimated_cost_cents": 125,
      "remaining_credit_cents": 40
    }
  }
}
```

**402 payment_failed**

```json
{
  "error": {
    "code": "payment_failed",
    "message": "A payment for API usage failed. On the developer dashboard's Billing page, select Update payment method and choose a card for your subscription.",
    "request_id": "f064e4099097414da3fb5b37684ab1bb"
  }
}
```

**402 payment_failed, card billing ended**

```json
{
  "error": {
    "code": "payment_failed",
    "message": "The last invoice of your API card billing is unpaid. Pay it from the developer dashboard's Billing page to continue.",
    "request_id": "f064e4099097414da3fb5b37684ab1bb"
  }
}
```

**402 usage_limit_reached**

```json
{
  "error": {
    "code": "usage_limit_reached",
    "message": "Your unbilled API usage reached $100.00. It is being billed to your payment method now, and the API continues as soon as that payment completes.",
    "request_id": "f064e4099097414da3fb5b37684ab1bb"
  }
}
```

An `insufficient_credit` or `needs_payment_method` refusal from a credit check includes `details.estimated_cost_cents` and `details.remaining_credit_cents`; treat `details` as optional. A generation created before its upload finishes is checked again when processing starts, and fails with the same error code in `generation.error.code` if credit cannot cover the recording. [Billing](https://diffio.ai/docs/overview/administration/billing/) explains credit and card billing.

### 5. Rate limits

No general per-key quota: Most endpoints set no per-key request limit; when workers are busy, generations wait in a queue (see `queue` on [Get a generation](https://diffio.ai/docs/api-reference/get-generation/)). A few actions have their own limits, per end user (or per account without `Diffio-End-User`):

- [Ask the edit assistant](https://diffio.ai/docs/api-reference/create-transcript-assistant-turn/): up to 30 turns per 10 minutes plus a daily cap; a turn over the limit ends `failed` with `error.code` `rate_limited`.
- [Send assistant feedback](https://diffio.ai/docs/api-reference/create-transcript-assistant-feedback/): up to 10 reports per hour; more answer `429` `rate_limited`.

Treat any `429` as "retry later with backoff"; both SDKs do this for calls that are safe to repeat and honour `Retry-After`. Usage is billed per second ([API pricing](https://diffio.ai/api-pricing/)).

## Endpoints

Browse all 30 endpoints across 8 categories: models, projects, generations, separated tracks, transcripts, shares, usage, and webhooks.

- [Models 1](#endpoints-models)
- [Projects 6](#endpoints-projects)
- [Generations 6](#endpoints-generations)
- [Separated tracks 4](#endpoints-separated-tracks)
- [Transcripts 7](#endpoints-transcripts)
- [Shares 4](#endpoints-shares)
- [Usage 1](#endpoints-usage)
- [Webhooks 1](#endpoints-webhooks)

### Models

1 endpoint

| Endpoint, method and path | What it does |
| --- | --- |
| [List models](https://diffio.ai/docs/api-reference/list-models/) GET `/models` | List every hosted model, tier alias, and retired model name with hourly list pricing. |

### Projects

6 endpoints

| Endpoint, method and path | What it does |
| --- | --- |
| [Create a project](https://diffio.ai/docs/api-reference/create-project/) POST `/projects` | Create a project for one audio or video file and receive multipart upload instructions. |
| [List projects](https://diffio.ai/docs/api-reference/list-projects/) GET `/projects` | List projects on the account newest first with cursor pagination. |
| [Get a project](https://diffio.ai/docs/api-reference/get-project/) GET `/projects/{project_id}` | Retrieve one project's upload status, media metadata, and latest generation. |
| [Delete a project](https://diffio.ai/docs/api-reference/delete-project/) DELETE `/projects/{project_id}` | Delete a project and all of its stored uploads, generations, exports, and shares. |
| [Get new upload instructions](https://diffio.ai/docs/api-reference/reopen-project-upload/) POST `/projects/{project_id}/upload` | Mint fresh 24-hour multipart upload instructions for a project awaiting its file. |
| [Complete a project's upload](https://diffio.ai/docs/api-reference/complete-project-upload/) POST `/projects/{project_id}/upload/complete` | Verify and prepare a finished multipart upload immediately instead of waiting for edge callback. |

### Generations

6 endpoints

| Endpoint, method and path | What it does |
| --- | --- |
| [Create a generation](https://diffio.ai/docs/api-reference/create-generation/) POST `/projects/{project_id}/generations` | Start a speech restoration generation on a project with a chosen model. |
| [List a project's generations](https://diffio.ai/docs/api-reference/list-project-generations/) GET `/projects/{project_id}/generations` | List every restore and transcript edit generation on a project, newest first. |
| [Get a generation](https://diffio.ai/docs/api-reference/get-generation/) GET `/projects/{project_id}/generations/{generation_id}` | Check one generation's status, live stage progress, queue position, available files, or failure reason. |
| [Get a playback grant](https://diffio.ai/docs/api-reference/get-generation-media/) GET `/projects/{project_id}/generations/{generation_id}/media` | Mint 6-hour signed playback and download URLs for a generation's audio, video, HLS, stems, and transcript files. |
| [Estimate a transcript edit](https://diffio.ai/docs/api-reference/estimate-transcript-edit/) POST `/projects/{project_id}/generations/{generation_id}/edits/estimate` | Estimate the changed word runs, 30-second windows, and maximum billable seconds of a Pro transcript edit. |
| [Edit a generation's transcript](https://diffio.ai/docs/api-reference/create-transcript-edit/) POST `/projects/{project_id}/generations/{generation_id}/edits` | Edit a finished Pro generation's transcript and re-restore only the windows around changed words. |

### Separated tracks

4 endpoints

| Endpoint, method and path | What it does |
| --- | --- |
| [Get the saved mix](https://diffio.ai/docs/api-reference/get-generation-mix/) GET `/projects/{project_id}/generations/{generation_id}/mix` | Read the saved background gain, speech leveling setting, and revision for a generation's separated tracks. |
| [Save the mix](https://diffio.ai/docs/api-reference/save-generation-mix/) PUT `/projects/{project_id}/generations/{generation_id}/mix` | Save the background track gain and speech leveling setting for a generation's separated tracks. |
| [Create an export](https://diffio.ai/docs/api-reference/create-generation-export/) POST `/projects/{project_id}/generations/{generation_id}/exports` | Render a downloadable or inline-playable file from a generation's separated speech and background tracks. |
| [Get an export](https://diffio.ai/docs/api-reference/get-generation-export/) GET `/projects/{project_id}/generations/{generation_id}/exports/{export_id}` | Poll an export's render status and mint a fresh 6-hour download or playback URL once ready. |

### Transcripts

7 endpoints

| Endpoint, method and path | What it does |
| --- | --- |
| [Get a generation's transcript](https://diffio.ai/docs/api-reference/get-transcript/) GET `/projects/{project_id}/generations/{generation_id}/transcript` | Retrieve a generation's normalized word-timed transcript for display, assistant turns, or Pro edits. |
| [Get the transcript draft](https://diffio.ai/docs/api-reference/get-transcript-draft/) GET `/projects/{project_id}/generations/{generation_id}/transcript/draft` | Read the saved JSON editor draft and compare-and-swap revision for a generation's transcript. |
| [Save the transcript draft](https://diffio.ai/docs/api-reference/save-transcript-draft/) PUT `/projects/{project_id}/generations/{generation_id}/transcript/draft` | Save an editor's JSON draft state (up to 900,000 bytes) for a generation's transcript. |
| [Delete the transcript draft](https://diffio.ai/docs/api-reference/delete-transcript-draft/) DELETE `/projects/{project_id}/generations/{generation_id}/transcript/draft` | Delete a generation's saved transcript editor draft with optional revision checking. |
| [Ask the edit assistant](https://diffio.ai/docs/api-reference/create-transcript-assistant-turn/) POST `/projects/{project_id}/generations/{generation_id}/transcript/assistant/turns` | Start an asynchronous edit-assistant chat turn on a finished Pro generation's transcript. |
| [Get an edit assistant turn](https://diffio.ai/docs/api-reference/get-transcript-assistant-turn/) GET `/projects/{project_id}/generations/{generation_id}/transcript/assistant/turns/{turn_id}` | Poll an edit-assistant turn for its reply, word-level edit proposals, moments, or failure details. |
| [Send assistant feedback](https://diffio.ai/docs/api-reference/create-transcript-assistant-feedback/) POST `/projects/{project_id}/generations/{generation_id}/transcript/assistant/feedback` | Send the Diffio team a bug report or an idea about the edit assistant, with the conversation if wanted. |

### Shares

4 endpoints

| Endpoint, method and path | What it does |
| --- | --- |
| [Publish a project's share](https://diffio.ai/docs/api-reference/publish-project-share/) PUT `/projects/{project_id}/share` | Publish or update a project's public playback share, optionally pinned to one generation or preview length. |
| [Get a project's share](https://diffio.ai/docs/api-reference/get-project-share/) GET `/projects/{project_id}/share` | Read a project's currently published share and its playback URLs using your API key. |
| [Revoke a project's share](https://diffio.ai/docs/api-reference/revoke-project-share/) DELETE `/projects/{project_id}/share` | Revoke a project's published share so its public share ID and media URLs stop working. |
| [Get a share](https://diffio.ai/docs/api-reference/get-share/) GET `/shares/{share_id}` | Fetch a published share's playback metadata and signed media URLs without an API key. |

### Usage

1 endpoint

| Endpoint, method and path | What it does |
| --- | --- |
| [Get usage](https://diffio.ai/docs/api-reference/usage-summary/) GET `/usage` | Report generation counts, billable seconds, and USD list-price usage in total and by model. |

### Webhooks

1 endpoint

| Endpoint, method and path | What it does |
| --- | --- |
| [Open the webhook portal](https://diffio.ai/docs/api-reference/open-webhook-portal/) POST `/webhooks/portal` | Create a short-lived login link to the hosted webhook portal to manage endpoints and secrets. |
