Text To Image
🎨

Text To Image

image

[POST] https://api.nichetensor.com/api/v1/txt2img

  • Header
NAME
TYPE
REQUIRED
API_KEY
string
✔️
  • Body
NAME
TYPE
REQUIRED
DESCRIPTION
Available Choices
prompt
string
✔️
The textual prompt used to generate the image.
model_name
string
✔️
The name of the model to use for image generation.
AnimeV3, DreamShaperXL, JuggernautXL , RealitiesEdgeXL, StickerMaker
seed
integer
The seed value for the random number generator. Use 0 for a random seed. Default: 0
aspect_ratio
string
Ratio of image to generate. Default: 1:1
1:1, 2:3, 3:2 , 16:9, 9:16, 13:19, 19:13
negative_prompt
string
List things to avoid to generation. Empty by default
advanced_params
object
Advanced params such as number of steps and guidance scale.
advanced_params.use_expansion
bool
Use prompt expansion for more aesthetic output
True, False
  • Example Request in Python
  • import requests
     
    API_KEY = "YOUR_API_KEY" 
    endpoint = "https://api.nichetensor.com/api/v1/txt2img"
    headers = {"API_KEY": API_KEY}
    
    data = {
        "prompt": "a cute cat",
        "model_name": "AnimeV3",
        "seed": 0,
        "aspect_ratio": "13:19",
        "negative_prompt": "low quality",
        "advanced_params": {"num_inference_steps": 20, "use_expansion": True}
    }
     
    response = requests.post(endpoint, json=data, headers=headers)
     
    print(response.status_code)
    print(response.json())
  • Example Response
  • { // image is base64-encoded
    		"image": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4n" # base64 image
    }

    The base64-encoded image can be converted to PIL using:

    def base64_to_pil_image(base64_image):
        image = base64.b64decode(base64_image)
        image = io.BytesIO(image)
        image = Image.open(image)
        return image