Retrieve task
curl --request GET \
--url https://api-direct.dimilinks.com/v1/tasks/{task_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api-direct.dimilinks.com/v1/tasks/{task_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api-direct.dimilinks.com/v1/tasks/{task_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-direct.dimilinks.com/v1/tasks/{task_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-direct.dimilinks.com/v1/tasks/{task_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api-direct.dimilinks.com/v1/tasks/{task_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-direct.dimilinks.com/v1/tasks/{task_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "img_xxx",
"task_id": "img_xxx",
"object": "image.task",
"status": "queued",
"progress": 50,
"created_at": 123,
"completed_at": 123,
"result": {
"created": 1777080000,
"task_id": "img_xxx",
"data": [
{
"url": "/p/img/img_xxx/0?exp=1777166400000&sig=...",
"file_id": "file_xxx"
}
]
},
"error": {
"message": "<string>",
"type": "invalid_request_error",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"code": "<string>"
}
}视频 / grok-imagine-video
Retrieve video task
查询视频生成任务的状态和结果链接。
GET
/
tasks
/
{task_id}
Retrieve task
curl --request GET \
--url https://api-direct.dimilinks.com/v1/tasks/{task_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api-direct.dimilinks.com/v1/tasks/{task_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api-direct.dimilinks.com/v1/tasks/{task_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-direct.dimilinks.com/v1/tasks/{task_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-direct.dimilinks.com/v1/tasks/{task_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api-direct.dimilinks.com/v1/tasks/{task_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-direct.dimilinks.com/v1/tasks/{task_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "img_xxx",
"task_id": "img_xxx",
"object": "image.task",
"status": "queued",
"progress": 50,
"created_at": 123,
"completed_at": 123,
"result": {
"created": 1777080000,
"task_id": "img_xxx",
"data": [
{
"url": "/p/img/img_xxx/0?exp=1777166400000&sig=...",
"file_id": "file_xxx"
}
]
},
"error": {
"message": "<string>",
"type": "invalid_request_error",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"code": "<string>"
}
}视频与图片任务共用
如果你的产品要把视频展示给终端用户,建议在你的服务端代理这一次下载:先用密钥取到视频,再以你自己的鉴权下发,避免把 DimiLinks 密钥暴露到浏览器。
/v1/tasks/{task_id}。提交 /v1/videos/generations 后拿到 task_id,再用本接口轮询。
请求
curl "https://api-direct.dimilinks.com/v1/tasks/video_xxx" \
-H "Authorization: Bearer $DIMILINKS_API_KEY"
进行中响应
{
"data": {
"id": "video_xxx",
"task_id": "video_xxx",
"status": "processing",
"progress": 35,
"created_at": 1777080000
}
}
成功响应
任务进入completed 后,结果视频可通过 /v1/videos/{task_id}/content 拉取(需要带 Bearer 鉴权)。
{
"data": {
"id": "video_xxx",
"task_id": "video_xxx",
"status": "completed",
"progress": 100,
"created_at": 1777080000,
"completed_at": 1777080300
}
}
curl -L "https://api-direct.dimilinks.com/v1/videos/video_xxx/content" \
-H "Authorization: Bearer $DIMILINKS_API_KEY" \
-o video.mp4
失败响应
{
"data": {
"id": "video_xxx",
"task_id": "video_xxx",
"status": "failed",
"progress": 100,
"created_at": 1777080000,
"completed_at": 1777080300,
"error": {
"code": "upstream_error",
"message": "视频生成失败,请稍后重试。"
}
}
}
状态
| 状态 | 含义 | 调用方建议 |
|---|---|---|
queued、pending、submitted | 等待处理 | 继续轮询 |
processing、in_progress、running | 生成中 | 继续轮询 |
completed、success | 已完成 | 拉取 /v1/videos/{task_id}/content |
failed、error、cancelled | 已失败 | 展示错误提示,允许用户重试 |
轮询建议
- 每 3 到 5 秒查询一次,比图片任务略宽松。
- 单条任务最长建议轮询 10 分钟;超时后直接告知用户失败并允许重试。
- 出现
404立即停止轮询,多半是任务 ID 错或不属于当前密钥。
授权
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
路径参数
响应
Image or video task