SDXL Controlnet

SDXL ControlNet gives unprecedented control over text-to-image generation. SDXL ControlNet models Introduces the concept of conditioning inputs, which provide additional information to guide the image generation process

~10.47s
~$0.012
 1import requests
 2import json
 3
 4url = "https://api.segmind.com/v1/sdxl-controlnet"
 5headers = {
 6    "x-api-key": "YOUR_API_KEY",
 7    "Content-Type": "application/json"
 8}
 9
10data = {
11    "image": "https://segmind-sd-models.s3.amazonaws.com/display_images/sdxl-controlnet-input.jpeg",
12    "prompt": "American woman, smiling, waving, eyeglasses, casual clothing, sitting at desk, laptop, home office, indoor, daylight, modern decor, house plants, bookshelf, natural lighting",
13    "negative_prompt": "low quality, ugly, painting, extra fingers, deformed",
14    "samples": 1,
15    "scheduler": "UniPC",
16    "cn_model": "sdxl_canny",
17    "num_inference_steps": 30,
18    "guidance_scale": 6,
19    "seed": 760941192,
20    "controlnet_scale": 0.9,
21    "base64": false
22}
23
24response = requests.post(url, headers=headers, json=data)
25
26if response.status_code == 200:
27    result = response.json()
28    print(json.dumps(result, indent=2))
29else:
30    print(f"Error: {response.status_code}")
31    print(response.text)

API Endpoint

POSThttps://api.segmind.com/v1/sdxl-controlnet

Parameters

imagerequired
string (uri)

Input Image

promptrequired
string

Prompt to render

base64optional
boolean

Base64 encoding of the output image.

Default: false
cn_modeloptional
string

Type of Controlnet

Default: "sdxl_canny"
Allowed values :
"sdxl_canny""sdxl_depth""sdxl_scribble""sdxl_softedge""sdxl_openpose"
controlnet_scaleoptional
number

Controlnet Strength

Default: 0.9Range: 0 - 1
guidance_scaleoptional
number

Scale for classifier-free guidance

Default: 6Range: 1 - 25
negative_promptoptional
string

Prompts to exclude, eg. 'bad anatomy, bad hands, missing fingers'

num_inference_stepsoptional
integer

Number of denoising steps.

Default: 30Range: 10 - 100
samplesoptional
integer

Number of samples to generate.

Default: 1Range: 1 - 4
scheduleroptional
string

Type of scheduler.

Default: "DPM2 Karras"
Allowed values (29 total):
"DPM++ SDE Karras""DPM++ 2M Karras""DPM++ 2M SDE Karras""DPM++ 2M SDE Heun Karras""DPM++ 3M SDE Karras""LMS Karras""DPM2 Karras""DPM2 a Karras""DPM++ 2S a Karras""DPM++ 2M SDE Exponential"+19 more
seedoptional
integer

Seed for image generation.

Default: -1Range: -1 - 999999999999999

Response Type

Returns: Image

Common Error Codes

The API returns standard HTTP status codes. Detailed error messages are provided in the response body.

400

Bad Request

Invalid parameters or request format

401

Unauthorized

Missing or invalid API key

403

Forbidden

Insufficient permissions

404

Not Found

Model or endpoint not found

406

Insufficient Credits

Not enough credits to process request

429

Rate Limited

Too many requests

500

Server Error

Internal server error

502

Bad Gateway

Service temporarily unavailable

504

Timeout

Request timed out