# Imagine 3

{% 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:"google-imagen-3",
    ar: "9:21",
    prompt: "Cinematic, high-quality photo of Thanos in a serene Japanese forest, clad in a traditional samurai armor made of white porcelain, adorned with intricate blue paintings that evoke the art of ancient Japanese ceramics. The armor's delicate, hand-painted designs seem to shimmer in the soft, dappled light filtering through the forest canopy. Thanos wields a heavy, curved katana with a worn, wooden scabbard, its blade gleaming with a subtle, deadly sheen. The scene is captured in a dramatic, close-up angle, with the misty forest atmosphere and the soft, golden light of dawn or dusk accentuating the armor's ethereal beauty, while the weight and power of the katana seem to anchor Thanos to the earth, ready to unleash his fury upon the world."
  },
})

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":"google-imagen-3",
    "ar": "9:21",
    "prompt": "Cinematic, high-quality photo of Thanos in a serene Japanese forest, clad in a traditional samurai armor made of white porcelain, adorned with intricate blue paintings that evoke the art of ancient Japanese ceramics. The armor's delicate, hand-painted designs seem to shimmer in the soft, dappled light filtering through the forest canopy. Thanos wields a heavy, curved katana with a worn, wooden scabbard, its blade gleaming with a subtle, deadly sheen. The scene is captured in a dramatic, close-up angle, with the misty forest atmosphere and the soft, golden light of dawn or dusk accentuating the armor's ethereal beauty, while the weight and power of the katana seem to anchor Thanos to the earth, ready to unleash his fury upon the world."
  }'
```

{% endtab %}
{% endtabs %}

#### Request Body

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

#### Headers

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

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

```jsonp
{
	"code": 0,
	"id": "6880f043e6060500018821de",
	"model": "google-imagen-3",
	"prompt": "Cinematic, high-quality photo of Thanos in a serene Japanese forest, clad in a traditional samurai armor made of white porcelain, adorned with intricate blue paintings that evoke the art of ancient Japanese ceramics. The armor's delicate, hand-painted designs seem to shimmer in the soft, dappled light filtering through the forest canopy. Thanos wields a heavy, curved katana with a worn, wooden scabbard, its blade gleaming with a subtle, deadly sheen. The scene is captured in a dramatic, close-up angle, with the misty forest atmosphere and the soft, golden light of dawn or dusk accentuating the armor's ethereal beauty, while the weight and power of the katana seem to anchor Thanos to the earth, ready to unleash his fury upon the world. --ar 9:21",
	"created_at": 1753280579,
	"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:"6880f043e6060500018821de"
  },
})

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

{% endtab %}
{% endtabs %}

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

```jsonp
{
	"code": 0,
	"id": "6880f043e6060500018821de",
	"model": "google-imagen-3",
	"prompt": "Cinematic, high-quality photo of Thanos in a serene Japanese forest, clad in a traditional samurai armor made of white porcelain, adorned with intricate blue paintings that evoke the art of ancient Japanese ceramics. The armor's delicate, hand-painted designs seem to shimmer in the soft, dappled light filtering through the forest canopy. Thanos wields a heavy, curved katana with a worn, wooden scabbard, its blade gleaming with a subtle, deadly sheen. The scene is captured in a dramatic, close-up angle, with the misty forest atmosphere and the soft, golden light of dawn or dusk accentuating the armor's ethereal beauty, while the weight and power of the katana seem to anchor Thanos to the earth, ready to unleash his fury upon the world. --ar 9:21",
	"created_at": 1753280579,
	"status": "done",
	"url": "https://timenote.storage.yandexcloud.net/exp48h/6880f043e6060500018821de_result.webp"
}
```

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

<figure><img src="/files/pFsngoAbhJAN0t3vU7C9" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.gptunnel.ru/media-api/imagine-3.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
