text-to-image

Create image from text - Classic fast

Convert descriptive text input into images using AI. This endpoint accepts a variety of parameters to customize the generated images.

post/v1/ai/text-to-image

Request

  • Base URL: https://api.magnific.com
  • URL: https://api.magnific.com/v1/ai/text-to-image
  • Auth: API key in header x-magnific-api-key

Request body

promptstring required

Text to generate image from Minimum length: 3 characters

negative_promptstring

Attributes to avoid in the generated image Minimum length: 3 characters

guidance_scalenumber

Defines the level of fidelity to the prompt when generating the image. A lower value allows for more creativity from the AI, while a higher value ensures closer adherence to the prompt. Valid values range [0.0, 2.0], default 1.0.

num_imagesinteger

Specifies the number of images to generate in a single request. Valid values range [1, 4], default 1.

seedinteger

Seed value for image generation. Using the same seed will produce the same image. If omitted, random seed will be applied, resulting in a different image each time. Valid values range [0, 1000000].

filter_nsfwboolean

If true, the generated image will be filtered for NSFW content. If false, the image may contain NSFW content. Default value is true.

Example request

{
  "prompt": "Crazy dog flying over the space",
  "negative_prompt": "b&w, grayscale, disfigured, bad quality",
  "styling": {
    "style": "cartoon",
    "colors": [
      {
        "color": "#FF0000",
        "weight": 0.5
      }
    ],
    "effects": {
      "color": "b&w",
      "lightning": "warm",
      "framing": "portrait"
    }
  },
  "guidance_scale": 2,
  "image": {
    "size": "square_1_1"
  },
  "num_images": 1,
  "seed": 123,
  "filter_nsfw": true
}

Response

OK - The request has succeeded, and the images generated from the text are returned.

Example response

{
  "data": [
    {
      "base64": "iVBORw0KGgoAAAANSUhEUgAAASwAAAEsAQAAAABRBrPYAAABrElEQVR4nO3BMQEAAADCoPVPbQ0Po...",
      "has_nsfw": false
    },
    {
      "base64": "iVBORw0KGgoAAAANSUhEUgAAASwAAAEsAQAAAABRBrPYAAABrElEQVR4nO3BMQEAAADCoPVPbQ0Po...",
      "has_nsfw": false
    }
  ],
  "meta": {
    "image": {
      "size": "square_1_1",
      "width": 1024,
      "height": 1024
    },
    "seed": 42,
    "guidance_scale": 2,
    "prompt": "Crazy dog flying over the space",
    "num_inference_steps": 8
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.