Kandinsky 2.2 Serverless API
Kandinsky inherits best practicies from Dall-E 2 and Latent diffusion, while introducing some new ideas.
~2.00s
1import requests
2import json
3
4url = "https://api.segmind.com/v1/kandinsky2.2-txt2img"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "masterpiece, best quality, portrait of an old man, 50mm, solo, natural skin texture, realistic eye and face details, dark, deep shadow, darkness, moonlight, award winning photo, extremely detailed, fine detail, highly detailed, extremely detailed eyes and face, piercing red eyes, detailed clothes, skinny, gothic, native american clothing, analog film, stock photograph,",
12 "negative_prompt": "lowres, text, error, cropped, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, out of frame, extra fingers, mutated hands",
13 "samples": 1,
14 "num_inference_steps": 25,
15 "img_width": 512,
16 "img_height": 768,
17 "prior_steps": 25,
18 "seed": 9863172,
19 "base64": false
20}
21
22response = requests.post(url, headers=headers, json=data)
23
24if response.status_code == 200:
25 result = response.json()
26 print(json.dumps(result, indent=2))
27else:
28 print(f"Error: {response.status_code}")
29 print(response.text) 1import requests
2import json
3
4url = "https://api.segmind.com/v1/kandinsky2.2-txt2img"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "masterpiece, best quality, portrait of an old man, 50mm, solo, natural skin texture, realistic eye and face details, dark, deep shadow, darkness, moonlight, award winning photo, extremely detailed, fine detail, highly detailed, extremely detailed eyes and face, piercing red eyes, detailed clothes, skinny, gothic, native american clothing, analog film, stock photograph,",
12 "negative_prompt": "lowres, text, error, cropped, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, out of frame, extra fingers, mutated hands",
13 "samples": 1,
14 "num_inference_steps": 25,
15 "img_width": 512,
16 "img_height": 768,
17 "prior_steps": 25,
18 "seed": 9863172,
19 "base64": false
20}
21
22response = requests.post(url, headers=headers, json=data)
23
24if response.status_code == 200:
25 result = response.json()
26 print(json.dumps(result, indent=2))
27else:
28 print(f"Error: {response.status_code}")
29 print(response.text)API Endpoint
POST
https://api.segmind.com/v1/kandinsky2.2-txt2imgParameters
promptrequiredstringPrompt to render
base64optionalbooleanBase64 encoding of the output image.
Default:
falseimg_heightoptionalintegerImage resolution.
Default:
768Allowed values :
7681024img_widthoptionalintegerImage resolution.
Default:
768Allowed values :
7681024negative_promptoptionalstringPrompts to exclude, eg. 'bad anatomy, bad hands, missing fingers'
num_inference_stepsoptionalintegerNumber of denoising steps.
Default:
20Range: 20 - 100prior_stepsoptionalintegerNumber of denoising steps.
Default:
25Range: 1 - 100samplesoptionalintegerNumber of samples to generate.
Default:
1Range: 1 - 4seedoptionalintegerSeed for image generation.
Default:
-1Response Type
Returns: Text/JSON
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