# Files

Models that take images, video or audio accept them in any of three forms. Each model page marks its file
parameters (for example `image`, `images`, `videos`, `audios`).

## 1. A public URL

Any `https://` (or `http://`) URL that the model can download:

```json
{ "image": "https://example.com/photos/product.jpg" }
```

The file must be reachable without cookies or login, and stay reachable until the request has started. Each model
page lists the size and dimension limits of its file parameters.

## 2. A data URI

Small files can go inline as a `data:` URI of up to 10 MB:

```json
{ "image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..." }
```

Base64 makes the body about a third larger than the file, so prefer uploads for anything big.

## 3. An upload

For local files, ask for an upload URL, `PUT` the bytes there, and pass the returned `file_url` to the model.
Creating the upload URL is free.

```bash 1 · Get an upload URL
curl -X POST "https://api.doitong.com/v1/files" \
  -H "Authorization: Bearer $DOITONG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"filename": "product.jpg", "content_type": "image/jpeg", "size": 482113}'
```

```json 201 Created · upload
{
  "object": "upload",
  "upload_url": "https://…signed upload URL…",
  "file_url": "https://content.doitong.com/…/product.jpg",
  "method": "PUT",
  "headers": { "Content-Type": "image/jpeg" },
  "content_type": "image/jpeg",
  "expires_in": 3600,
  "max_bytes": 15728640
}
```

```bash 2 · Upload the bytes with exactly the returned headers
curl -X PUT "<upload_url>" -H "Content-Type: image/jpeg" --data-binary @product.jpg
```

```bash 3 · Use file_url as the model input
curl -X POST "https://api.doitong.com/v1/run/{model_id}?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image": "https://content.doitong.com/…/product.jpg", "prompt": "..."}'
```

- Supported uploads: `.jpg`, `.jpeg`, `.png`, `.webp` (up to 15 MB) and `.mp4`, `.mov`, `.webm` (up to 200 MB).
  The extension sets the type; `content_type` must match it.
- The upload URL is valid for one hour. The `file_url` stays valid.
- For audio, use a public URL or a data URI.

## Output files

> [!TIP]
> Generated files are copied to our storage and returned in `outputs[].url` as links on `content.doitong.com`. You can
> pass them straight into another model, for example an image from a text-to-image model into an image-to-video model.

You choose how long output files are kept:

- **Forever** (`permanent`, the default): until you delete them, for 100 API credits
  ($0.10) per GB per month, charged once a day from the API balance (1 GB = 1024³ bytes).
- **7 days** (`temporary`): free, then deleted from our storage.

Set the default with the "Keep files forever" switch in the [dashboard](https://doitong.com/developers/dashboard#balance) or with
`PATCH /account/storage`, and override it per run with `?storage=temporary` (or `permanent`):

```bash
curl -X PATCH "https://api.doitong.com/v1/account/storage" \
  -H "Authorization: Bearer $DOITONG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"mode": "temporary"}'
```

Each request shows its own `storage` (`mode`, `bytes`, `expires_at`, `expired`). The setting applies to new requests;
files you already keep forever stay until you delete them with `DELETE /requests/{id}/files` (see
[Requests](https://doitong.com/developers/docs/requests#delete-files)). If the API balance cannot pay for storage, you get an email
and 30 days to top up before kept files become temporary.
