Get a media generation task
Getting a Task
Section titled “Getting a Task”GET
https://gptunnel.ru/api/v2/media/tasks/:idReturns the task by ID. Poll until the status is done or failed, or receive the result through a webhook.
Path parameters
| Parameter | Type | Description |
|---|---|---|
id* | string | Identifier from the creation response, 24 characters |
Example request
Section titled “Example request”Set GPTUNNEL_API_KEY to your API key and TASK_ID to the id field from the task creation response.
import jsonimport osfrom urllib.request import Request, urlopen
task_id = os.environ['TASK_ID']url = f'https://gptunnel.ru/api/v2/media/tasks/{task_id}'request = Request(url, headers={'Authorization': os.environ['GPTUNNEL_API_KEY']})with urlopen(request, timeout=30) as response: print(json.load(response)['status'])curl --fail-with-body "https://gptunnel.ru/api/v2/media/tasks/${TASK_ID:?Set TASK_ID}" \ --header "Authorization: ${GPTUNNEL_API_KEY:?Set GPTUNNEL_API_KEY}"const key = process.env.GPTUNNEL_API_KEYif (!key) throw new Error('Set GPTUNNEL_API_KEY')const id = process.env.TASK_IDif (!id) throw new Error('Set TASK_ID')const response = await fetch(`https://gptunnel.ru/api/v2/media/tasks/${encodeURIComponent(id)}`, { headers: { Authorization: key } })if (!response.ok) throw new Error(await response.text())const data = await response.json()console.log(data.status)Example response (done)
Section titled “Example response (done)”{ "code": 0, "id": "6a61e021a6e77553a989c41d", "model": "kling-v3", "status": "done", "prompt": "a red fox running through snow, cinematic", "params": { "resolution": "1080p", "duration": 5, "aspect_ratio": "16:9" }, "price": 210, "result": [ { "url": "https://cdn.gptunnel.com/predication/6a61e021a6e77553a989c41d_result.mp4" } ], "created_at": 1784799265}Example of response (music, multiple tracks)
Section titled “Example of response (music, multiple tracks)”{ "code": 0, "id": "6a61e021a6e77553a989c41e", "model": "suno", "status": "done", "prompt": "lo-fi beat for late night coding", "price": 16.8, "result": [ { "url": "https://cdn.gptunnel.com/suno/..._1.mp3", "id": "9f2c1b7a-...", "cover_url": "https://cdn.gptunnel.com/suno/..._1.jpg", "duration": 128, "title": "Late Night Compile", "lyric": "[Verse]\n...", "tags": "lo-fi, mellow, rainy" }, { "url": "https://cdn.gptunnel.com/suno/..._2.mp3", "id": "4d81ea03-...", "cover_url": "https://cdn.gptunnel.com/suno/..._2.jpg", "duration": 131, "title": "Late Night Compile", "tags": "lo-fi, mellow, rainy" } ], "created_at": 1784799265}Suno returns two tracks for each task in result. The id field identifies each track at the provider.
Example of response (failure)
Section titled “Example of response (failure)”{ "code": 0, "id": "6a61e021a6e77553a989c41d", "model": "kling-v3", "status": "failed", "error": { "code": 1001, "title": "SENSITIVE_CONTENT", "message": "Sensitive content has been detected in your request or uploaded files. Please check the text and media and try again." }, "result": [], "created_at": 1784799265}Fields of task object
Section titled “Fields of task object”| Parameter | Type | Description |
|---|---|---|
id* | string | Task Identifier |
model | string | ID of the requested model. If a retired model was replaced, this remains the ID you originally sent. The x-model-served header in the task creation response identifies the model that ran it. |
status* | string | queued | running | done | failed |
params | object | Generation parameters applied to the task |
price | number | Amount charged in rubles |
result* | array | Array of results when status is done. Otherwise it is empty. Each item has a url. Models that produce multiple files return items in the order they become available. Music items also include id, cover_url, duration, title, lyric and tags. |
error | object | Failure details when status is failed. Use code as a stable value when handling failures. The title field gives a machine-readable reason that can be more specific than code. The message field is a human-readable description. |
webhook | object | Present if the creation request included webhook_url. The url field is the recipient URL. The status is pending, delivered, or failed. |
trace_id | string | Trace ID, if available. Include it with the task id when contacting support. |
created_at | number | Time of creation (Unix, seconds) |