一、标准 API 接口
适用于后端服务、脚本、CLI 工具等直接调用。鉴权方式:Header 携带 Authorization: Bearer <api_key>,服务端自动分配可用 Session
1. 图像生成 API
POST http://localhost:8000/v1/images/generations
Authorization: Bearer <api_key>
Content-Type: application/json
| 参数 | 类型 | 必填 | 默认值 | 说明 |
model | string | 否 | jimeng-image-5.0-lite | 模型ID |
prompt | string | 是 | - | 正向提示词 |
negative_prompt | string | 否 | "" | 反向提示词(不希望出现的内容) |
ratio | string | 否 | 1:1 | 比例:1:1, 4:3, 3:4, 16:9, 9:16, 3:2, 2:3, 21:9 |
resolution | string | 否 | 2k | 分辨率:1k, 2k, 4k(3.x/2.x仅支持1k) |
sample_strength | number | 否 | 0.5 | 采样强度 0-1,仅参考图模式生效 |
filePath | string | 否 | "" | 参考图URL/路径,填写后自动进入图生图模式 |
response_format | string | 否 | url | 返回格式:url 或 b64_json |
curl -X POST http://localhost:8000/v1/images/generations \
-H "Authorization: Bearer <api_key>" \
-H "Content-Type: application/json" \
-d '{
"model": "jimeng-image-4.7",
"prompt": "一只在太空中飞行的柴犬,赛博朋克风格",
"negative_prompt": "模糊, 低质量",
"ratio": "16:9",
"resolution": "2k"
}'
curl -X POST http://localhost:8000/v1/images/generations \
-H "Authorization: Bearer <api_key>" \
-H "Content-Type: application/json" \
-d '{
"model": "jimeng-image-4.7",
"prompt": "将这张图变成梵高风格",
"filePath": "https://example.com/ref.jpg",
"sample_strength": 0.6
}'
curl -X POST http://localhost:8000/v1/images/generations \
-H "Authorization: Bearer <api_key>" \
-F "model=jimeng-image-4.7" \
-F "prompt=将这张图变成梵高风格" \
-F "file=@./reference.jpg"
import requests
resp = requests.post(
"http://localhost:8000/v1/images/generations",
headers={
"Authorization": "Bearer <api_key>",
"Content-Type": "application/json"
},
json={
"model": "jimeng-image-4.7",
"prompt": "一只在太空中飞行的柴犬",
"ratio": "16:9",
"resolution": "2k"
}
)
print(resp.json()["data"][0]["url"])
const res = await fetch("http://localhost:8000/v1/images/generations", {
method: "POST",
headers: {
"Authorization": "Bearer <api_key>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "jimeng-image-4.7",
prompt: "一只在太空中飞行的柴犬",
ratio: "16:9",
resolution: "2k"
})
});
const { data } = await res.json();
console.log(data[0].url);
响应示例
{
"success": true,
"data": [
{ "url": "https://lf3-jimeng.jianying.com/..." }
]
}
2. 视频生成 API
POST http://localhost:8000/v1/videos/generations
Authorization: Bearer <api_key>
Content-Type: application/json
| 参数 | 类型 | 必填 | 默认值 | 说明 |
model | string | 否 | jimeng-video-seedance-2.0-mini | 视频模型ID |
prompt | string | 是 | - | 视频内容描述 |
ratio | string | 否 | 16:9 | 比例:16:9, 9:16, 1:1, 4:3, 3:4, 21:9 |
resolution | string | 否 | 720p | 分辨率:720p, 1080p, 4k(因模型而异) |
duration | number | 否 | 10 | 时长(秒):5 或 10 |
file_paths | string[] | 否 | [] | 首尾帧图片URL数组,1张=首帧,2张=首帧+尾帧 |
response_format | string | 否 | url | 返回格式:url 或 b64_json |
curl -X POST http://localhost:8000/v1/videos/generations \
-H "Authorization: Bearer <api_key>" \
-H "Content-Type: application/json" \
-d '{
"model": "jimeng-video-seedance-2.0-pro",
"prompt": "城市夜景延时摄影,车流如织",
"ratio": "16:9",
"resolution": "1080p",
"duration": 10
}'
curl -X POST http://localhost:8000/v1/videos/generations \
-H "Authorization: Bearer <api_key>" \
-H "Content-Type: application/json" \
-d '{
"model": "jimeng-video-seedance-2.0-pro",
"prompt": "从日出到日落的延时变化",
"file_paths": [
"https://example.com/sunrise.jpg",
"https://example.com/sunset.jpg"
]
}'
resp = requests.post(
"http://localhost:8000/v1/videos/generations",
headers={
"Authorization": "Bearer <api_key>",
"Content-Type": "application/json"
},
json={
"model": "jimeng-video-seedance-2.0-pro",
"prompt": "城市夜景延时摄影",
"duration": 10,
"resolution": "1080p"
}
)
print(resp.json()["data"]["url"])
const res = await fetch("http://localhost:8000/v1/videos/generations", {
method: "POST",
headers: {
"Authorization": "Bearer <api_key>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "jimeng-video-seedance-2.0-pro",
prompt: "城市夜景延时摄影",
duration: 10
})
});
const { data } = await res.json();
console.log(data.url);
响应示例
{
"success": true,
"data": {
"url": "https://lf3-jimeng.jianying.com/..."
}
}
3. 模型列表 API
GET http://localhost:8000/v1/models
Authorization: Bearer <api_key>
| 查询参数 | 类型 | 默认值 | 说明 |
refresh | string | false | 设为 true 或 1 强制刷新即梦官网模型缓存 |
type | string | 无 | 过滤:image 仅图像,video 仅视频 |
curl http://localhost:8000/v1/models \
-H "Authorization: Bearer <api_key>"
curl "http://localhost:8000/v1/models?type=video" \
-H "Authorization: Bearer <api_key>"
curl "http://localhost:8000/v1/models?refresh=true" \
-H "Authorization: Bearer <api_key>"
resp = requests.get(
"http://localhost:8000/v1/models",
headers={"Authorization": "Bearer <api_key>"},
params={"type": "image"}
)
for m in resp.json()["data"]:
print(m["id"], m["name"])
响应示例
{
"data": [{
"id":
"jimeng-image-4.7",
"object":
"model",
"owned_by":
"jimeng-image",
"name":
"Seedream 4.7",
"model_req_key":
"high_aes_general_v43",
"supported_resolutions": [
"2k",
"4k"],
"default_resolution":
"2k",
"source":
"static",
"benefit_count_by_resolution": {
"2k": 4,
"4k": 1 }
}]
}
benefit_count_by_resolution 表示"每积分可生成的图片数",如 "2k": 4 = 每积分可生成4张2K图
4. Token 有效性检查
POST http://localhost:8000/token/check
Content-Type: application/json
| 参数 | 类型 | 必填 | 说明 |
token | string | 是 | 要检查的即梦 refresh_token |
curl -X POST http://localhost:8000/token/check \
-H "Content-Type: application/json" \
-d '{"token": "your-refresh-token"}'
响应示例
{
"live": true
}
5. Token 积分查询
POST http://localhost:8000/token/points
Authorization: Bearer <api_key>
| 参数 | 类型 | 必填 | 说明 |
Authorization | Header | 是 | Bearer 格式传入 API Key,服务端验证后自动分配可用 Session |
curl -X POST http://localhost:8000/token/points \
-H "Authorization: Bearer <api_key>"
响应示例
[
{ "token": "abc...xyz", "points": 1234 },
{ "token": "def...uvw", "points": 5678 }
]
6. 本地媒体文件访问
GET http://localhost:8000/media/:date/:filename
| 路径参数 | 说明 |
:date | 日期目录,格式 YYYY-MM-DD |
:filename | 文件名,如 1234567890.jpg、abc123.mp4 |
curl http://localhost:8000/media/2026-07-20/1234567890.jpg
curl http://localhost:8000/media/2026-07-20/abc123.mp4
支持格式:png、jpg、jpeg、gif、webp、mp4、webm
7. 健康检查
GET http://localhost:8000/ping
curl http://localhost:8000/ping
8. 异步任务提交(推荐)
解决同步接口长时间阻塞导致调用方超时重试的问题。提交后立即返回 task_id,通过轮询查询任务状态和结果。
POST http://localhost:8000/v1/tasks/submit
Authorization: Bearer <api_key>
Content-Type: application/json
| 参数 | 类型 | 必填 | 说明 |
type | string | 是 | 任务类型:image 或 video |
prompt | string | 是 | 生成提示词 |
model | string | 否 | 模型ID,默认 jimeng-image-5.0-lite 或 jimeng-video-seedance-2.0-mini |
ratio | string | 否 | 比例,如 1:1、16:9、9:16 |
resolution | string | 否 | 分辨率,如 2k、4k、720p、1080p |
negative_prompt | string | 否 | 反向提示词(仅图像) |
sample_strength | number | 否 | 精细度,0-1(仅图像) |
duration | number | 否 | 视频时长,5 或 10(仅视频) |
curl -X POST http://localhost:8000/v1/tasks/submit \
-H "Authorization: Bearer <api_key>" \
-H "Content-Type: application/json" \
-d '{
"type": "image",
"model": "jimeng-image-4.7",
"prompt": "一只可爱的猫咪在窗台上晒太阳"
}'
curl -X POST http://localhost:8000/v1/tasks/submit \
-H "Authorization: Bearer <api_key>" \
-H "Content-Type: application/json" \
-d '{
"type": "video",
"model": "jimeng-video-seedance-2.0-pro",
"prompt": "一只猫在草地上奔跑 16:9",
"duration": 10
}'
resp = requests.post(
"http://localhost:8000/v1/tasks/submit",
headers={
"Authorization": "Bearer <api_key>",
"Content-Type": "application/json"
},
json={
"type": "image",
"model": "jimeng-image-4.7",
"prompt": "一只可爱的猫咪"
}
)
task_id = resp.json()["task_id"]
print(f"任务已提交: {task_id}")
const res = await fetch("http://localhost:8000/v1/tasks/submit", {
method: "POST",
headers: {
"Authorization": "Bearer <api_key>",
"Content-Type": "application/json"
},
body: JSON.stringify({
type: "image",
model: "jimeng-image-4.7",
prompt: "一只可爱的猫咪"
})
});
const { task_id } = await res.json();
console.log(`任务已提交: ${task_id}`);
响应示例
{
"task_id": "550e8400-e29b-41d4-a716-446655440000",
"status": "pending",
"type": "image",
"created_at": "2026-07-20T12:00:00.000Z"
}
9. 任务状态查询
GET http://localhost:8000/v1/tasks/:task_id
Authorization: Bearer <api_key>
curl http://localhost:8000/v1/tasks/550e8400-e29b-41d4-a716-446655440000 \
-H "Authorization: Bearer <api_key>"
状态流转
pending → processing → completed | failed
响应示例 - 处理中
{
"task_id": "550e8400-...",
"type": "image",
"status": "processing",
"prompt": "一只可爱的猫咪",
"model": "jimeng-image-4.7",
"created_at": "2026-07-20T12:00:00",
"updated_at": "2026-07-20T12:00:05"
}
响应示例 - 完成
{
"task_id": "550e8400-...",
"type": "image",
"status": "completed",
"prompt": "一只可爱的猫咪",
"model": "jimeng-image-4.7",
"result": {
"created": 1753036800,
"data": [
{ "url": "https://lf3-jimeng.jianying.com/..." }
]
}
}
响应示例 - 失败
{
"task_id": "550e8400-...",
"type": "image",
"status": "failed",
"error": "积分不足:当前session已标记为不可用"
}
轮询建议:图像任务每 3-5 秒查询一次,视频任务每 10-15 秒查询一次。任务结果保留 24 小时后自动清理。
二、OpenAI 兼容接口
兼容 OpenAI Chat Completions 格式,可直接接入 Dify、Coze、FastGPT 等 AI Agent 平台。Base URL:http://your-server:8000/v1
10. OpenAI Chat Completions
POST http://localhost:8000/v1/chat/completions
Authorization: Bearer <api_key>
Content-Type: application/json
| 参数 | 类型 | 必填 | 说明 |
model | string | 否 | 模型ID,图像 jimeng-image-*,视频 jimeng-video-* |
messages | array | 是 | 消息数组,支持纯文本和多模态格式 |
stream | boolean | 否 | 是否流式输出,默认 false |
curl -X POST http://localhost:8000/v1/chat/completions \
-H "Authorization: Bearer <api_key>" \
-H "Content-Type: application/json" \
-d '{
"model": "jimeng-image-4.7",
"messages": [{"role": "user", "content": "一只可爱的猫咪"}]
}'
curl -X POST http://localhost:8000/v1/chat/completions \
-H "Authorization: Bearer <api_key>" \
-H "Content-Type: application/json" \
-d '{
"model": "jimeng-image-4.7",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "将这张图变成梵高风格"},
{"type": "image_url", "image_url": {"url": "https://example.com/img.jpg"}}
]
}]
}'
curl -X POST http://localhost:8000/v1/chat/completions \
-H "Authorization: Bearer <api_key>" \
-H "Content-Type: application/json" \
-d '{
"model": "jimeng-video-seedance-2.0-pro",
"messages": [{"role": "user", "content": "一只猫在草地上奔跑"}]
}'
resp = requests.post(
"http://localhost:8000/v1/chat/completions",
headers={
"Authorization": "Bearer <api_key>",
"Content-Type": "application/json"
},
json={
"model": "jimeng-image-4.7",
"messages": [{"role": "user", "content": "一只可爱的猫咪"}]
}
)
print(resp.json()["choices"][0]["message"]["content"])
const res = await fetch("http://localhost:8000/v1/chat/completions", {
method: "POST",
headers: {
"Authorization": "Bearer <api_key>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "jimeng-image-4.7",
messages: [{ role: "user", content: "一只可爱的猫咪" }]
})
});
const { choices } = await res.json();
console.log(choices[0].message.content);
响应示例
{
"id":
"uuid",
"model":
"jimeng-image-4.7",
"object":
"chat.completion",
"choices": [{
"index": 0,
"message": {
"role":
"assistant",
"content":
"\n"
},
"finish_reason":
"stop"
}],
"usage": {
"prompt_tokens": 1,
"completion_tokens": 1,
"total_tokens": 2 }
}
- 图像结果以 Markdown  格式嵌在 content 中
- 视频结果以  格式嵌在 content 中
- 该接口会自动在提示词前追加 "一次只生成2张图片," 前缀
11. AI Agent 接入指南
| 配置项 | 值 |
| API Base URL | http://your-server:8000/v1 |
| API Key | 在管理面板创建的 API Key |
| Model | jimeng-image-4.7(图像)或 jimeng-video-seedance-2.0-pro(视频) |
支持平台:Dify、Coze/扣子、FastGPT、LobeChat、Open-WebUI 等
Dify:设置 → 模型供应商 → 添加 OpenAI-API-compatible → 填入 Base URL 和 API Key
Coze:创建 Bot → 添加插件 → 自定义 API 工具 → 配置 Base URL + Header 鉴权
FastGPT/LobeChat:模型管理 → 添加 OpenAI 兼容 → 填入地址和密钥