> ## Documentation Index
> Fetch the complete documentation index at: /llms.txt
> Use this file to discover all available pages before exploring further.

# JavaScript

> Learn how to run your first AI inference job using the Livepeer AI JS SDK.

**1. Prerequisites**

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

* [Choose an AI Gateway](/ai/builders/gateways.md)
* **Optional**: Get an API key (required for some gateways).

**2. Install the SDK**

Get the Livepeer AI JavaScript SDK.

```bash theme={null}
npm add @livepeer/ai
```

**3. Initialize the SDK**

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

```js theme={null}
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](/ai/pipelines/overview.md).

```js theme={null}
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();
```

**5. Try it yourself**

> [card] [Javascript Examples](https://github.com/livepeer/livepeer-ai-js/tree/main/docs/sdks/generate#generate)
>
> See the examples on GitHub.

## Next steps

Checkout Livepeer AI [API Reference](/ai/api-reference) to learn more about the
Livepeer AI API and the Javascript SDK.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.