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-large-txt2img"
# Request payload
data = {
"prompt": "~*~ aesthetic ~*~ #boho #fashion full-body 30-something woman laying on microfloral grass, candid pose, overlay reads Stable Diffusion 3.5, cheerful cursive typography font,",
"negative_prompt": "low quality, blurry",
"steps": 25,
"guidance_scale": 5.5,
"seed": 98552302,
"sampler": "euler",
"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
Prompt for image generation
The negative prompt to exclude unwanted details
Number of inference steps for generating the image
min : 10,
max : 70
Guidance scale for controlling how closely the generation matches the prompt
min : 1,
max : 15
Random number,seed for image generation
Sampling method for image generation
Allowed values:
Scheduler for image generation
Allowed values:
Width of the output image in pixels
min : 64,
max : 2048
Height of the output image in pixels
min : 64,
max : 2048
Aspect ratio of the output image. Select 'custom' to specify the width and height manually.
Allowed values:
Number of images to generate in one batch
min : 1,
max : 10
Output image format
Allowed values:
Image quality setting for output
min : 10,
max : 100
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 Large Text-to-Image (SD3.5 Large) is the latest and most advanced addition to the Stable Diffusion family of image-to-image models. SD3.5 text-to-image Large 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 Large can run efficiently on consumer-grade hardware, including consumer PCs and laptops, as well as enterprise-tier GPUs. SD3.5 Large is designed to be more resource-efficient, making it a better choice for users with limited computational resources.
SD3.5 Large 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 Large incorporates typography within your images with unparalleled precision, making your message shine.