# Fajlo

Modelura so len kipo, video vaj audio prihvatin len ande trin forma. Sakono modelosko lil sikavel lesqe fajlonqe parametra (sar `image`, `images`, `videos`, `audios`).

## 1. Jekh publiku URL

Savo `https://` (vaj `http://`) URL so o modelo shaj downloadil:

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

O fajlo trubul te avel resno bi cookies vaj login, thaj te ačhel resno dži o mangipen startisardilo. Sakono modelosko lil sikavel o limitura e fajlongo barehipnasko thaj dimensionongo.

## 2. Jekh data URI

Tikne fajlo shaj aven inline sar jekh `data:` URI dži 10 MB:

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

Base64 kerel o body ande jekh trito maj baro katar o fajlo, kadaleste preferin uploadura pентru sa so si baro.

## 3. Jekh upload

Pентru lokalno fajlo, mang jekh upload URL, `PUT` o bytes odothe, thaj de o palpale-kerdo `file_url` ko modelo. Keripen e upload URL-esko si bi pais.

```bash 1 · Le jekh upload URL
curl -X POST "https://api.doitong.ru/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 · Uploadisar o bytes le exaktno palpale-kerde headers-enca
curl -X PUT "<upload_url>" -H "Content-Type: image/jpeg" --data-binary @product.jpg
```

```bash 3 · Labar file_url sar inputo modelosko
curl -X POST "https://api.doitong.ru/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": "..."}'
```

- Lijarde uploadura: `.jpg`, `.jpeg`, `.png`, `.webp` (dži 15 MB) thaj `.mp4`, `.mov`, `.webm` (dži 200 MB). O extension kidel o tipo; `content_type` trubul te matchil les.
- O upload URL validno si pентru jekh ora. O `file_url` ačhel validno.
- Pентru audio, labar jekh publiku URL vaj data URI.

## Rezultatosqe fajlo

> [!TIP]
> Generirime fajlo si kopirime amare arakhipneste thaj dino ande `outputs[].url` sar linkura ko `content.doitong.com`. Shaj bičhales len direktno ande aver modelo, sar jekh kipo katar jekh text-to-image modelo ande jekh image-to-video modelo.

Tu kidel sar dugo te ačhen o rezultatosqe fajlo:

- **Vično** (`permanent`, o standardno): dži tu borrares len, pентru 100 API krediti ($0.10) per GB per minuta, charge-ime jekhvar ande dives katar o API balanso (1 GB = 1024³ bytes).
- **7 divesa** (`temporary`): bi pais, palal borrarime amare arakhipnestar.

Kerdol o standardno le "Astar fajlura sa dživdipe" switch-esa ande [dashboard](https://doitong.com/developers/dashboard#balance) vaj le `PATCH /account/storage`-esa, thaj override-isar les per run le `?storage=temporary`-sa (vaj `permanent`):

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

Sakono mangipen sikavel lesko korkoro `storage` (`mode`, `bytes`, `expires_at`, `expired`). O setipen applies ko neve mangipena; fajlo so tu već arakhes vično ačhen dži tu borrares len le `DELETE /requests/{id}/files`-sa (dikh [Mangipena](https://doitong.com/developers/docs/requests#delete-files)). Kana o API balanso na del te paisol pентru arakhipen, reses email thaj 30 divesa te pheres tiro balanso anglal o arakhade fajlo aven temporary.
