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

# SDK

> Programmatic access to Eden's generative AI capabilities

> [!NOTE]
>
> API keys are currently in beta. If you'd like to use the SDK, please reach out to the devs on [Discord](https://discord.com/invite/4dSYwDT).

The Eden SDK is a JavaScript library for interacting with the Eden API. The SDK allows you to make creation requests programatically and integrate Eden-facing widgets into your own applications. It is available as an npm package, with a commonjs version and Python SDK also planned for the near future.

Full API documentation is available at [https://api.eden.art/documentation](https://api.eden.art/documentation/). Some browsers have issues opening the documentation, so if you have trouble, try using a different browser or use incognito mode.

## Get API credentials

To get an API key, please message one of the devs in [the Discord](https://discord.com/invite/4dSYwDT) and ask for one.

## Installation

```bash npm theme={null}
npm install @edenlabs/eden-sdk
```

```bash yarn theme={null}
yarn add @edenlabs/eden-sdk
```

```bash pnpm theme={null}
pnpm add @edenlabs/eden-sdk
```

## Make a creation

A full list of generators and their config parameters can be found in the [creation tool](https://app.eden.art/create).

All requests to Eden go through the `EdenClient` class. To make a task request, target a specific generator (e.g. "create") with a configuration object. For example:

```javascript theme={null}
import {EdenClient} from "@edenlabs/eden-sdk";

const eden = new EdenClient({
  apiKey: "YOUR_EDEN_API_KEY",
  apiSecret: "YOUR_EDEN_API_SECRET",
});

const config = {
  text_input: "An apple tree in a field",
};

const urls = await eden.create({
  generatorName: "create",
  config: config
});
console.log(urls[0])
```

## Manual task polling

Alternatively, you can create a task and poll for the result manually:

```javascript theme={null}
const taskResult = await eden.tasks.create({
  generatorName: "create", 
  config: config
});
```

The `tasks.create` method is asynchronous and will immediately return a `taskResult` object with an ID for that task (or an error message). If you want to wait for the task to complete, you can poll the task until it is done:

```javascript theme={null}
const pollForTask = async function(pollingInterval, taskId) {
  let finished = false;
  while (!finished) {
    const taskResult = await eden.tasks.get({taskId: taskId});
    if (taskResult.task.status == "failed") {
      throw new Error('Failed')
    }
    else if (taskResult.task.status == "completed") {
      finished = true;
      const url = taskResult.task.creation.uri;
      return url;
    }
    await new Promise(resolve => setTimeout(resolve, pollingInterval))
  }
}

const result = await pollForTask(5000, taskResult.taskId);
```

## Hello Eden

> [card] [Example React App](https://github.com/edenartlab/hello-eden)
>
> An example React app which shows how to authenticate with the Eden SDK and make creations in a boilerplate NextJS web application


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