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

prodia-api

v0.1.4

Published

[![npm version](https://badge.fury.io/js/prodia-api.svg?1)](https://badge.fury.io/js/prodia-api)

Downloads

12

Readme

Prodia AI Image Generation API

npm version

Tests

This is a Node.js library written in TypeScript for usage with the Prodia AI API

The library offers type safety as it was written in TypeScript, fully compatible with other TypeScript projects or plain JavaScript projects.

Installation

Install the library using npm:

npm i prodia-api

Make sure you're using node >= 18 so fetch is available.

Library Usage

First, you need to import the library and set your API key:

import { Prodia } from "prodia-api"
// js: const Prodia = require("prodia-api").Prodia;

// Your API Key from https://app.prodia.com/
const prodia = new Prodia(`XxXxX-XxXxX-XxXxX-XxXxX`);

Generating an image

import Prodia from "prodia-api"

// Your API Key from https://app.prodia.com/
const prodia = new Prodia(`XxXxX-XxXxX-XxXxX-XxXxX`);

// Construct your generation request
const generationRequest: CreateGenerationRequest = {
    aspect_ratio: ProdiaAspectRatio.PORTRAIT,
    cfg_scale: 7.5,
    model: ProdiaModel.ANYTHING_V45,
    negative_prompt: `easynegative`,
    prompt: `A portrait of a cute dog`, // The only actual required field, feel free to only send this.
    sampler: ProdiaSampler.DPM_PP_2M_KARRAS,
    seed: -1,
    steps: 32,
    upscale: false
}

const imageGenerationJob = await prodia.createImageGeneration(generationRequest);
console.log("Image Generation request sent...");

let safetyWait = 25;
while ((j.status == JobStatus.GENERATING || j.status == JobStatus.QUEUED) && --safetyWait > 0 ) {
    await new Promise((r) => setTimeout(r, 500));

    imageGenerationJob = await prodia.fetchImageGeneration(imageGenerationJob.job);
}

if (imageGenerationJob.status !== JobStatus.SUCCEEDED) {
    throw new Error("Job failed!");
}

console.log("Generation completed!", job.imageUrl);
import { Prodia } from "prodia-api"
// js: const Prodia = require("prodia-api").Prodia;

Error Handling

When an error occurs, the library will simply throw an error. All promises from the library do throw proper exceptions.

Community

If you have any questions in regard to the API you can always jump on the official Prodia Discord Server,

If you have any questions in regards to the library, what I recommend is simply asking on the above discord server but if you think that I would personally be a better fit or that you have found actual issues with the library either open up an issue in the repository or you can email me [email protected]