Replicate SD img2img 功能
▼
Authorization
在 Header 添加参数 Authorization,其值为 Bearer 之后拼接 Token
示例:
Authorization: Bearer ********************
请求参数
Header 参数
Authorization
string
可选
示例: Bearer {{YOUR_API_KEY}}
Content-Type
string
可选
示例: application/json
Body 参数 application/json
version
string
必需
模型版本ID
input
object
必需
模型输入参数
image
string
必需
生成变化的初始图像。
prompt
string
可选
输入提示
scheduler
string
可选
选择一个调度程序。
num_outputs
integer
可选
输出图像数量。默认值:1。最小值:1,最大值:8。
guidance_scale
number
可选
无分类器引导尺度。默认值:7.5。最小值:1,最大值:20。
prompt_strength
number
可选
提供图像时提示强度。默认值:0.8。
num_inference_steps
integer
可选
去噪步骤数。默认值:25。最小值:1,最大值:500。
示例
{
"version": "stability-ai/stable-diffusion-img2img:15a3689ee13b0d2616e98820eca31d4c3abcd36672df6afce5cb6feb1d66087d",
"input": {
"image": "https://replicate.delivery/pbxt/HtKMvJSvuGWDn2B35mM396QGzcrgCNkcgSko8JxtXux4aX9H/sketch-mountains-input.jpeg",
"prompt": "A fantasy landscape, trending on artstation"
}
}
请求示例代码
curl --location --request POST 'https://api.quickrouter.ai/replicate/v1/predictions' --header 'Authorization: Bearer YOUR_API_KEY' --header 'Content-Type: application/json' --data-raw '{
"version": "stability-ai/stable-diffusion-img2img:15a3689ee13b0d2616e98820eca31d4c3abcd36672df6afce5cb6feb1d66087d",
"input": {
"image": "https://replicate.delivery/pbxt/HtKMvJSvuGWDn2B35mM396QGzcrgCNkcgSko8JxtXux4aX9H/sketch-mountains-input.jpeg",
"prompt": "A fantasy landscape, trending on artstation"
}
}'
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer YOUR_API_KEY");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"version": "stability-ai/stable-diffusion-img2img:15a3689ee13b0d2616e98820eca31d4c3abcd36672df6afce5cb6feb1d66087d",
"input": {
"image": "https://replicate.delivery/pbxt/HtKMvJSvuGWDn2B35mM396QGzcrgCNkcgSko8JxtXux4aX9H/sketch-mountains-input.jpeg",
"prompt": "A fantasy landscape, trending on artstation"
}
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.quickrouter.ai/replicate/v1/predictions", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
import http.client
import json
conn = http.client.HTTPSConnection("api.quickrouter.ai")
payload = json.dumps({
"version": "stability-ai/stable-diffusion-img2img:15a3689ee13b0d2616e98820eca31d4c3abcd36672df6afce5cb6feb1d66087d",
"input": {
"image": "https://replicate.delivery/pbxt/HtKMvJSvuGWDn2B35mM396QGzcrgCNkcgSko8JxtXux4aX9H/sketch-mountains-input.jpeg",
"prompt": "A fantasy landscape, trending on artstation"
}
})
headers = {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
conn.request("POST", "/replicate/v1/predictions", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
返回响应
响应参数 application/json
id
string
可选
任务ID
status
string
可选
任务状态
output
string
可选
任务输出
示例
{
"id": "qpt5jq1fssrmc0cmd5hvy31mdg",
"status": "starting"
}