POST
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 import requests import base64 # Use this function to convert an image file from the filesystem to base64 def image_file_to_base64(image_path): with open(image_path, 'rb') as f: image_data = f.read() return base64.b64encode(image_data).decode('utf-8') # Use this function to fetch an image from a URL and convert it to base64 def image_url_to_base64(image_url): response = requests.get(image_url) image_data = response.content return base64.b64encode(image_data).decode('utf-8') api_key = "YOUR_API_KEY" url = "https://api.segmind.com/v1/stable-diffusion-3.5-turbo-txt2img" # Request payload data = { "prompt": "A panda in a glowing tech-infused jacket, standing in front of a bustling cyberpunk market, his T-shirt displaying 'Segmind'. Neon lights illuminate his face, with a futuristic cityscape behind him. Reflections shimmer on the wet pavement.", "negative_prompt": "low quality, blurry", "steps": 4, "guidance_scale": 1, "seed": 98552302, "sampler": "dpmpp_2m", "scheduler": "sgm_uniform", "width": 1024, "height": 1024, "aspect_ratio": "custom", "batch_size": 1, "image_format": "jpeg", "image_quality": 95, "base64": False } headers = {'x-api-key': api_key} response = requests.post(url, json=data, headers=headers) print(response.content) # The response is the generated image
RESPONSE
image/jpeg
HTTP Response Codes
200 - OKImage Generated
401 - UnauthorizedUser authentication failed
404 - Not FoundThe requested URL does not exist
405 - Method Not AllowedThe requested HTTP method is not allowed
406 - Not AcceptableNot enough credits
500 - Server ErrorServer had some issue with processing

Attributes


promptstr *

Prompt for image generation


negative_promptstr ( default: low quality, blurry )

The negative prompt to exclude unwanted details


stepsint ( default: 4 )

Number of inference steps for generating the image

min : 10,

max : 70


guidance_scalefloat ( default: 1 )

Guidance scale for controlling how closely the generation matches the prompt

min : 1,

max : 15


seedint ( default: 98552302 )

Random number,seed for image generation


samplerenum:str *

Sampling method for image generation

Allowed values:


schedulerenum:str *

Scheduler for image generation

Allowed values:


widthint ( default: 1024 )

Width of the output image in pixels

min : 64,

max : 2048


heightint ( default: 1024 )

Height of the output image in pixels

min : 64,

max : 2048


aspect_ratioenum:str ( default: custom )

Aspect ratio of the output image. Select 'custom' to specify the width and height manually.

Allowed values:


batch_sizeint ( default: 1 )

Number of images to generate in one batch

min : 1,

max : 10


image_formatenum:str ( default: jpeg )

Output image format

Allowed values:


image_qualityint ( default: 95 )

Image quality setting for output

min : 10,

max : 100


base64bool ( default: 1 )

Output as base64 encoded string

To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.

Stable Diffusion 3.5 Turbo Text-to-Image

Stable Diffusion 3.5 Turbo Text-to-Image (SD3.5 Turbo) is the latest and most advanced addition to the Stable Diffusion family of image-to-image models. SD3.5 text-to-image Turbo is designed to be more resource-efficient, making it a better choice for users with limited computational resources. Due to its smaller size, SD3.5 Turbo can run efficiently on consumer-grade hardware, including consumer PCs and laptops, as well as enterprise-tier GPUs. SD3.5 Turbo is designed to be more resource-efficient, making it a better choice for users with limited computational resources.

Stable Diffusion 3.5 Turbo Text-to-Image Capabilities

SD3.5 Turbo crafts stunningly realistic images, breaking new ground in photorealistic generation. It also tackles intricate prompts with multiple subjects, even if you have a typo or two. SD3.5 Turbo incorporates typography within your images with unparalleled precision, making your message shine.