Story Diffusion

Story Diffusion turns your written narratives into stunning image sequences.

~119.73s
~$0.166
 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

POSThttps://api.segmind.com/v1/storydiffusion

Parameters

character_descriptionoptional
string

Add 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'

Default: "a man wearing black suit"
comic_descriptionoptional
string

Remove [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.

Default: "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_styleoptional
string
Default: "Classic Comic Style"
Allowed values :
"Four Pannel""Classic Comic Style"
guidance_scaleoptional
number

Scale for classifier-free guidance

Default: 5Range: 0.1 - 10
image_heightoptional
integer
Default: 768
Allowed values (25 total):
256288320352384416448480512544+15 more
image_widthoptional
integer
Default: 768
Allowed values (25 total):
256288320352384416448480512544+15 more
negative_promptoptional
string

Describe things you do not want to see in the output

Default: "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_idsoptional
integer

Number of id images in total images. This should not exceed total number of line-separated prompts

Default: 3
num_stepsoptional
integer

Number of sample steps

Default: 25Range: 20 - 50
output_formatoptional
string
Default: "webp"
Allowed values :
"webp""jpg""png"
output_qualityoptional
integer

Quality of the output images, from 0 to 100. 100 is best quality, 0 is lowest quality

Default: 80Range: 0 - 100
ref_imageoptional
string (uri)

Reference image for the character

Default: null
sa32_settingoptional
number

The degree of Paired Attention at 32 x 32 self-attention layers

Default: 0.5Range: 0 - 1
sa64_settingoptional
number

The degree of Paired Attention at 64 x 64 self-attention layers

Default: 0.5Range: 0 - 1
sd_modeloptional
string
Default: "Unstable"
Allowed values :
"Unstable""RealVision"
seedoptional
integer

Random seed. Leave blank to randomize the seed

Default: 42
style_nameoptional
string
Default: "Disney Charactor"
Allowed values :
"(No style)""Japanese Anime""Cinematic""Disney Charactor""Photographic""Comic book""Line art"
style_strength_ratiooptional
integer

Style strength of Ref Image (%), only used if ref_image is provided

Default: 20Range: 15 - 50

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