0.1.4 • Published 11 months ago

prodia-api v0.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

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 contact@danlegt.com

0.1.4

11 months ago

0.1.3

11 months ago

0.1.2

12 months ago

0.1.0

12 months ago

0.0.2

12 months ago

0.0.1

12 months ago

1.0.0

1 year ago

0.0.0

1 year ago