图像生成
图像生成
本文介绍如何使用 文生图、图生图 API 生成图像。
文生图
1.文生图通用请求
请在您的HTTP请求中将 content-type
设置为 application/json
,目前仅支持JSON格式。在 playground 试用。
请求:
curl --location 'https://api.scsd.cn/v3/async/txt2img' \
--header 'Authorization: Bearer {{API Key}}' \
--header 'Content-Type: application/json' \
--data '{
"extra": {
"response_image_type": "jpeg"
},
"request": {
"prompt": "a cute dog",
"model_name": "realisticVisionV51_v51VAE_94301.safetensors",
"negative_prompt": "nsfw, bottle,bad face",
"width": 512,
"height": 384,
"image_num": 2,
"steps": 20,
"seed": -1,
"clip_skip": 1,
"sampler_name": "Euler a",
"guidance_scale": 7.5
}
}'
返回:
{
"task_id": "9da3ee7c-edfe-46b5-a13d-17c6d6d07211"
}
使用 task_id
获取图像
2xx 范围内的 HTTP 状态代码表示请求已成功接受,5xx 范围内的状态代码表示内部服务器错误。
您可以在响应的 images
中获取图像下载地址。
请求:
curl --location --request GET 'https://api.scsd.cn/v3/async/task-result?task_id=9da3ee7c-edfe-46b5-a13d-17c6d6d07211' \
--header 'Authorization: Bearer {{API Key}}'
返回:
{
"extra": {
"seed": "2120990378",
"enable_nsfw_detection": true,
"debug_info": {
"request_info": "{\"model\":\"protovisionXLHighFidelity3D_release0620Bakedvae_131308.safetensors\",\"refiner\":{\"switch_at\":1},\"prompts\":[\"a room with a bed and a desk in it,Weathered furniture,Dilapidated wallpaper,Worn-out floorboards,Tattered curtains,Faded upholstery,Cracked window panes,Broken light fixtures,Peeling paint,Rusty metal accents,Dusty surfaces,Cobweb-covered corners,Stained bedding,Scratched desk surface,Chipped wooden frame,Frayed edges on rugs,Aged and distressed textures,Scuffed chair legs,Worn-out bookshelves,Flickering, dim lighting,Crumbling plaster on walls\"],\"negative_prompts\":[\"\"],\"seeds\":[2120990378],\"height\":512,\"width\":512,\"guidance_scale\":7.5,\"num_images_per_prompt\":2,\"num_inference_steps\":20,\"sampler_name\":\"DPM++ 2S a Karras\",\"clip_skip\":1}",
"submit_time_ms": "1713258342481",
"execute_time_ms": "1713258342550",
"complete_time_ms": "1713258366442"
}
},
"task": {
"task_id": "9da3ee7c-edfe-46b5-a13d-17c6d6d07211",
"task_type": "TXT_TO_IMG",
"status": "TASK_STATUS_SUCCEED",
"reason": "",
"eta": 0,
"progress_percent": 0
},
"images": [
{
"image_url": "https://faas-output-image-1312767721.cos.ap-shanghai.myqcloud.com/test/9da3ee7c-edfe-46b5-a13d-17c6d6d07211/4c0159ddc144448b9624daa204899f9b.png?q-sign-algorithm=sha1&q-ak=AKIDHOHvKVnrgHkyxhCTyOdeSjoiRxGPSJ0V&q-sign-time=1713258366%3B1713261966&q-key-time=1713258366%3B1713261966&q-header-list=host&q-url-param-list=&q-signature=3773e2f80106bfe28698b1056c5f233b91c1550d",
"image_url_ttl": "3600",
"image_type": "png",
"nsfw_detection_result": null
},
{
"image_url": "https://faas-output-image-1312767721.cos.ap-shanghai.myqcloud.com/test/9da3ee7c-edfe-46b5-a13d-17c6d6d07211/9a8179f484314f32906bf4bae2f048c9.png?q-sign-algorithm=sha1&q-ak=AKIDHOHvKVnrgHkyxhCTyOdeSjoiRxGPSJ0V&q-sign-time=1713258366%3B1713261966&q-key-time=1713258366%3B1713261966&q-header-list=host&q-url-param-list=&q-signature=f51a86c51a8f805b18956b2da2b6869c25576c87",
"image_url_ttl": "3600",
"image_type": "png",
"nsfw_detection_result": null
}
],
"videos": []
}
2.文生图 LORA 请求
请在您的HTTP请求中将 content-type
设置为 application/json
,目前仅支持JSON格式。在 playground 试用。
请求:
curl --location 'https://api.scsd.cn/v3/async/txt2img' \
--header 'Authorization: Bearer {{API Key}}' \
--header 'Content-Type: application/json' \
--data '{
"extra": {
"response_image_type": "jpeg"
},
"request": {
"prompt": "a cute dog",
"model_name": "realisticVisionV51_v51VAE_94301.safetensors",
"negative_prompt": "nsfw, bottle,bad face",
"width": 512,
"height": 512,
"image_num": 2,
"steps": 20,
"seed": 123,
"clip_skip": 1,
"sampler_name": "Euler a",
"guidance_scale": 7.5,
"loras": [
{
"model_name": "MS_Real_AssSpread",
"strength": 0.7
},
{
"model_name": "MS_Real_Cameltoe_Lite",
"strength": 0.9
}
]
}
}'
返回:
{
"task_id": "6469ca5b-5929-4200-b263-241020763eb8"
}
使用 task_id
获取图像
2xx 范围内的 HTTP 状态代码表示请求已成功接受,5xx 范围内的状态代码表示内部服务器错误。
您可以在响应的 images
中获取图像下载地址。
请求:
curl --location --request GET 'https://api.scsd.cn/v3/async/task-result?task_id=6469ca5b-5929-4200-b263-241020763eb8' \
--header 'Authorization: Bearer {{API Key}}'
返回:
{
"extra": {
"seed": "253234069"
},
"task": {
"task_id": "a578f6e0-3467-46c2-ab4f-a30b9b40f54c",
"task_type": "TXT_TO_IMG",
"status": "TASK_STATUS_SUCCEED",
"reason": "",
"eta": 0,
"progress_percent": 0
},
"images": [
{
"image_url": "https://faas-output-image-1312767721.cos.ap-shanghai.myqcloud.com/test/9da3ee7c-edfe-46b5-a13d-17c6d6d07211/4c0159ddc144448b9624daa204899f9b.png?q-sign-algorithm=sha1&q-ak=AKIDHOHvKVnrgHkyxhCTyOdeSjoiRxGPSJ0V&q-sign-time=1713258366%3B1713261966&q-key-time=1713258366%3B1713261966&q-header-list=host&q-url-param-list=&q-signature=3773e2f80106bfe28698b1056c5f233b91c1550d",
"image_url_ttl": "3600",
"image_type": "jpeg"
},
{
"image_url": "https://faas-output-image-1312767721.cos.ap-shanghai.myqcloud.com/test/9da3ee7c-edfe-46b5-a13d-17c6d6d07211/9a8179f484314f32906bf4bae2f048c9.png?q-sign-algorithm=sha1&q-ak=AKIDHOHvKVnrgHkyxhCTyOdeSjoiRxGPSJ0V&q-sign-time=1713258366%3B1713261966&q-key-time=1713258366%3B1713261966&q-header-list=host&q-url-param-list=&q-signature=f51a86c51a8f805b18956b2da2b6869c25576c87",
"image_url_ttl": "3600",
"image_type": "jpeg"
}
],
"videos": []
}
3.文生图 SDXL 1.0 请求
请在您的HTTP请求中将 content-type
设置为 application/json
,目前仅支持JSON格式。
请求:
curl --location 'https://api.scsd.cn/v3/async/txt2img' \
--header 'Authorization: Bearer {{API Key}}' \
--header 'Content-Type: application/json' \
--data '{
"extra": {
"response_image_type": "jpeg",
"enterprise_plan": {
"enabled": false
}
},
"request": {
"prompt": "a cute dog",
"model_name": "sd_xl_base_1.0.safetensors",
"negative_prompt": "nsfw, bottle,bad face",
"width": 1024,
"height": 1024,
"image_num": 1,
"steps": 20,
"seed": -1,
"clip_skip": 1,
"sampler_name": "Euler a",
"guidance_scale": 7.5
}
}'
返回:
{
"task_id": "6469ca5b-5929-4200-b263-241020763eb8"
}
使用 task_id
获取图像
2xx 范围内的 HTTP 状态代码表示请求已成功接受,5xx 范围内的状态代码表示内部服务器错误。
您可以在响应的 images
中获取图像下载地址。
请求:
curl --location --request GET 'https://api.scsd.cn/v3/async/task-result?task_id=6469ca5b-5929-4200-b263-241020763eb8' \
--header 'Authorization: Bearer {{API Key}}'
返回:
{
"extra": {
"seed": "3706472920",
"enable_nsfw_detection": false
},
"task": {
"task_id": "346b3562-ae4e-4849-a9fb-9318cb1a689d",
"task_type": "TXT_TO_IMG",
"status": "TASK_STATUS_SUCCEED",
"reason": "",
"eta": 0,
"progress_percent": 0
},
"images": [
{
"image_url": "https://faas-output-image.s3.ap-southeast-1.amazonaws.com/prod/346b3562-ae4e-4849-a9fb-9318cb1a689d/5698013f545d425cbcdeae00cef8c435.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIASVPYCN6LRCW3SOUV%2F20240307%2Fap-southeast-1%2Fs3%2Faws4_request&X-Amz-Date=20240307T033747Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&x-id=GetObject&X-Amz-Signature=68f00e2800de145d5c2c9d05f957a684283fa8dce41049337b8ce59267c49cf2",
"image_url_ttl": "3600",
"image_type": "jpeg",
"nsfw_detection_result": null
}
],
"videos": []
}
图生图
1. 图生图通用请求
请在您的HTTP请求中将 content-type
设置为 application/json
,目前仅支持JSON格式。在 playground 试用。
请求:
curl --location 'https://api.scsd.cn/v3/async/img2img' \
--header 'Authorization: Bearer {{API Key}}' \
--header 'Content-Type: application/json' \
--data '{
"extra": {
"response_image_type": "jpeg"
},
"request": {
"model_name": "chilloutmix_NiPrunedFp32Fix.safetensors",
"prompt": "a cute dog",
"negative_prompt": "",
"height": 512,
"width": 384,
"image_num": 1,
"steps": 20,
"seed": 123,
"clip_skip": 1,
"guidance_scale": 7.5,
"sampler_name": "Euler a",
"embeddings": [
{
"model_name": "pureerosface_v1_5162.pt"
}
],
"loras": [
{
"model_name": "MS_Real_AssSpread",
"strength": 0.7
},
{
"model_name": "MS_Real_Cameltoe_Lite",
"strength": 0.9
}
],
"image_base64": "{{Base64 encode image}}"
}
}'
返回:
{
"code": 0,
"msg": "",
"data": {
"task_id": "698287f4-fc4c-43ff-b00a-0a5c635d3014"
}
}
使用 task_id
获取图像
2xx 范围内的 HTTP 状态代码表示请求已成功接受,5xx 范围内的状态代码表示内部服务器错误。
您可以在响应的 images
中获取图像下载地址。
请求:
curl --location --request GET 'https://api.scsd.cn/v3/async/task-result?task_id=698287f4-fc4c-43ff-b00a-0a5c635d3014' \
--header 'Authorization: Bearer {{API Key}}'
返回:
{
"extra": {
"seed": "361250364",
"enable_nsfw_detection": true,
"debug_info": {
"request_info": "{\"model\":\"dreamshaper_8_93211.safetensors\",\"prompts\":[\"Future world, future, science fiction film, science fiction, astronauts walking in a spaceship, astronauts, close-up of upper body, open hands, equipment glowing on the wall, technologically advanced spaceships\"],\"negative_prompts\":[\"\"],\"seeds\":[361250364],\"height\":512,\"width\":384,\"guidance_scale\":7.5,\"num_images_per_prompt\":1,\"num_inference_steps\":20,\"sampler_name\":\"DPM++ 2S a Karras\",\"clip_skip\":1,\"strength\":0.7}",
"submit_time_ms": "1713260232061",
"execute_time_ms": "1713260232253",
"complete_time_ms": "1713260243112"
}
},
"task": {
"task_id": "698287f4-fc4c-43ff-b00a-0a5c635d3014",
"task_type": "IMG_TO_IMG",
"status": "TASK_STATUS_SUCCEED",
"reason": "",
"eta": 0,
"progress_percent": 0
},
"images": [
{
"image_url": "https://faas-output-image-1312767721.cos.ap-shanghai.myqcloud.com/test/698287f4-fc4c-43ff-b00a-0a5c635d3014/3d480552975d4245b702eb81a6418aa8.png?q-sign-algorithm=sha1&q-ak=AKIDHOHvKVnrgHkyxhCTyOdeSjoiRxGPSJ0V&q-sign-time=1713260243%3B1713263843&q-key-time=1713260243%3B1713263843&q-header-list=host&q-url-param-list=&q-signature=e82c298beabf6bb1c77f61e1a4c4ab4b470d74e9",
"image_url_ttl": "3600",
"image_type": "png",
"nsfw_detection_result": null
}
],
"videos": []
}
2. 图生图 controlNet 请求
请在您的HTTP请求中将 content-type
设置为 application/json
,目前仅支持JSON格式。在 playground 试用。
Request with image_assets_id:
curl --location 'https://api.scsd.cn/v3/async/img2img' \
--header 'Authorization: Bearer {{API Key}}' \
--header 'Content-Type: application/json' \
--data '{
"extra": {
"response_image_type": "jpeg"
},
"request": {
"model_name": "realcartoon25D_v3_240762.safetensors",
"prompt": "1girl",
"negative_prompt": "bad quality, bad anatomy, worst quality, low quality, lowres, extra fingers, blur, blurry, ugly, wrong proportions, watermark, image artifacts, bad eyes, bad hands, bad arms",
"height": 1024,
"width": 1024,
"image_num": 1,
"steps": 20,
"seed": -1,
"clip_skip": 1,
"guidance_scale": 7,
"sampler_name": "Euler",
"controlnet": {
"units": [
{
"model_name": "control_v11p_sd15_openpose",
"image_base64": "{{Base64 encode image}}",
"strength": 0.5,
"preprocessor": "openpose"
}
]
},
"image_base64": "{{Base64 encode image}}"
}
}'
返回:
{
"code": 0,
"msg": "",
"data": {
"task_id": "5867de36-7b76-4dc7-876e-818e3ffe683e"
}
}
使用 task_id
获取图像
2xx 范围内的 HTTP 状态代码表示请求已成功接受,5xx 范围内的状态代码表示内部服务器错误。
您可以在响应的 images
中获取图像下载地址。
请求:
curl --location --request GET 'https://api.scsd.cn/v3/async/task-result?task_id=5867de36-7b76-4dc7-876e-818e3ffe683e' \
--header 'Authorization: Bearer {{API Key}}'
返回:
{
"extra": {
"seed": "361250364",
"enable_nsfw_detection": true,
"debug_info": {
"request_info": "{\"model\":\"dreamshaper_8_93211.safetensors\",\"prompts\":[\"Future world, future, science fiction film, science fiction, astronauts walking in a spaceship, astronauts, close-up of upper body, open hands, equipment glowing on the wall, technologically advanced spaceships\"],\"negative_prompts\":[\"\"],\"seeds\":[361250364],\"height\":512,\"width\":384,\"guidance_scale\":7.5,\"num_images_per_prompt\":1,\"num_inference_steps\":20,\"sampler_name\":\"DPM++ 2S a Karras\",\"clip_skip\":1,\"strength\":0.7}",
"submit_time_ms": "1713260232061",
"execute_time_ms": "1713260232253",
"complete_time_ms": "1713260243112"
}
},
"task": {
"task_id": "698287f4-fc4c-43ff-b00a-0a5c635d3014",
"task_type": "IMG_TO_IMG",
"status": "TASK_STATUS_SUCCEED",
"reason": "",
"eta": 0,
"progress_percent": 0
},
"images": [
{
"image_url": "https://faas-output-image-1312767721.cos.ap-shanghai.myqcloud.com/test/698287f4-fc4c-43ff-b00a-0a5c635d3014/3d480552975d4245b702eb81a6418aa8.png?q-sign-algorithm=sha1&q-ak=AKIDHOHvKVnrgHkyxhCTyOdeSjoiRxGPSJ0V&q-sign-time=1713260243%3B1713263843&q-key-time=1713260243%3B1713263843&q-header-list=host&q-url-param-list=&q-signature=e82c298beabf6bb1c77f61e1a4c4ab4b470d74e9",
"image_url_ttl": "3600",
"image_type": "png",
"nsfw_detection_result": null
}
],
"videos": []
}