novitalabs / javascript-sdk

JavaScript SDK for Novita AI API (Txt2Img, Img2Img, Txt2Video, Img2Video, Doodle, Remove Background, Replace Object, Reimagine, Merge Faces, ControlNet, VAE, LoRA)

Home Page:https://novita.ai

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Novita.ai Javascript SDK

This SDK is based on the official novita.ai API reference

Join our discord server for help:

Quick start

  1. Sign up on novita.ai and get an API key. Please follow the instructions at https://novita.ai/get-started

  2. Install the npm package in your project.

npm i novita-sdk

Usage

1. Functional usage

import { txt2ImgSync, setNovitaKey } from "novita-sdk";

setNovitaKey("your api key");

const params = {
  model_name: "sd_xl_base_1.0.safetensors",
  prompt: "1 girl",
};
txt2ImgSync(params)
  .then((res) => {
    console.log("imgs", res);
  })
  .catch((err) => {
    console.error(err);
  });

2. Class-based usage

import { NovitaSDK } from "novita-sdk";

const novitaClient = new NovitaSDK("your api key");

const params = {
  model_name: "sd_xl_base_1.0.safetensors",
  prompt: "1 girl",
};
novitaClient
  .txt2ImgSync(params)
  .then((res) => {
    console.log("imgs", res);
  })
  .catch((err) => {
    console.error(err);
  });

API list and Sample codes

Type Definitions

For detailed information on the parameters and return types of each method, please refer to the types.ts file.

Playground

You can try all demos at https://novita.ai/playground

About

JavaScript SDK for Novita AI API (Txt2Img, Img2Img, Txt2Video, Img2Video, Doodle, Remove Background, Replace Object, Reimagine, Merge Faces, ControlNet, VAE, LoRA)

https://novita.ai


Languages

Language:TypeScript 97.2%Language:JavaScript 2.6%Language:Shell 0.2%