# Kōnae

Ka whakaae ngā tauira e whiwhi ana i ngā atahanga, ataata, ororongo rānei ki ngā momo e toru. Ka tohu ia whārangi tauira i ōna tawhā kōnae (hei tauira `image`, `images`, `videos`, `audios`).

## 1. He URL tūmatanui

Ko tēhea URL `https://` (ko `http://` rānei) ka taea e te tauira te tiki:

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

Me taea te toro atu ki te kōnae me te kore pihikete, takiuru rānei, ā, me wātea tonu kia tīmata rā anō te tono. Ka whakarārangihia e ia whārangi tauira ngā rohe rahi me te ahu mō ōna tawhā kōnae.

## 2. He URI raraunga

Ka taea ngā kōnae iti te whakauru hei URI `data:` tae atu ki te 10 MB:

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

Mā Base64 e whakanui te tinana kia tata ki te hautoru ake i te kōnae, nō reira me pai ake ngā tukunga mō ngā mea nui.

## 3. He tukunga

Mō ngā kōnae ā-rohe, tonoa he URL tuku, `PUT` ngā paita ki reira, ka tukuna te `file_url` kua whakahokia ki te tauira. He kore utu te hanga URL tuku.

```bash 1 · Tikina he URL tuku
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 · tuku
{
  "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 · Tukuna ngā paita me ngā pane kua whakahokia, kia ōrite tonu
curl -X PUT "<upload_url>" -H "Content-Type: image/jpeg" --data-binary @product.jpg
```

```bash 3 · Whakamahia file_url hei tāuru tauira
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": "..."}'
```

- Ngā tukunga e tautokona ana: `.jpg`, `.jpeg`, `.png`, `.webp` (tae atu ki te 15 MB) me `.mp4`, `.mov`, `.webm` (tae atu ki te 200 MB). Mā te toronga e whakarite te momo; me ōrite a `content_type`.
- Kotahi haora te wā whai mana o te URL tuku. Ka whai mana tonu a `file_url`.
- Mō te ororongo, whakamahia he URL tūmatanui, he URI raraunga rānei.

## Ngā kōnae putanga

> [!TIP]
> Ka tāruatia ngā kōnae i hangaia ki tō mātou rokiroki, ā, ka whakahokia ki `outputs[].url` hei hononga ki `content.doitong.com`. Ka taea te tuku tika ki tētahi atu tauira, hei tauira he atahanga mai i tētahi tauira text-to-image ki tētahi tauira image-to-video.

Māu e kōwhiri te roa e puritia ai ngā kōnae putanga:

- **Mō ake tonu atu** (`permanent`, te taunoa): kia mukua rā anō e koe, mō 100 whiwhinga API ($ 0.10) mō ia GB ia marama, ka utua kotahi ia rā mai i te toenga API (1 GB = 1024³ paita).
- **7 rā** (`temporary`): kore utu, kātahi ka mukua mai i tō mātou rokiroki.

Whakaritea te taunoa mā te pana "Pupurihia ngā kōnae mō ake tonu atu" i te [papatohu](https://doitong.com/developers/dashboard#balance), mā `PATCH /account/storage` rānei, ā, whakakapia mō ia whakahaere mā `?storage=temporary` (ko `permanent` rānei):

```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"}'
```

Ka whakaatu ia tono i tōna ake `storage` (`mode`, `bytes`, `expires_at`, `expired`). Ka pā te tautuhinga ki ngā tono hou; ka noho tonu ngā kōnae kua puritia e koe mō ake tonu atu kia mukua rā anō e koe mā `DELETE /requests/{id}/files` (tirohia [Ngā tono](https://doitong.com/developers/docs/requests#delete-files)). Ki te kore e taea e te toenga API te utu rokiroki, ka whiwhi īmēra koe, ā, e 30 rā hei tāpiri pūtea i mua i te noho rangitahi o ngā kōnae kua puritia.
