Kandinsky 2.2

Kandinsky inherits best practicies from Dall-E 2 and Latent diffusion, while introducing some new ideas.

~1.98s
~$0.005
 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

POSThttps://api.segmind.com/v1/kandinsky2.2-txt2img

Parameters

promptrequired
string

Prompt to render

base64optional
boolean

Base64 encoding of the output image.

Default: false
img_heightoptional
integer

Image resolution.

Default: 768
Allowed values :
7681024
img_widthoptional
integer

Image resolution.

Default: 768
Allowed values :
7681024
negative_promptoptional
string

Prompts to exclude, eg. 'bad anatomy, bad hands, missing fingers'

num_inference_stepsoptional
integer

Number of denoising steps.

Default: 20Range: 20 - 100
prior_stepsoptional
integer

Number of denoising steps.

Default: 25Range: 1 - 100
samplesoptional
integer

Number of samples to generate.

Default: 1Range: 1 - 4
seedoptional
integer

Seed for image generation.

Default: -1

Response 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