Skip to content

编辑图片(Edit)接口

POST  v1/mj/submit/edits

执行edit接口,可以编辑外部传入的图片,可以进行局部重绘,也可以直接改图

请求参数

Authorization

在 Header 添加参数 Authorization,其值为在 Bearer 之后拼接 Token。

Authorization: Bearer ******************

Body 参数

Content-Type: application/json

参数名类型必填说明
modestring必需运行模式或生成模式。
promptstring必需提示词,用于指导生成的内容。
imageBase64string必需要编辑的图片
base64Arrayarray[string]可选垫图 Base64 数组。通常用于图生图(Image-to-Image)任务,提供一张或多张图片的 Base64 编码。
accountFilterobject可选账号筛选条件。用于指定由哪个或哪类账号来执行此任务。
└─ channelIdstring可选渠道 ID。
└─ instanceIdstring可选账号实例 ID。
└─ modesarray[string]可选账号模式列表。
└─ remarkstring可选备注信息。
└─ remixboolean可选账号是否开启 Remix 模式。
└─ remixAutoConsideredboolean可选逻辑说明:在账号过滤时,如果设置了此选项,"Remix 自动提交" 将被视为账号的 remix 属性为 false
notifyHookstring可选回调地址。如果为空,则使用系统配置的全局 notifyHook
statestring可选自定义参数,通常用于在回调时透传数据,保持请求与回调的上下文关联。

请求示例 (JSON)

{
    "prompt": "将图片转为吉卜力风格",
    "imageBase64": "data:image/png;xxx"
}

返回响应

200 成功

Content-Type: application/json

响应参数

参数类型必填说明
codeinteger必需状态码。用于标识请求的处理结果
descriptionstring必需描述信息。对状态码的文字说明或具体的错误提示
resultinteger必需结果标识。可能用于表示操作影响的行数、特定的结果状态或分页总数等数值型结果。

响应示例

{
    "code": 0,
    "description": "string",
    "result": "string"
}

示例代码

python
import http.client
import json

conn = http.client.HTTPSConnection("nxaiapp.com")
payload = json.dumps({
   "prompt": "将图片转为吉卜力风格",
   "imageBase64": "data:image/png;xxx"
})
headers = {
   'Authorization': 'Bearer <token>',
   'Content-Type': 'application/json'
}
conn.request("POST", "/v1/mj/submit/edits", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))