1

Prerequisites

To get the most out of this guide, you’ll need to:

2

Install the SDK

Get the Livepeer AI JavaScript SDK.

npm add @livepeer/ai
3

Initialize the SDK

The first step is to initialize the SDK (with your API key if required).

import { Livepeer } from "@livepeer/ai";

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

Use the SDK

Now that you have the SDK installed and initialized, you can use it to request one of the available AI services.

import { Livepeer } from "@livepeer/ai";

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

async function run() {
  const result = await livepeer.generate.textToImage({
    prompt: "<value>",
  });

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

run();

Next steps

Checkout Livepeer AI API Reference to learn more about the Livepeer AI API and the Javascript SDK.