0.4.6 • Published 8 months ago

@edenlabs/eden-sdk v0.4.6

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

Eden SDK

The official SDK for interacting with the Eden API. Supports both Node.js and browser environments.

Installation

npm install @edenlabs/eden-sdk
# or
yarn add @edenlabs/eden-sdk

Environment-Specific Configuration

Node.js Environment

When using the SDK in a Node.js environment, no additional configuration is required. The SDK will automatically use the appropriate EventSource implementation.

Browser Environment (Webpack 5+)

If you're using Webpack 5 or later in a browser environment, you'll need to add the following configuration to your webpack.config.js:

module.exports = {
  // ... other config
  resolve: {
    fallback: {
      "url": false,
      "http": false,
      "https": false,
      "util": false
    }
  }
}

Browser Environment (Using pre-built bundle)

For browser applications, you can use our pre-built UMD bundle which includes all necessary polyfills:

<script src="https://unpkg.com/@edenlabs/eden-sdk@0.4.6/dist/index.umd.js"></script>

The UMD bundle is specifically built to work in browsers without any additional configuration. If you're experiencing issues with the ES module version in a browser environment, we recommend using this UMD bundle instead.

Or import it in your module bundler:

import { EdenClient } from '@edenlabs/eden-sdk';

Basic Usage

import { EdenClient } from '@edenlabs/eden-sdk';

const client = new EdenClient({
  apiKey: 'your-api-key',
});

// Example: Create a task
const result = await client.tasks.createV2({
  tool: 'flux_dev',
  args: {
    prompt: 'Garden of Eden'
  }
});

Environment Detection

The SDK automatically detects whether it's running in Node.js or a browser environment and uses the appropriate EventSource implementation. No manual configuration is required for this feature.

Troubleshooting

Webpack 5 Polyfill Issues

If you encounter errors related to missing Node.js core modules (url, http, https, util), make sure you've added the fallback configuration as shown in the "Browser Environment (Webpack 5+)" section above.

SSE (Server-Sent Events) Connection Issues

  • For Node.js: Make sure you have network access to the Eden API endpoint
  • For Browsers: Ensure CORS is properly configured if you're running in a different domain

License

MIT

A thin wrapper around the Eden REST API. Inspect methods.ts for all available methods.

Creating an Eden instance

import { EdenClient } from "@edenlabs/eden-sdk";

const apiKey = 'YOUR_API_KEY';

const eden = new EdenClient({ apiKey });

Making a creation

Submit a task and await creation result

const input = {
  tool: "flux_dev",
  args: {
    prompt: "Garden of Eden"
  }
}

const result = await eden.createV2(input);

Submit a task and return task data immediately, without waiting for creation result

const input = {
  tool: "flux_dev",
  args: {
    prompt: "Garden of Eden"
  }
}

const result = await eden.createV2(input, false);

Creations

Get a single creation by id

const creation = await eden.creations.getV2({creationId: '1234567890'})

Tasks

Get a single task by id

const task = await eden.tasks.getV2({taskId: '1234567890'})

Get paginated list of tasks

const tasks = await eden.tasks.listV2();

Get paginated list of tasks filterd by tool and status

const tasks = await eden.tasks.listV2({ tool: 'flux_dev', status: 'pending' });

Tools

To get a list of all the tools available:

const tools = await eden.tools.list();

Get a single tool by key

const tool = await eden.tools.get({key: 'flux_dev'});

Uploading an image

import fs from 'fs'

const filepath = `${__dirname}/test.png`
const media = await fs.readFileSync(filepath)

const result = await eden.media.upload({ media })

Examples

See examples/ for more (*V2.js)

0.4.4

9 months ago

0.4.6

8 months ago

0.4.3

9 months ago

0.4.2

11 months ago

0.3.9

1 year ago

0.3.6

1 year ago

0.3.5

1 year ago

0.3.8

1 year ago

0.3.7

1 year ago

0.4.1

1 year ago

0.4.0

1 year ago

0.3.4

1 year ago

0.3.3

1 year ago

0.3.2

2 years ago

0.3.0

2 years ago

0.3.1

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago