Story Diffusion
Story Diffusion turns your written narratives into stunning image sequences.
1import requests
2import json
3
4url = "https://api.segmind.com/v1/storydiffusion"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "seed": 42,
12 "num_ids": 3,
13 "sd_model": "Unstable",
14 "num_steps": 25,
15 "image_width": 768,
16 "image_height": 768,
17 "sa32_setting": 0.5,
18 "sa64_setting": 0.5,
19 "output_format": "webp",
20 "guidance_scale": 5,
21 "output_quality": 80,
22 "negative_prompt": "bad anatomy, bad hands, missing fingers, extra fingers, three hands, three legs, bad arms, missing legs, missing arms, poorly drawn face, bad face, fused face, cloned face, three crus, fused feet, fused thigh, extra crus, ugly fingers, horn, cartoon, cg, 3d, unreal, animate, amputation, disconnected limbs",
23 "character_description": "a man, wearing black suit",
24 "comic_description": "at home, read new paper #at home, The newspaper says there is a treasure house in the forest.\non the road, near the forest\n[NC] The car on the road, near the forest #He drives to the forest in search of treasure.\n[NC]A tiger appeared in the forest, at night \nvery frightened, open mouth, in the forest, at night\nrunning very fast, in the forest, at night\n[NC] A house in the forest, at night #Suddenly, he discovers the treasure house!\nin the house filled with treasure, laughing, at night #He is overjoyed inside the house.",
25 "style_strength_ratio": 20,
26 "style_name": "Disney Charactor",
27 "comic_style": "Classic Comic Style"
28}
29
30response = requests.post(url, headers=headers, json=data)
31
32if response.status_code == 200:
33 result = response.json()
34 print(json.dumps(result, indent=2))
35else:
36 print(f"Error: {response.status_code}")
37 print(response.text) 1import requests
2import json
3
4url = "https://api.segmind.com/v1/storydiffusion"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "seed": 42,
12 "num_ids": 3,
13 "sd_model": "Unstable",
14 "num_steps": 25,
15 "image_width": 768,
16 "image_height": 768,
17 "sa32_setting": 0.5,
18 "sa64_setting": 0.5,
19 "output_format": "webp",
20 "guidance_scale": 5,
21 "output_quality": 80,
22 "negative_prompt": "bad anatomy, bad hands, missing fingers, extra fingers, three hands, three legs, bad arms, missing legs, missing arms, poorly drawn face, bad face, fused face, cloned face, three crus, fused feet, fused thigh, extra crus, ugly fingers, horn, cartoon, cg, 3d, unreal, animate, amputation, disconnected limbs",
23 "character_description": "a man, wearing black suit",
24 "comic_description": "at home, read new paper #at home, The newspaper says there is a treasure house in the forest.\non the road, near the forest\n[NC] The car on the road, near the forest #He drives to the forest in search of treasure.\n[NC]A tiger appeared in the forest, at night \nvery frightened, open mouth, in the forest, at night\nrunning very fast, in the forest, at night\n[NC] A house in the forest, at night #Suddenly, he discovers the treasure house!\nin the house filled with treasure, laughing, at night #He is overjoyed inside the house.",
25 "style_strength_ratio": 20,
26 "style_name": "Disney Charactor",
27 "comic_style": "Classic Comic Style"
28}
29
30response = requests.post(url, headers=headers, json=data)
31
32if response.status_code == 200:
33 result = response.json()
34 print(json.dumps(result, indent=2))
35else:
36 print(f"Error: {response.status_code}")
37 print(response.text)API Endpoint
https://api.segmind.com/v1/storydiffusionParameters
character_descriptionoptionalstringAdd triger word 'img' when using ref_image. General description of the character. If ref_image above is provided, making sure to follow the class word you want to customize with the trigger word 'img', such as: 'man img' or 'woman img' or 'girl img'
"a man wearing black suit"comic_descriptionoptionalstringRemove [NC] when using Ref_image Each frame is divided by a new line. Only the first 10 prompts are valid for demo speed! For comic_description NOT using ref_image: (1) Support Typesetting Style and Captioning. By default, the prompt is used as the caption for each image. If you need to change the caption, add a '#' at the end of each line. Only the part after the '#' will be added as a caption to the image. (2) The [NC] symbol is used as a flag to indicate that no characters should be present in the generated scene images. If you want do that, prepend the '[NC]' at the beginning of the line.
"at home, read new paper #at home, The newspaper says there is a treasure house in the forest.\non the road, near the forest\n[NC] The car on the road, near the forest #He drives to the forest in search of treasure.\n[NC]A tiger appeared in the forest, at night \nvery frightened, open mouth, in the forest, at night\nrunning very fast, in the forest, at night\n[NC] A house in the forest, at night #Suddenly, he discovers the treasure house!\nin the house filled with treasure, laughing, at night #He is overjoyed inside the house."comic_styleoptionalstring"Classic Comic Style""Four Pannel""Classic Comic Style"guidance_scaleoptionalnumberScale for classifier-free guidance
5Range: 0.1 - 10image_heightoptionalinteger768256288320352384416448480512544+15 moreimage_widthoptionalinteger768256288320352384416448480512544+15 morenegative_promptoptionalstringDescribe things you do not want to see in the output
"bad anatomy, bad hands, missing fingers, extra fingers, three hands, three legs, bad arms, missing legs, missing arms, poorly drawn face, bad face, fused face, cloned face, three crus, fused feet, fused thigh, extra crus, ugly fingers, horn, cartoon, cg, 3d, unreal, animate, amputation, disconnected limbs"num_idsoptionalintegerNumber of id images in total images. This should not exceed total number of line-separated prompts
3num_stepsoptionalintegerNumber of sample steps
25Range: 20 - 50output_formatoptionalstring"webp""webp""jpg""png"output_qualityoptionalintegerQuality of the output images, from 0 to 100. 100 is best quality, 0 is lowest quality
80Range: 0 - 100ref_imageoptionalstring (uri)Reference image for the character
nullsa32_settingoptionalnumberThe degree of Paired Attention at 32 x 32 self-attention layers
0.5Range: 0 - 1sa64_settingoptionalnumberThe degree of Paired Attention at 64 x 64 self-attention layers
0.5Range: 0 - 1sd_modeloptionalstring"Unstable""Unstable""RealVision"seedoptionalintegerRandom seed. Leave blank to randomize the seed
42style_nameoptionalstring"Disney Charactor""(No style)""Japanese Anime""Cinematic""Disney Charactor""Photographic""Comic book""Line art"style_strength_ratiooptionalintegerStyle strength of Ref Image (%), only used if ref_image is provided
20Range: 15 - 50Response Type
Returns: Image
Common Error Codes
The API returns standard HTTP status codes. Detailed error messages are provided in the response body.
Bad Request
Invalid parameters or request format
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions
Not Found
Model or endpoint not found
Insufficient Credits
Not enough credits to process request
Rate Limited
Too many requests
Server Error
Internal server error
Bad Gateway
Service temporarily unavailable
Timeout
Request timed out