即梦官方格式生图
curl --request POST \
--url https://octopusx.ai/jm \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"req_key": "<string>",
"model": "<string>",
"prompt": "<string>",
"resolution": "<string>",
"size": 123,
"force_single": true,
"image_urls": [
{}
],
"width": 123,
"height": 123
}
'import requests
url = "https://octopusx.ai/jm"
payload = {
"req_key": "<string>",
"model": "<string>",
"prompt": "<string>",
"resolution": "<string>",
"size": 123,
"force_single": True,
"image_urls": [{}],
"width": 123,
"height": 123
}
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>',
model: '<string>',
prompt: '<string>',
resolution: '<string>',
size: 123,
force_single: true,
image_urls: [{}],
width: 123,
height: 123
})
};
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>',
'model' => '<string>',
'prompt' => '<string>',
'resolution' => '<string>',
'size' => 123,
'force_single' => true,
'image_urls' => [
[
]
],
'width' => 123,
'height' => 123
]),
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 \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"resolution\": \"<string>\",\n \"size\": 123,\n \"force_single\": true,\n \"image_urls\": [\n {}\n ],\n \"width\": 123,\n \"height\": 123\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 \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"resolution\": \"<string>\",\n \"size\": 123,\n \"force_single\": true,\n \"image_urls\": [\n {}\n ],\n \"width\": 123,\n \"height\": 123\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 \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"resolution\": \"<string>\",\n \"size\": 123,\n \"force_single\": true,\n \"image_urls\": [\n {}\n ],\n \"width\": 123,\n \"height\": 123\n}"
response = http.request(request)
puts response.read_body{
"code": 10000,
"data": {
"task_id": "67fb9e82-126e-4c71-bb16-a3bb3789e3b7",
"status": "submitted"
},
"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>",
"model": "<string>",
"prompt": "<string>",
"resolution": "<string>",
"size": 123,
"force_single": true,
"image_urls": [
{}
],
"width": 123,
"height": 123
}
'import requests
url = "https://octopusx.ai/jm"
payload = {
"req_key": "<string>",
"model": "<string>",
"prompt": "<string>",
"resolution": "<string>",
"size": 123,
"force_single": True,
"image_urls": [{}],
"width": 123,
"height": 123
}
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>',
model: '<string>',
prompt: '<string>',
resolution: '<string>',
size: 123,
force_single: true,
image_urls: [{}],
width: 123,
height: 123
})
};
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>',
'model' => '<string>',
'prompt' => '<string>',
'resolution' => '<string>',
'size' => 123,
'force_single' => true,
'image_urls' => [
[
]
],
'width' => 123,
'height' => 123
]),
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 \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"resolution\": \"<string>\",\n \"size\": 123,\n \"force_single\": true,\n \"image_urls\": [\n {}\n ],\n \"width\": 123,\n \"height\": 123\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 \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"resolution\": \"<string>\",\n \"size\": 123,\n \"force_single\": true,\n \"image_urls\": [\n {}\n ],\n \"width\": 123,\n \"height\": 123\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 \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"resolution\": \"<string>\",\n \"size\": 123,\n \"force_single\": true,\n \"image_urls\": [\n {}\n ],\n \"width\": 123,\n \"height\": 123\n}"
response = http.request(request)
puts response.read_body{
"code": 10000,
"data": {
"task_id": "67fb9e82-126e-4c71-bb16-a3bb3789e3b7",
"status": "submitted"
},
"message": "Success",
"request_id": "67fb9e82-126e-4c71-bb16-a3bb3789e3b7",
"status": 10000,
"time_elapsed": "35.381µs"
}
即梦官方格式生图
即梦官方格式的图像生成接口,使用 JSON 提交并需要携带查询参数。- 路由入口是
POST /jm。 - 需要在 URL 中携带
Action和Version查询参数。 - 当前使用
application/json提交。 - 支持文生图、图生图等多种场景。
- 提交成功后返回任务
task_id,后续用 查询任务 获取结果。
支持模型
jimeng-4.0:即梦 4.0 模型
方法与路径
POST /jm?Action=CVSync2AsyncSubmitTask&Version=2022-08-31
请求示例
curl -X POST "https://octopusx.ai/jm?Action=CVSync2AsyncSubmitTask&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",
"model": "jimeng-4.0",
"prompt": "落日余晖映照湖面,细腻的油画质感",
"force_single": true,
"image_urls": [],
"width": 1024,
"height": 1024
}'
import requests
resp = requests.post(
"https://octopusx.ai/jm",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
"Accept": "application/json",
},
params={
"Action": "CVSync2AsyncSubmitTask",
"Version": "2022-08-31",
},
json={
"req_key": "jimeng_t2i_v40",
"model": "jimeng-4.0",
"prompt": "落日余晖映照湖面,细腻的油画质感",
"force_single": True,
"image_urls": [],
"width": 1024,
"height": 1024,
},
timeout=60,
)
print(resp.json())
带参考图示例
curl -X POST "https://octopusx.ai/jm?Action=CVSync2AsyncSubmitTask&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",
"model": "jimeng-4.0",
"prompt": "参考图片生成艺术风格",
"force_single": true,
"image_urls": [
"https://example.com/reference1.png",
"https://example.com/reference2.png"
],
"resolution": "2k"
}'
import requests
resp = requests.post(
"https://octopusx.ai/jm",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
"Accept": "application/json",
},
params={
"Action": "CVSync2AsyncSubmitTask",
"Version": "2022-08-31",
},
json={
"req_key": "jimeng_t2i_v40",
"model": "jimeng-4.0",
"prompt": "参考图片生成艺术风格",
"force_single": True,
"image_urls": [
"https://example.com/reference1.png",
"https://example.com/reference2.png",
],
"resolution": "2k",
},
timeout=60,
)
print(resp.json())
响应示例
{
"code": 10000,
"data": {
"task_id": "67fb9e82-126e-4c71-bb16-a3bb3789e3b7",
"status": "submitted"
},
"message": "Success",
"request_id": "67fb9e82-126e-4c71-bb16-a3bb3789e3b7",
"status": 10000,
"time_elapsed": "35.381µs"
}
认证
Authorization: Bearer YOUR_API_KEY
查询参数
操作类型。固定值:
CVSync2AsyncSubmitTask(提交任务)。API 版本。固定值:
2022-08-31。Body
服务标识。取固定值:
jimeng_t2i_v40。模型名。例如
jimeng-4.0。用于生成图像的提示词。中英文输入均可。建议最长不超过 800 字符,prompt 过长有概率出图异常或不生效。支持在 prompt 中直接指定生图比例。
分辨率。可选值:
1k、2k、4k。生成图片的面积(已弃用)。默认值:4194304,即 20482048,生成 2K 分辨率图像。取值范围:[10241024, 4096*4096],可生成 1K 到 4K 分辨率图像。
是否强制生成单图。默认值:
false。图片文件 URL。支持输入 0 至 10 张图,用于图生图场景。
图片宽度。推荐可选值:1024(1K)、2048(2K)、4096(4K)等。
图片高度。推荐可选值:1024(1K)、2048(2K)、4096(4K)等。
Response
状态码。
10000 表示成功。响应数据容器。
任务 ID。用于后续查询任务状态和结果。
任务状态。
状态消息。
请求 ID。
状态码。
请求耗时。
推荐尺寸
1K 分辨率
| 宽高 | 比例 |
|---|---|
| 1024x1024 | 1:1 |
2K 分辨率
| 宽高 | 比例 |
|---|---|
| 2048x2048 | 1:1 |
| 2304x1728 | 4:3 |
| 2496x1664 | 3:2 |
| 2560x1440 | 16:9 |
| 3024x1296 | 21:9 |
4K 分辨率
| 宽高 | 比例 |
|---|---|
| 4096x4096 | 1:1 |
| 4694x3520 | 4:3 |
| 4992x3328 | 3:2 |
| 5404x3040 | 16:9 |
| 6198x2656 | 21:9 |
相关接口
⌘I