npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-dream-machine-api

v0.2.0

Published

The luma dream machine api for node.js

Downloads

9

Readme

NodeDreamMachineAPI

NodeDreamMachineAPI is a TypeScript/JavaScript library for interacting with the Luma Labs AI Dream Machine API. It provides an easy-to-use interface for generating AI-powered videos and images.

Installation

You can install the package using npm or pnpm:

npm install node-dream-machine-api

or

pnpm install node-dream-machine-api

Usage

First, import the NodeDreamMachineAPI class:

import { NodeDreamMachineAPI } from 'node-dream-machine-api';

Then, create an instance of the API with your access token:

const api = new NodeDreamMachineAPI('your luma_session here');

To find your luma session id, you need to:

  1. Login to lumalabs.ai
  2. Right click on the page and click "inspect"
  3. Go to Application in the dev tools
  4. Find "https://lumalabs.ai under cookies
  5. Click on luma_session
  6. Copy the cookie value - that is your luma session id!

Screenshot

API Reference

make(options: MakeOptions)

Generate a new video or image based on the provided options.

Parameters:

  • options: MakeOptions
    • prompt: string - The text prompt for generation
    • imgFile?: string - Path to an optional input image file
    • imgEndFile?: string - Path to an optional end image file
    • aspectRatio?: string - Optional aspect ratio for the generated content

Returns: A Promise that resolves with the generation result.

Example:

const result = await api.make({
  prompt: "A serene lake surrounded by mountains",
  aspectRatio: "16:9"
});

refresh(options?: RefreshOptions)

Retrieve a list of recent generations.

Parameters:

  • options?: RefreshOptions
    • offset?: number - Starting index for pagination (default: 0)
    • limit?: number - Number of items to retrieve (default: 10)

Returns: A Promise that resolves with a list of recent generations.

Example:

const recentGenerations = await api.refresh({ limit: 5 });

getVideoDownloadUrl(videoId: string)

Get the download URL for a generated video.

Parameters:

  • videoId: string - The ID of the generated video

Returns: A Promise that resolves with the video download URL.

Example:

const downloadUrl = await api.getVideoDownloadUrl("video_id_here");

Note on File Upload Functionality

The file upload functionality (imgFile and imgEndFile in the make method) is only available in Node.js environments. Attempting to use these features in a browser environment will result in an error.

Error Handling

All methods may throw errors if the API request fails or if invalid parameters are provided. It's recommended to use try-catch blocks or .catch() methods when calling these functions.

Example:

try {
  const result = await api.make({ prompt: "A futuristic city" });
  console.log(result);
} catch (error) {
  console.error("An error occurred:", error);
}

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License