POST
/
text-to-image
import { Livepeer } from "@livepeer/ai";

const livepeer = new Livepeer({
  httpBearer: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await livepeer.generate.textToImage({
    modelId: "",
    loras: "",
    prompt: "<value>",
    height: 576,
    width: 1024,
    guidanceScale: 7.5,
    negativePrompt: "",
    safetyCheck: true,
    numInferenceSteps: 50,
    numImagesPerPrompt: 1,
  });

  // Handle the result
  console.log(result);
}

run();
{
  "images": [
    {
      "url": "<string>",
      "seed": 123,
      "nsfw": true
    }
  ]
}

The default Gateway used in this guide is the public Livepeer.cloud Gateway. It is free to use but not intended for production-ready applications. For production-ready applications, consider using the Livepeer Studio Gateway, which requires an API token. Alternatively, you can set up your own Gateway node or partner with one via the ai-video channel on Discord.

Please note that the exact parameters, default values, and responses may vary between models. For more information on model-specific parameters, please refer to the respective model documentation available in the text pipeline. Not all parameters might be available for a given model.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
model_id
string
default:
required

Hugging Face model ID used for image generation.

prompt
string
required

Text prompt(s) to guide image generation. Separate multiple prompts with '|' if supported by the model.

loras
string
default:

A LoRA (Low-Rank Adaptation) model and its corresponding weight for image generation. Example: { "latent-consistency/lcm-lora-sdxl": 1.0, "nerijs/pixel-art-xl": 1.2}.

height
integer
default:
576

The height in pixels of the generated image.

width
integer
default:
1024

The width in pixels of the generated image.

guidance_scale
number
default:
7.5

Encourages model to generate images closely linked to the text prompt (higher values may reduce image quality).

negative_prompt
string
default:

Text prompt(s) to guide what to exclude from image generation. Ignored if guidance_scale < 1.

safety_check
boolean
default:
true

Perform a safety check to estimate if generated images could be offensive or harmful.

seed
integer

Seed for random number generation.

num_inference_steps
integer
default:
50

Number of denoising steps. More steps usually lead to higher quality images but slower inference. Modulated by strength.

num_images_per_prompt
integer
default:
1

Number of images to generate per prompt.

Response

200
application/json
Successful Response

Response model for image generation.

images
object[]
required

The generated images.