即梦AI API 文档
通过API调用即梦AI图片和视频生成服务
Base URL:
认证方式: Bearer Token (使用你的 SessionID)
https://pay.aigc-home.online认证方式: Bearer Token (使用你的 SessionID)
获取 SessionID
- 登录 即梦官网
- 按 F12 打开开发者工具
- 进入 Application → Cookies → jimeng.jianying.com
- 复制
sessionid的值
API 接口
POST /v1/videos/generations
图片生成视频(图生视频)
请求参数
| 参数 | 类型 | 说明 |
|---|---|---|
model |
string | 模型名称 (可选) 可选值: jimeng-video-3.5-pro, jimeng-video-3.0-pro, jimeng-video-3.0, jimeng-video-3.0-fast, jimeng-video-2.0, jimeng-video-2.0-pro 默认: jimeng-video-3.5-pro |
prompt |
string | 视频描述提示词 (必填) |
ratio |
string | 视频比例 (可选) 可选值: 16:9, 9:16, 4:3, 3:4, 1:1 默认: 16:9 |
resolution |
string | 分辨率 (可选) 3.0/3.0 Pro: 480p, 720p, 1080p 3.5 Pro: 固定720p (此参数无效) 默认: 720p |
duration |
number | 视频时长(秒) (可选) 3.0/3.0 Pro: 5 或 10 3.5 Pro: -1(自动) 或 4-12 默认: 5 |
file_paths |
array | 参考图片URL数组 (必填) 提供首帧图片,视频将基于此图片生成 支持外部URL或通过 /v1/images/generations 生成的图片URL 示例: ["https://p3-aigcaas-image-sign.bytedanceapi.com/xxx/image.png"] |
代码示例
# 图生视频 - 使用 3.5 Pro 模型 (自动时长)
curl -X POST https://pay.aigc-home.online/v1/videos/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_SESSION_ID" \
-d '{
"model": "jimeng-video-3.5-pro",
"prompt": "小猫慢慢睁开眼睛,伸了个懒腰,然后跳下沙发",
"ratio": "9:16",
"duration": -1,
"file_paths": ["https://p3-aigcaas-image-sign.bytedanceapi.com/xxx/image.png"]
}'
# 图生视频 - 指定时长 (4-12秒)
curl -X POST https://pay.aigc-home.online/v1/videos/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_SESSION_ID" \
-d '{
"model": "jimeng-video-3.5-pro",
"prompt": "镜头缓慢推进,风景画中的云彩开始流动",
"ratio": "16:9",
"duration": 10,
"file_paths": ["https://your-image-url.com/landscape.jpg"]
}'
import requests
# 图生视频示例
url = "https://pay.aigc-home.online/v1/videos/generations"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_SESSION_ID"
}
# 首先生成一张图片,或使用已有的图片URL
image_url = "https://p3-aigcaas-image-sign.bytedanceapi.com/xxx/image.png"
data = {
"model": "jimeng-video-3.5-pro",
"prompt": "小猫慢慢睁开眼睛,伸了个懒腰",
"ratio": "9:16",
"duration": -1, # -1 自动时长,或 4-12 指定
"file_paths": [image_url]
}
response = requests.post(url, json=data, headers=headers)
result = response.json()
if result.get("data"):
video_url = result["data"][0]["url"]
print(f"视频URL: {video_url}")
const axios = require('axios');
// 图生视频示例
async function generateVideo() {
// 首先生成一张图片,或使用已有的图片URL
const imageUrl = 'https://p3-aigcaas-image-sign.bytedanceapi.com/xxx/image.png';
const response = await axios.post(
'https://pay.aigc-home.online/v1/videos/generations',
{
model: 'jimeng-video-3.5-pro',
prompt: '小猫慢慢睁开眼睛,伸了个懒腰',
ratio: '9:16',
duration: -1, // -1 自动时长,或 4-12 指定
file_paths: [imageUrl]
},
{
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_SESSION_ID'
}
}
);
const videoUrl = response.data.data[0].url;
console.log('视频URL:', videoUrl);
}
generateVideo();
// 图生视频示例 - 使用 Java 11+ HttpClient
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class VideoGenerator {
public static void main(String[] args) throws Exception {
String url = "https://pay.aigc-home.online/v1/videos/generations";
String sessionId = "YOUR_SESSION_ID";
String imageUrl = "https://p3-aigcaas-image-sign.bytedanceapi.com/xxx/image.png";
// 图生视频,duration=-1 表示自动时长
String jsonBody = """
{
"model": "jimeng-video-3.5-pro",
"prompt": "小猫慢慢睁开眼睛,伸了个懒腰",
"ratio": "9:16",
"duration": -1,
"file_paths": ["%s"]
}
""".formatted(imageUrl);
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Content-Type", "application/json")
.header("Authorization", "Bearer " + sessionId)
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println("响应: " + response.body());
}
}
<?php
// 图生视频示例
$url = "https://pay.aigc-home.online/v1/videos/generations";
$imageUrl = "https://p3-aigcaas-image-sign.bytedanceapi.com/xxx/image.png";
$data = [
"model" => "jimeng-video-3.5-pro",
"prompt" => "小猫慢慢睁开眼睛,伸了个懒腰",
"ratio" => "9:16",
"duration" => -1, // -1 自动时长,或 4-12 指定
"file_paths" => [$imageUrl]
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer YOUR_SESSION_ID"
]);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
if ($result["data"]) {
$videoUrl = $result["data"][0]["url"];
echo "视频URL: " . $videoUrl;
}
?>
响应示例
成功响应 (200)
{
"created": 1766901879,
"data": [
{
"url": "https://v6-artist.vlabvod.com/xxx/video.mp4",
"revised_prompt": "一只可爱的小猫在草地上奔跑"
}
]
}
POST /v1/images/generations
文本生成图片
请求参数
| 参数 | 类型 | 说明 |
|---|---|---|
model |
string | 模型名称 (可选) 可选值: jimeng-4.5, jimeng-4.1, jimeng-4.0, jimeng-3.1, jimeng-3.0, jimeng-2.1, jimeng-2.0-pro, jimeng-2.0, jimeng-1.4, jimeng-xl-pro 默认: jimeng-4.5 |
prompt |
string | 图片描述提示词 (必填) |
negative_prompt |
string | 负面提示词 (可选) 描述不希望出现在图片中的元素 |
ratio |
string | 图片比例 (可选) 可选值: 1:1, 4:3, 3:4, 16:9, 9:16, 3:2, 2:3, 21:9 默认: 1:1 |
resolution |
string | 分辨率 (可选) 可选值: 1k (1024px), 2k (2048px), 4k (4096px) 默认: 2k |
sample_strength |
number | 采样强度 (可选) 范围: 0-1 默认: 0.5 |
response_format |
string | 响应格式 (可选) 可选值: url, b64_json 默认: url |
代码示例
# 基础用法 - 使用 4.5 模型生成 2K 竖屏图片
curl -X POST https://pay.aigc-home.online/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_SESSION_ID" \
-d '{
"model": "jimeng-4.5",
"prompt": "一只穿着宇航服的猫咪,站在月球上,背景是地球",
"ratio": "9:16",
"resolution": "2k"
}'
# 使用负面提示词
curl -X POST https://pay.aigc-home.online/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_SESSION_ID" \
-d '{
"model": "jimeng-4.5",
"prompt": "美丽的山水风景画,中国水墨风格",
"negative_prompt": "模糊, 低质量, 变形, 文字",
"ratio": "16:9",
"resolution": "2k"
}'
import requests
url = "https://pay.aigc-home.online/v1/images/generations"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_SESSION_ID"
}
data = {
"model": "jimeng-4.5",
"prompt": "一只穿着宇航服的猫咪,站在月球上",
"negative_prompt": "模糊, 低质量",
"ratio": "9:16",
"resolution": "2k"
}
response = requests.post(url, json=data, headers=headers)
result = response.json()
if result.get("data"):
image_url = result["data"][0]["url"]
print(f"图片URL: {image_url}")
# 下载图片
img_response = requests.get(image_url)
with open("generated_image.png", "wb") as f:
f.write(img_response.content)
print("图片已保存为 generated_image.png")
const axios = require('axios');
const fs = require('fs');
async function generateImage() {
const response = await axios.post(
'https://pay.aigc-home.online/v1/images/generations',
{
model: 'jimeng-4.5',
prompt: '一只穿着宇航服的猫咪,站在月球上',
negative_prompt: '模糊, 低质量',
ratio: '9:16',
resolution: '2k'
},
{
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_SESSION_ID'
}
}
);
const imageUrl = response.data.data[0].url;
console.log('图片URL:', imageUrl);
// 下载图片
const imgResponse = await axios.get(imageUrl, { responseType: 'arraybuffer' });
fs.writeFileSync('generated_image.png', imgResponse.data);
console.log('图片已保存');
}
generateImage();
<?php
$url = "https://pay.aigc-home.online/v1/images/generations";
$data = [
"model" => "jimeng-4.5",
"prompt" => "一只穿着宇航服的猫咪,站在月球上",
"negative_prompt" => "模糊, 低质量",
"ratio" => "9:16",
"resolution" => "2k"
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer YOUR_SESSION_ID"
]);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
if ($result["data"]) {
$imageUrl = $result["data"][0]["url"];
echo "图片URL: " . $imageUrl;
// 下载图片
$imageData = file_get_contents($imageUrl);
file_put_contents("generated_image.png", $imageData);
}
?>
响应示例
成功响应 (200)
{
"created": 1766901879,
"data": [
{
"url": "https://p3-aigcaas-image-sign.bytedanceapi.com/xxx/image.png"
}
]
}
分辨率对照表
| 分辨率 | 1:1 | 9:16 | 16:9 | 4:3 | 3:4 |
|---|---|---|---|---|---|
1k |
1024×1024 | 576×1024 | 1024×576 | 768×1024 | 1024×768 |
2k |
2048×2048 | 1440×2560 | 2560×1440 | 2304×1728 | 1728×2304 |
4k |
4096×4096 | 2880×5120 | 5120×2880 | 4608×3456 | 3456×4608 |
POST /v1/images/compositions
多参考图合成(图生图/多图融合)- 使用1-10张参考图生成新图片
功能说明: 上传参考图片,AI会根据参考图的风格、内容和你的提示词生成新的图片。支持单图风格迁移、多图融合等场景。推荐使用 jimeng-4.x 系列模型效果最佳。
请求参数
支持两种请求格式:JSON 格式(图片URL)或 multipart/form-data 格式(直接上传图片文件)
方式一:JSON 格式(使用图片URL)
| 参数 | 类型 | 说明 |
|---|---|---|
model |
string | 模型名称 (可选) 推荐: jimeng-4.5, jimeng-4.1, jimeng-4.0 默认: jimeng-4.5 |
prompt |
string | 图片描述提示词 (必填) |
images |
array | 参考图片URL数组 (必填) 支持1-10张参考图 格式: ["https://xxx/1.jpg", "https://xxx/2.jpg"] 或 [{"url": "https://xxx/1.jpg"}, {"url": "https://xxx/2.jpg"}] |
negative_prompt |
string | 负面提示词 (可选) |
ratio |
string | 图片比例 (可选) 可选值: 1:1, 4:3, 3:4, 16:9, 9:16, 3:2, 2:3 默认: 1:1 |
resolution |
string | 分辨率 (可选) 可选值: 1k, 2k, 4k 默认: 2k |
sample_strength |
number | 参考图强度 (可选) 范围: 0.1-1.0(越大越接近原图) 默认: 0.5 |
方式二:multipart/form-data 格式(直接上传文件)
| 参数 | 类型 | 说明 |
|---|---|---|
images |
file[] | 参考图片文件 (必填) 支持1-10张图片,格式: jpg/png/webp |
| 其他参数同上(model, prompt, ratio 等) | ||
代码示例
# 方式一:JSON格式 - 使用图片URL
curl -X POST https://pay.aigc-home.online/v1/images/compositions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_SESSION_ID" \
-d '{
"model": "jimeng-4.5",
"prompt": "将这些元素融合成一幅梦幻的风景画",
"images": [
"https://example.com/image1.jpg",
"https://example.com/image2.jpg"
],
"ratio": "16:9",
"resolution": "2k",
"sample_strength": 0.6
}'
# 方式二:multipart/form-data - 直接上传文件
curl -X POST https://pay.aigc-home.online/v1/images/compositions \
-H "Authorization: Bearer YOUR_SESSION_ID" \
-F "model=jimeng-4.5" \
-F "prompt=融合这些图片的风格,创作一幅新画作" \
-F "ratio=1:1" \
-F "resolution=2k" \
-F "sample_strength=0.5" \
-F "images=@/path/to/image1.jpg" \
-F "images=@/path/to/image2.jpg" \
-F "images=@/path/to/image3.jpg"
import requests
# 方式一:使用图片URL
url = "https://pay.aigc-home.online/v1/images/compositions"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_SESSION_ID"
}
data = {
"model": "jimeng-4.5",
"prompt": "将这些元素融合成梦幻风景",
"images": [
"https://example.com/image1.jpg",
"https://example.com/image2.jpg"
],
"ratio": "16:9",
"resolution": "2k",
"sample_strength": 0.6
}
response = requests.post(url, json=data, headers=headers)
result = response.json()
print("生成的图片:", [img["url"] for img in result["data"]])
# 方式二:直接上传图片文件
url = "https://pay.aigc-home.online/v1/images/compositions"
headers = {
"Authorization": "Bearer YOUR_SESSION_ID"
}
files = [
('images', ('image1.jpg', open('image1.jpg', 'rb'), 'image/jpeg')),
('images', ('image2.jpg', open('image2.jpg', 'rb'), 'image/jpeg')),
]
data = {
"model": "jimeng-4.5",
"prompt": "融合这些图片创作新画作",
"ratio": "1:1",
"resolution": "2k",
"sample_strength": "0.5"
}
response = requests.post(url, files=files, data=data, headers=headers)
result = response.json()
print("生成的图片:", result)
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
// 方式一:使用图片URL
async function composeWithUrls() {
const response = await axios.post(
'https://pay.aigc-home.online/v1/images/compositions',
{
model: 'jimeng-4.5',
prompt: '将这些元素融合成梦幻风景',
images: [
'https://example.com/image1.jpg',
'https://example.com/image2.jpg'
],
ratio: '16:9',
resolution: '2k',
sample_strength: 0.6
},
{
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_SESSION_ID'
}
}
);
console.log('生成的图片:', response.data);
}
// 方式二:直接上传图片文件
async function composeWithFiles() {
const form = new FormData();
form.append('model', 'jimeng-4.5');
form.append('prompt', '融合这些图片创作新画作');
form.append('ratio', '1:1');
form.append('resolution', '2k');
form.append('sample_strength', '0.5');
form.append('images', fs.createReadStream('image1.jpg'));
form.append('images', fs.createReadStream('image2.jpg'));
const response = await axios.post(
'https://pay.aigc-home.online/v1/images/compositions',
form,
{
headers: {
...form.getHeaders(),
'Authorization': 'Bearer YOUR_SESSION_ID'
}
}
);
console.log('生成的图片:', response.data);
}
<?php
// 方式一:使用图片URL
$url = "https://pay.aigc-home.online/v1/images/compositions";
$data = [
"model" => "jimeng-4.5",
"prompt" => "将这些元素融合成梦幻风景",
"images" => [
"https://example.com/image1.jpg",
"https://example.com/image2.jpg"
],
"ratio" => "16:9",
"resolution" => "2k",
"sample_strength" => 0.6
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer YOUR_SESSION_ID"
]);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
print_r($result);
// 方式二:上传文件
$ch = curl_init($url);
$postData = [
'model' => 'jimeng-4.5',
'prompt' => '融合图片创作新画作',
'ratio' => '1:1',
'resolution' => '2k',
'sample_strength' => '0.5',
'images[0]' => new CURLFile('/path/to/image1.jpg'),
'images[1]' => new CURLFile('/path/to/image2.jpg'),
];
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer YOUR_SESSION_ID"
]);
$response = curl_exec($ch);
curl_close($ch);
print_r(json_decode($response, true));
?>
响应示例
成功响应 (200)
{
"created": 1769441186,
"data": [
{ "url": "https://p26-dreamina-sign.byteimg.com/xxx/image1.png" },
{ "url": "https://p26-dreamina-sign.byteimg.com/xxx/image2.png" },
{ "url": "https://p3-dreamina-sign.byteimg.com/xxx/image3.png" },
{ "url": "https://p3-dreamina-sign.byteimg.com/xxx/image4.png" }
],
"input_images": 2,
"composition_type": "multi_image_synthesis"
}
使用技巧:
- sample_strength 参数: 0.3-0.5 偏向创意,0.6-0.8 偏向保持原图风格
- 单图风格迁移: 上传1张参考图 + 详细的目标描述
- 多图融合: 上传2-5张风格相近的图片,AI会融合它们的特征
- 角色一致性: 上传同一角色的多角度照片,保持角色特征
GET /ping
服务健康检查
curl https://pay.aigc-home.online/ping
# 返回: pong
错误处理
| 错误码 | 说明 |
|---|---|
401 |
SessionID 无效或已过期,请重新获取 |
400 |
请求参数错误 |
429 |
请求过于频繁或积分不足 |
500 |
服务器内部错误 |
注意事项:
- SessionID 会过期,请定期更新
- 官方每日赠送 66 积分,用完需等待次日刷新
- 视频URL有效期约 24 小时
- 仅供个人使用,请勿商用或公开分享
在线测试
填入你的 SessionID 和图片URL进行图生视频测试: