# Seedream 4 \[Direct API]

{% hint style="info" %}
Чтобы отправлять авторизованные запросы нужно получить API ключ, как это сделать написано в разделе [**С чего начать?**](https://docs.gptunnel.ru/)
{% endhint %}

## Запрос

<mark style="color:green;">`POST`</mark> `https://gptunnel.ru/v1/media/generate`

Синхронный запрос вернёт результат сразу от модели.

## Пример запроса

{% tabs %}
{% tab title="NodeJS" %}

```typescript
import axios from 'axios'

const request = axios({
  method: 'POST',
  url: 'https://gptunnel.ru/v1/media/generate',
  headers: {
    // use your API key here
    Authorization: 'YOUR_API_KEY',
  },
  data: {
	"model":"seedream-4",
	"response_format":"url",
	"prompt": "Fine art fashion photography. Full-hight vertical portrait, gorgeous lithe supermodel, intricate orange and white face paint and a matching hood and translucent shawl. Her light skin and bold blue eyeshadow, orange lipstick accentuating features. Soft dreamy atmosphere, thick foggy, muted grey background with swirling mist, bright vibrant colours, futuristic avant-garde style, soft light, soft contrast, soft saturation",
	"size": "4K",
	"aspect_ratio": "21:9"
  },
})

request.then((result) => {
  console.log(result)
}).catch((error) => {
  console.error(error)
})
```

{% endtab %}

{% tab title="Curl" %}

```bash
curl --request POST \
  --url https://gptunnel.ru/v1/media/generate \
  --header 'Authorization: YOUR_API_KEY' \
  --header '{
	"model":"seedream-4",
	"response_format":"url",
	"prompt": "Fine art fashion photography. Full-hight vertical portrait, gorgeous lithe supermodel, intricate orange and white face paint and a matching hood and translucent shawl. Her light skin and bold blue eyeshadow, orange lipstick accentuating features. Soft dreamy atmosphere, thick foggy, muted grey background with swirling mist, bright vibrant colours, futuristic avant-garde style, soft light, soft contrast, soft saturation",
	"size": "4K",
	"aspect_ratio": "21:9"
  }'
```

{% endtab %}
{% endtabs %}

#### Параметры запроса

| Name                                     | Type           | Description                                                                                 |
| ---------------------------------------- | -------------- | ------------------------------------------------------------------------------------------- |
| model<mark style="color:red;">\*</mark>  | string         | Уникальный ID модели                                                                        |
| prompt<mark style="color:red;">\*</mark> | string         | Промпт запроса                                                                              |
| images                                   | Array\<string> | Массив ссылок / base64\_url  изображении для референса                                      |
| aspect\_ratio                            | string         | Соотношение сторон, допустимые значения '1:1', '16:9', '9:16', '4:3', '3:4', '21:9', '9:21' |
| response\_format                         | string         | Формат ответ, допустимые значения 'base64, 'url'                                            |
| size                                     | string         | Размер изображения, допустимые значения '1K', '2K', '3K', '4K'                              |

#### Заголовки

| Name                                            | Type   | Description |
| ----------------------------------------------- | ------ | ----------- |
| Authorization<mark style="color:red;">\*</mark> | string | API ключ    |

## Пример успешного ответа

```jsonp
{
	"code": 0,
	"id": "6901d3a98e0aa613c523cb9d",
	"created_at": 1761727401,
	"status": "done",
	"result": "https://ark-content-generation-v2-ap-southeast-1.tos-ap-southeast-1.volces.com/seedream-4-0/021761727389240f77831a0a17adee8e985c3ef7c2c9d7cc87e8d_0.jpeg?X-Tos-Algorithm=TOS4-HMAC-SHA256&X-Tos-Credential=AKLTYWJkZTExNjA1ZDUyNDc3YzhjNTM5OGIyNjBhNDcyOTQ%2F20251029%2Fap-southeast-1%2Ftos%2Frequest&X-Tos-Date=20251029T084321Z&X-Tos-Expires=86400&X-Tos-Signature=4081af37d922af1c9bc63c928462a5b1f65fb0f8324ddfbd119fc7eb8a3dacba&X-Tos-SignedHeaders=host",
	"cost": "8"
}
```

<figure><img src="https://1859504775-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPKoICCojZs9hCiX1hcZe%2Fuploads%2F9HHI70ywGydMJIuk8H6o%2F021761727389240f77831a0a17adee8e985c3ef7c2c9d7cc87e8d_0.jpeg?alt=media&#x26;token=3bf82fc0-ed3b-4a1e-8aa8-c679846da754" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
Ссылка на файл доступна в течение 24 часов. Если вы планируете получить доступ к сгенерированному файлу позже, рекомендуется сохранить его на вашем ресурсе.
{% endhint %}
