即梦官方格式查询任务
curl --request POST \
--url https://octopusx.ai/jm \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"req_key": "<string>",
"task_id": "<string>",
"req_json": "<string>"
}
'import requests
url = "https://octopusx.ai/jm"
payload = {
"req_key": "<string>",
"task_id": "<string>",
"req_json": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({req_key: '<string>', task_id: '<string>', req_json: '<string>'})
};
fetch('https://octopusx.ai/jm', 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://octopusx.ai/jm",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'req_key' => '<string>',
'task_id' => '<string>',
'req_json' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://octopusx.ai/jm"
payload := strings.NewReader("{\n \"req_key\": \"<string>\",\n \"task_id\": \"<string>\",\n \"req_json\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://octopusx.ai/jm")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"req_key\": \"<string>\",\n \"task_id\": \"<string>\",\n \"req_json\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://octopusx.ai/jm")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"req_key\": \"<string>\",\n \"task_id\": \"<string>\",\n \"req_json\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"code": 10000,
"data": {
"binary_data_base64": [],
"image_urls": null,
"status": "generating"
},
"message": "Success",
"request_id": "67fb9e82-126e-4c71-bb16-a3bb3789e3b7",
"status": 10000,
"time_elapsed": "35.381µs"
}
即梦图像
即梦官方格式查询任务
使用 POST /jm 查询即梦官方格式任务状态与结果。
POST
https://octopusx.ai
/
jm
即梦官方格式查询任务
curl --request POST \
--url https://octopusx.ai/jm \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"req_key": "<string>",
"task_id": "<string>",
"req_json": "<string>"
}
'import requests
url = "https://octopusx.ai/jm"
payload = {
"req_key": "<string>",
"task_id": "<string>",
"req_json": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({req_key: '<string>', task_id: '<string>', req_json: '<string>'})
};
fetch('https://octopusx.ai/jm', 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://octopusx.ai/jm",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'req_key' => '<string>',
'task_id' => '<string>',
'req_json' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://octopusx.ai/jm"
payload := strings.NewReader("{\n \"req_key\": \"<string>\",\n \"task_id\": \"<string>\",\n \"req_json\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://octopusx.ai/jm")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"req_key\": \"<string>\",\n \"task_id\": \"<string>\",\n \"req_json\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://octopusx.ai/jm")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"req_key\": \"<string>\",\n \"task_id\": \"<string>\",\n \"req_json\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"code": 10000,
"data": {
"binary_data_base64": [],
"image_urls": null,
"status": "generating"
},
"message": "Success",
"request_id": "67fb9e82-126e-4c71-bb16-a3bb3789e3b7",
"status": 10000,
"time_elapsed": "35.381µs"
}
即梦官方格式查询任务
即梦官方格式的任务查询接口,用于查询图像生成任务的状态与结果。- 路由入口是
POST /jm。 - 需要在 URL 中携带
Action和Version查询参数。 - 通过 Body 中的
task_id指定要查询的任务。 - 返回任务状态(
generating、success、failed)及图像下载地址。
方法与路径
POST /jm?Action=CVSync2AsyncGetResult&Version=2022-08-31
请求示例
curl -X POST "https://octopusx.ai/jm?Action=CVSync2AsyncGetResult&Version=2022-08-31" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"req_key": "jimeng_t2i_v40",
"task_id": "67fb9e82-126e-4c71-bb16-a3bb3789e3b7",
"req_json": "{\"return_url\": true}"
}'
import requests
import json
resp = requests.post(
"https://octopusx.ai/jm",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
"Accept": "application/json",
},
params={
"Action": "CVSync2AsyncGetResult",
"Version": "2022-08-31",
},
json={
"req_key": "jimeng_t2i_v40",
"task_id": "67fb9e82-126e-4c71-bb16-a3bb3789e3b7",
"req_json": json.dumps({"return_url": True}),
},
timeout=60,
)
print(resp.json())
响应示例
生成中
{
"code": 10000,
"data": {
"binary_data_base64": [],
"image_urls": null,
"status": "generating"
},
"message": "Success",
"request_id": "67fb9e82-126e-4c71-bb16-a3bb3789e3b7",
"status": 10000,
"time_elapsed": "35.381µs"
}
生成成功
{
"code": 10000,
"data": {
"binary_data_base64": [],
"image_urls": [
"https://example.com/generated-image-1.png",
"https://example.com/generated-image-2.png"
],
"status": "success"
},
"message": "Success",
"request_id": "67fb9e82-126e-4c71-bb16-a3bb3789e3b7",
"status": 10000,
"time_elapsed": "2.5s"
}
生成失败
{
"code": 10001,
"data": {
"binary_data_base64": [],
"image_urls": null,
"status": "failed"
},
"message": "Task failed",
"request_id": "67fb9e82-126e-4c71-bb16-a3bb3789e3b7",
"status": 10001,
"time_elapsed": "1.2s"
}
认证
Authorization: Bearer YOUR_API_KEY
查询参数
操作类型。固定值:
CVSync2AsyncGetResult(查询结果)。API 版本。固定值:
2022-08-31。Body
服务标识。取固定值:
jimeng_t2i_v40。任务 ID。创建任务时返回的
task_id。JSON 序列化后的字符串。目前支持水印配置和是否以图片链接形式返回,可在返回结果中添加。例如:
{"return_url": true}。Response
状态码。
10000 表示成功。响应数据容器。
图片的 Base64 编码数组。
图片 URL 数组。当
req_json 中设置 return_url: true 时返回。任务状态。可选值:
generating(生成中)、success(成功)、failed(失败)。状态消息。
请求 ID。
状态码。
请求耗时。
相关接口
⌘I