# Image - 1

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

## Запрос

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

Асинхронный запрос вернёт задачу и её идентификатор — сохраните его для последующего получения ссылки на результат.

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

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

```typescript
import axios from 'axios'

const request = axios({
  method: 'POST',
  url: 'https://gptunnel.ru/v1/media/create',
  headers: {
    // use your API key here
    Authorization: 'YOUR_API_KEY',
  },
  data: {
    model:"gpt-image-1-high",
    prompt: "Subject: stunning afro-futuristic female model with metallic blue makeup Subject Position: confidently standing in center frame, facing camera with slight head tilt Photo Type: high-fashion editorial portrait Wearing: reflective silver bodysuit with sculptural shoulder pads Lens: 85mm f/1.4 Environment: minimalist white studio with chrome panels Environment Focus: shallow depth of field, background softly blurred Environment Description: smooth reflective floor, hints of neon light reflections Lighting: strong directional spotlight from the right, with soft fill light Time of Day: studio-lit, artificial Textures: glossy fabric, smooth skin, gleaming surfaces Atmosphere: bold and futuristic, assertive elegance Aesthetic: cyber-glam meets editorial minimalism Film Stock: Kodak Ektar 100"
  },
})

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/create \
  --header 'Authorization: YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "model":"gpt-image-1-high",
    "prompt": "Subject: stunning afro-futuristic female model with metallic blue makeup Subject Position: confidently standing in center frame, facing camera with slight head tilt Photo Type: high-fashion editorial portrait Wearing: reflective silver bodysuit with sculptural shoulder pads Lens: 85mm f/1.4 Environment: minimalist white studio with chrome panels Environment Focus: shallow depth of field, background softly blurred Environment Description: smooth reflective floor, hints of neon light reflections Lighting: strong directional spotlight from the right, with soft fill light Time of Day: studio-lit, artificial Textures: glossy fabric, smooth skin, gleaming surfaces Atmosphere: bold and futuristic, assertive elegance Aesthetic: cyber-glam meets editorial minimalism Film Stock: Kodak Ektar 100"
  }'
```

{% endtab %}
{% endtabs %}

#### Request Body

| Name                                     | Type           | Description                                                                 |
| ---------------------------------------- | -------------- | --------------------------------------------------------------------------- |
| model<mark style="color:red;">\*</mark>  | string         | Уникальный ID модели                                                        |
| prompt<mark style="color:red;">\*</mark> | string         | Промпт запроса                                                              |
| images                                   | Array\<string> | Массив ссылок на изображения для контекста                                  |
| ar                                       | string         | Соотношение сторон, допустимые значения '1:1', '16:9', '9:16', '4:3', '3:4' |

#### Headers

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

## Пример ответа /create

```jsonp
{
	"code": 0,
	"id": "687fab1e49832bb77d34db47",
	"model": "gpt-image-1-low",
	"prompt": "Subject: stunning afro-futuristic female model with metallic blue makeup Subject Position: confidently standing in center frame, facing camera with slight head tilt Photo Type: high-fashion editorial portrait Wearing: reflective silver bodysuit with sculptural shoulder pads Lens: 85mm f/1.4 Environment: minimalist white studio with chrome panels Environment Focus: shallow depth of field, background softly blurred Environment Description: smooth reflective floor, hints of neon light reflections Lighting: strong directional spotlight from the right, with soft fill light Time of Day: studio-lit, artificial Textures: glossy fabric, smooth skin, gleaming surfaces Atmosphere: bold and futuristic, assertive elegance Aesthetic: cyber-glam meets editorial minimalism Film Stock: Kodak Ektar 100",
	"created_at": 1753197342,
	"status": "idle",
	"url": null
}
```

После получения 24-значного идентификатора задачи вы можете вызвать метод для получения результата.

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

Запрос можно вызвать как **POST** так и **GET** методом передав `task_id` в query либо в body. Результатом выполнения запроса будет json объект с ссылкой на изображение.

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

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

```typescript
import axios from 'axios'

const request = axios({
  method: 'POST',
  url: 'https://gptunnel.ru/v1/media/result',
  headers: {
    // use your API key here
    Authorization: 'YOUR_API_KEY',
  },
  data: {
    task_id:"687fab1e49832bb77d34db47"
  },
})

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/result \
  --header 'Authorization: YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "task_id":"687fab1e49832bb77d34db47"
  }'
```

{% endtab %}
{% endtabs %}

## Пример ответа /result

```jsonp
{
	"code": 0,
	"id": "687fa9f2c69e500001e2f9a4",
	"model": "gpt-image-1-high",
	"prompt": "Subject: stunning afro-futuristic female model with metallic blue makeup Subject Position: confidently standing in center frame, facing camera with slight head tilt Photo Type: high-fashion editorial portrait Wearing: reflective silver bodysuit with sculptural shoulder pads Lens: 85mm f/1.4 Environment: minimalist white studio with chrome panels Environment Focus: shallow depth of field, background softly blurred Environment Description: smooth reflective floor, hints of neon light reflections Lighting: strong directional spotlight from the right, with soft fill light Time of Day: studio-lit, artificial Textures: glossy fabric, smooth skin, gleaming surfaces Atmosphere: bold and futuristic, assertive elegance Aesthetic: cyber-glam meets editorial minimalism Film Stock: Kodak Ektar 100",
	"created_at": 1753197042,
	"status": "done",
	"url": "https://storage.yandexcloud.net/timenote/exp48h/687fa9f2c69e500001e2f9a4-gpt-image-1-high-original.webp"
}
```

<figure><img src="https://1859504775-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPKoICCojZs9hCiX1hcZe%2Fuploads%2FRTnhhLXpnH29EIOzxPiE%2F687fa9f2c69e500001e2f9a4-gpt-image-1-high-original.webp?alt=media&#x26;token=0297116a-f4cc-4a2a-a7f5-21cb4ced3afc" alt=""><figcaption></figcaption></figure>

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