即梦图像生成
curl --request POST \
--url https://octopusx.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"n": 123,
"size": "<string>",
"image": [
{}
],
"ratio": "<string>",
"resolution": "<string>"
}
'import requests
url = "https://octopusx.ai/v1/images/generations"
payload = {
"model": "<string>",
"prompt": "<string>",
"n": 123,
"size": "<string>",
"image": [{}],
"ratio": "<string>",
"resolution": "<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({
model: '<string>',
prompt: '<string>',
n: 123,
size: '<string>',
image: [{}],
ratio: '<string>',
resolution: '<string>'
})
};
fetch('https://octopusx.ai/v1/images/generations', 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/v1/images/generations",
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([
'model' => '<string>',
'prompt' => '<string>',
'n' => 123,
'size' => '<string>',
'image' => [
[
]
],
'ratio' => '<string>',
'resolution' => '<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/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"n\": 123,\n \"size\": \"<string>\",\n \"image\": [\n {}\n ],\n \"ratio\": \"<string>\",\n \"resolution\": \"<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/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"n\": 123,\n \"size\": \"<string>\",\n \"image\": [\n {}\n ],\n \"ratio\": \"<string>\",\n \"resolution\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://octopusx.ai/v1/images/generations")
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 \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"n\": 123,\n \"size\": \"<string>\",\n \"image\": [\n {}\n ],\n \"ratio\": \"<string>\",\n \"resolution\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"created": 1735689600,
"data": [
{
"url": "https://example.com/generated-image.png",
"revised_prompt": "A close-up depiction of a domestic cat in a relaxed state..."
}
]
}
即梦图像
即梦图像生成
使用 POST /v1/images/generations 调用即梦模型生成图像。
POST
https://octopusx.ai
/
v1
/
images
/
generations
即梦图像生成
curl --request POST \
--url https://octopusx.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"n": 123,
"size": "<string>",
"image": [
{}
],
"ratio": "<string>",
"resolution": "<string>"
}
'import requests
url = "https://octopusx.ai/v1/images/generations"
payload = {
"model": "<string>",
"prompt": "<string>",
"n": 123,
"size": "<string>",
"image": [{}],
"ratio": "<string>",
"resolution": "<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({
model: '<string>',
prompt: '<string>',
n: 123,
size: '<string>',
image: [{}],
ratio: '<string>',
resolution: '<string>'
})
};
fetch('https://octopusx.ai/v1/images/generations', 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/v1/images/generations",
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([
'model' => '<string>',
'prompt' => '<string>',
'n' => 123,
'size' => '<string>',
'image' => [
[
]
],
'ratio' => '<string>',
'resolution' => '<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/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"n\": 123,\n \"size\": \"<string>\",\n \"image\": [\n {}\n ],\n \"ratio\": \"<string>\",\n \"resolution\": \"<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/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"n\": 123,\n \"size\": \"<string>\",\n \"image\": [\n {}\n ],\n \"ratio\": \"<string>\",\n \"resolution\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://octopusx.ai/v1/images/generations")
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 \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"n\": 123,\n \"size\": \"<string>\",\n \"image\": [\n {}\n ],\n \"ratio\": \"<string>\",\n \"resolution\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"created": 1735689600,
"data": [
{
"url": "https://example.com/generated-image.png",
"revised_prompt": "A close-up depiction of a domestic cat in a relaxed state..."
}
]
}
即梦图像生成
OpenAI 兼容格式的图像生成接口,支持即梦模型的图像生成能力。- 路由入口是
POST /v1/images/generations。 - 当前使用
application/json提交。 - 支持即梦模型(
jimeng-4.0、jimeng-4.5)。 - 支持通过
image字段传入参考图进行图生图。
支持模型
jimeng-4.0:即梦 4.0 模型jimeng-4.5:即梦 4.5 模型
方法与路径
POST /v1/images/generations
请求示例
curl -X POST https://octopusx.ai/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"model": "jimeng-4.0",
"prompt": "A close-up depiction of a domestic cat in a relaxed state. The cat features vibrant orange fur, with striking white markings around its eyes that extend down to its soft, pink nose.",
"n": 1,
"size": "1024*1024"
}'
import requests
resp = requests.post(
"https://octopusx.ai/v1/images/generations",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
"Accept": "application/json",
},
json={
"model": "jimeng-4.0",
"prompt": "A close-up depiction of a domestic cat in a relaxed state. The cat features vibrant orange fur, with striking white markings around its eyes that extend down to its soft, pink nose.",
"n": 1,
"size": "1024*1024",
},
timeout=60,
)
print(resp.json())
const response = await fetch("https://octopusx.ai/v1/images/generations", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({
model: "jimeng-4.0",
prompt: "A close-up depiction of a domestic cat in a relaxed state. The cat features vibrant orange fur, with striking white markings around its eyes that extend down to its soft, pink nose.",
n: 1,
size: "1024*1024",
}),
});
console.log(await response.json());
带参考图示例
curl -X POST https://octopusx.ai/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"model": "jimeng-4.0",
"prompt": "参考图片生成写实类型的图像",
"n": 1,
"image": ["https://example.com/reference.png"],
"ratio": "16:9",
"resolution": "2k"
}'
import requests
resp = requests.post(
"https://octopusx.ai/v1/images/generations",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
"Accept": "application/json",
},
json={
"model": "jimeng-4.0",
"prompt": "参考图片生成写实类型的图像",
"n": 1,
"image": ["https://example.com/reference.png"],
"ratio": "16:9",
"resolution": "2k",
},
timeout=60,
)
print(resp.json())
响应示例
{
"created": 1735689600,
"data": [
{
"url": "https://example.com/generated-image.png",
"revised_prompt": "A close-up depiction of a domestic cat in a relaxed state..."
}
]
}
认证
Authorization: Bearer YOUR_API_KEY
Body
模型名称。支持
jimeng-4.0、jimeng-4.5。提示词。生成图像的文本描述,支持中文和英文。
图像数量。生成图片的数量。
图像大小。分辨率设置,例如
1024*1024。垫图。参考图片 URL 数组,用于图生图场景。
图片比例。例如
1:1、16:9、9:16、4:3、3:4 等。分辨率。可选值:
1k、2k、4k。Response
生成时间戳(Unix 时间戳)。
生成结果数组。
生成图片的 URL 地址。
改写后的提示词(部分上游会返回)。
相关接口
⌘I