Socket
Book a DemoInstallSign in
Socket

@chaingpt/nft

Package Overview
Dependencies
Maintainers
5
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chaingpt/nft

SDK for Nft

0.1.1
latest
npmnpm
Version published
Maintainers
5
Created
Source

ChainGPT AI NFT SDK

This library provides convenient access to the ChainGPT AI NFT REST API from TypeScript or JavaScript.

Installation

npm install --save @chaingpt/nft
# or
yarn add @chaingpt/nft

Usage

Generate a text to image using Velogen

const { Nft } = require('@chaingpt/nft');
const fs = require('fs');

const nftInstance = new Nft({
  apiKey: 'Your ChainGPT API Key',
});

async function main() {
  const generatedImage = await nftInstance.generateImage({
    prompt: 'cars racing to the finish', // Prompt to be used to generate the NFT art
    model: 'velogen', // Model to be used to generate the NFT art
    enhance: 'original', // enhance image once pass '1x' or twice pass '2x'
    steps: 2, // steps parameter passed while image generation
    height: 512, //height of the resulting image
    width: 512, // width of the resulting image
    style: 'cinematic', //sample value for style
  });

  // Save the buffer directly to a file
  fs.writeFileSync('generated-image.jpg', Buffer.from(generatedImage.data.data));
}

main();

Generate an image to image using Velogen

const { Nft } = require('@chaingpt/nft');
const fs = require('fs');

const nftInstance = new Nft({
  apiKey: 'Your ChainGPT API Key',
});

async function main() {
  const generatedImage = await nftInstance.generateImage({
    prompt: "medieval fantasy knight, wearing armor", // Prompt to be used to generate the NFT art
    image: "https://chaingpt.s3.dualstack.us-east-2.amazonaws.com/sdk/cgpt-bot.jpg",
    model: 'velogen', // Model to be used to generate the NFT art
    enhance: 'original', // enhance image once pass '1x' or twice pass '2x'
    steps: 3,
    height: 1024, //height of the resulting image
    width: 1024, // width of the resulting image

  });

  // Save the buffer directly to a file
  fs.writeFileSync('generated-image.jpg', Buffer.from(generatedImage.data.data));
}

main();

Generate a text to image using nebula forge

const { Nft } = require('@chaingpt/nft');
const fs = require('fs');

const nftInstance = new Nft({
  apiKey: 'Your ChainGPT API Key',
});

async function main() {
  const generatedImage = await nftInstance.generateImage({
    prompt: 'cars racing to the finish', // Prompt to be used to generate the NFT art
    model: 'nebula_forge_xl', // Model to be used to generate the NFT art
    enhance: 'original', // enhance image once pass '1x' or twice pass '2x'
    steps: 25, // steps parameter passed while image generation
    height: 1024, //height of the resulting image
    width: 1024, // width of the resulting image
  });

  // Save the buffer directly to a file
  fs.writeFileSync('generated-image.jpg', Buffer.from(generatedImage.data.data));
}

main();

Generate an image to image using nebula forge

const { Nft } = require('@chaingpt/nft');
const fs = require('fs');

const nftInstance = new Nft({
  apiKey: 'Your ChainGPT API Key',
});

async function main() {
  const generatedImage = await nftInstance.generateImage({
    prompt: "medieval fantasy knight, wearing armor", // Prompt to be used to generate the NFT art
    image: "https://chaingpt.s3.dualstack.us-east-2.amazonaws.com/sdk/cgpt-bot.jpg",
    model: 'nebula_forge_xl', // Model to be used to generate the NFT art
    enhance: 'original', // enhance image once pass '1x' or twice pass '2x'
    steps: 20,
    height: 1024, //height of the resulting image
    width: 1024, // width of the resulting image,
  });

  // Save the buffer directly to a file
  fs.writeFileSync('generated-image.jpg', Buffer.from(generatedImage.data.data));
}

main();

Generate a text to image using visionary forge

const { Nft } = require('@chaingpt/nft');
const fs = require('fs');

const nftInstance = new Nft({
  apiKey: 'Your ChainGPT API Key',
});

async function main() {
  const generatedImage = await nftInstance.generateImage({
    prompt: 'cars racing to the finish, realistic and higly detailed image', // Prompt to be used to generate the NFT art
    model: 'VisionaryForge', // Model to be used to generate the NFT art
    enhance: 'original', // enhance image once pass '1x' or twice pass '2x'
    height: 1024, //height of the resulting image
    width: 1024, // width of the resulting image
  });

  // Save the buffer directly to a file
  fs.writeFileSync('generated-image.jpg', Buffer.from(generatedImage.data.data));
}

main();

Generate an image to image using visionary forge

const { Nft } = require('@chaingpt/nft');
const fs = require('fs');

const nftInstance = new Nft({
  apiKey: 'Your ChainGPT API Key',
});

async function main() {
  const generatedImage = await nftInstance.generateImage({
    prompt: "medieval fantasy knight, wearing armor", // Prompt to be used to generate the NFT art
    image: "https://chaingpt.s3.dualstack.us-east-2.amazonaws.com/sdk/cgpt-bot.jpg",
    model: 'VisionaryForge', // Model to be used to generate the NFT art
    enhance: 'original', // enhance image once pass '1x' or twice pass '2x'
    height: 1024, //height of the resulting image
    width: 1024, // width of the resulting image
  });

  // Save the buffer directly to a file
  fs.writeFileSync('generated-image.jpg', Buffer.from(generatedImage.data.data));
}

main();

Character Reference NFT Image Generation

const { Nft } = require('@chaingpt/nft');
const fs = require('fs');

const nftInstance = new Nft({
  apiKey: 'Your ChainGPT API Key',
});

async function main() {
  const generatedImage = await nftInstance.generateImage({
    prompt: "musician playing guitar under stage lights", // Prompt to be used to generate the NFT art
    image: "https://chaingpt.s3.dualstack.us-east-2.amazonaws.com/sdk/cgpt-bot.jpg",
    model: 'velogen', // Allowed models velogen, VisionaryForge, nebula_forge_xl
    enhance: 'original', // enhance image once pass '1x' or twice pass '2x'
    steps: 3,
    height: 1024, //height of the resulting image
    width: 1024, // width of the resulting image
    isCharacterPreserve: true // to preserve the character

  });

  // Save the buffer directly to a file
  fs.writeFileSync('generated-image.jpg', Buffer.from(generatedImage.data.data));
}

main();

Note: If isCharacterPreserve is set to true, you must also provide a valid image URL.

Generate an image using Dale3

const { Nft } = require('@chaingpt/nft');
const fs = require('fs');

const nftInstance = new Nft({
  apiKey: 'Your ChainGPT API Key',
});

async function main() {
  const generatedImage = await nftInstance.generateImage({
    prompt: 'cars racing to the finish', // Prompt to be used to generate the NFT art
    model: 'Dale3', // Model to be used to generate the NFT art
    upscale: true, // enhance image once pass '1x' or twice pass '2x'
    height: 1024, //height of the resulting image
    width: 1024, // width of the resulting image
    style: 'cinematic', //sample value for style
    traits: [
      //optional traits
      {
        trait_type: 'Background',
        value: [
          { value: 'Heaven', ratio: 20 },
          { value: 'Hell', ratio: 60 },
          { value: 'Pakistan', ratio: 20 },
        ],
      },
      {
        trait_type: 'contrast',
        value: [
          { value: 'dark', ratio: 20 },
          { value: 'light', ratio: 80 },
        ],
      },
    ],
  });

  // Save the buffer directly to a file
  fs.writeFileSync('generated-image.jpg', Buffer.from(generatedImage.data.data));
}

main();

get chains to generate NFT on a chain, to get testNet chains aswell pass true as parameter

const { Nft } = require('@chaingpt/nft');

const nftInstance = new Nft({
  apiKey: 'Your ChainGPT API Key',
});

async function main() {
  const chains = await nftInstance.getChains(false); // true for testnet
  console.log(chains);
}

main();

Generate an NFT

const { Nft } = require('@chaingpt/nft');

const nftInstance = new Nft({
  apiKey: 'Your ChainGPT API Key',
});

async function main() {
  const generatedNFT = await nftInstance.generateNft({
    walletAddress: '<your wallet address>', // Public Key of the wallet that will mint NFT
    prompt: 'a car being modified', // Prompt to be used to generate the NFT art
    model: 'velogen', // Model to be used to generate the NFT art
    enhance: 'original', // enhance image once pass '1x' or twice pass '2x'
    steps: 3, // steps parameter passed while image generation
    height: 1024, //height of the resulting image
    width: 1024, // width of the resulting image
    chainId: 97, //chain id
    amount: 1, // no of images to generate
    style: 'cinematic', //sample value for style
    traits: [
      {
        trait_type: 'contrast', // set trait name
        value: [
          // set ratio for values
          { value: 'dark', ratio: 20 },
          { value: 'light', ratio: 80 },
        ],
      },
    ],
  });
  console.log(generatedNFT);
}

main();

Generate an NFT from image

const { Nft } = require('@chaingpt/nft');
const fs = require('fs');

const nftInstance = new Nft({
  apiKey: 'Your ChainGPT API Key',
});

async function main() {
  const generatedImage = await nftInstance.generateNft({
    prompt: 'cars racing to the finish', // Prompt to be used to generate the NFT art
    model: 'velogen', // Model to be used to generate the NFT art
    enhance: 'original', // enhance image once pass '1x' or twice pass '2x'
    steps: 2, // steps parameter passed while image generation
    height: 512, //height of the resulting image
    width: 512, // width of the resulting image
    image: 'https://dywmmvb02wrr8.cloudfront.net/document/532d6f9608fa33feeb3455a6ba788483.jpg-1726748667979.jpeg', // URL of image Only JPEG/JPG Format Supported.
  });
}

main();

Generate an NFT and queue the generation instead of waiting for it to complete

const { Nft } = require('@chaingpt/nft');

const nftInstance = new Nft({
  apiKey: 'Your ChainGPT API Key',
});

async function main() {
  const generatedNFTQueue = await nftInstance.generateNftWithQueue({
    walletAddress: '<your wallet address>', // Public Key of the wallet that will mint NFT
    prompt: 'dragon', // Prompt to be used to generate the NFT art
    model: 'Dale3', // Model to be used to generate the NFT art
    upscale: true, // upscale image
    height: 1024, //height of the resulting image
    width: 1024, // width of the resulting image
    chainId: 56, //chain id
    amount: 2, //no of images to generate
    style: 'cinematic', //sample value for style
    traits: [
      {
        trait_type: 'contrast', // set trait name
        value: [
          // set ratio for values
          { value: 'dark', ratio: 20 },
          { value: 'light', ratio: 80 },
        ],
      },
    ],
  });
  console.log(generatedNFTQueue);
}

main();

Check the creation progress of your NFT Generation (useful with generateNftWithQueue())

const { Nft } = require('@chaingpt/nft');

const nftInstance = new Nft({
  apiKey: 'Your ChainGPT API Key',
});

async function main() {
  const getProgress = await nftInstance.getNftProgress({
    collectionId: '<collection id>', // your NFT generation collection ID
  });
  console.log(getProgress);
}

main();

Enhances your prompt by adding more details and context to improve image generation quality.

const { Nft } = require('@chaingpt/nft');

const nftInstance = new Nft({
  apiKey: 'Your ChainGPT API Key',
});

async function main() {
  const enhancedPrompt = await nftInstance.enhancePrompt({
    prompt: 'lion in jungle',
  });
  console.log(enhancedPrompt);
}

main();

Generate a random prompt for NFT creation

const { Nft } = require('@chaingpt/nft');

const nftInstance = new Nft({
  apiKey: 'Your ChainGPT API Key',
});

async function main() {
  const randomPrompt = await nftInstance.surpriseMe();
  // Returns a randomly generated prompt that can be used for NFT creation
  console.log(randomPrompt);
}

main();

Get collections generated by your api key with optional filters

const { Nft } = require('@chaingpt/nft');

const nftInstance = new Nft({
  apiKey: 'Your ChainGPT API Key',
});

async function main() {
  const collections = await nftInstance.getCollections({
    walletAddress: '<wallet address>', // Wallet address to filter collections
    isPublic: true, // Filter by public status
    // isDraft: false, // Filter by draft status (addtional filter)
    // isMinted: false, // Filter by minted status (addtional filter)
    // name: "<name>", // Filter by collection name (addtional filter)
    // symbol: "<symbol>", // Filter by collection symbol (addtional filter)
    page: 1, // Page number for pagination
    limit: 10, // Number of items per page
  });
}

main();

Toggle NFT visibility (make public/private)

const { Nft } = require('@chaingpt/nft');

const nftInstance = new Nft({
  apiKey: 'Your ChainGPT API Key',
});

async function main() {
  const response = await nftInstance.toggleNftVisibility({
    collectionId: '<collection id>', // ID of the collection to toggle visibility
  });
  console.log(response);
}

main();

Retrieving required data to mint the generated NFT

const { Nft } = require('@chaingpt/nft');

const nftInstance = new Nft({
  apiKey: 'Your ChainGPT API Key',
});

async function main() {
  const mint = await nftInstance.mintNft({
    collectionId: '<collection Id>', // Your NFT generation Collection ID
    ids: [1], // collection to mint from generated images starting from 1
    name: '<name>', // A name for your NFT
    description: '<description>', // A description for your NFT
    symbol: '<symbol>', // symbol
  });
  console.log(mint);
}

main();

Retrieving the NFT Mint Factory Contract ABI to call the Mint function

const { Nft } = require('@chaingpt/nft');

const nftInstance = new Nft({
  apiKey: 'Your ChainGPT API Key',
});

async function main() {
  const abi = await nftInstance.abi();
  console.log(abi);
}

main();

Supported Models

Here is a list of supported models:

  • velogen
  • nebula_forge_xl
  • VisionaryForge
  • Dale3

Enhance Image

You can enhance your image once or twice by using enhance property

  • for enhancement pass enhance ='1x'
  • for double enhancement pass enhance ='2x'

Models that support enhancement:

  • velogen
  • nebula_forge_xl
  • VisionaryForge

Steps

Steps property can be used to refine image verious times.

  • velogen supports steps 1 to 4 with default 2
  • nebula_forge_xl supports steps to 50 with default 25

Supported Resolutions (Height/Width)

Each model supports specific resolutions for optimal results.

Velogen

Without Enhancement

  • Square: 512×512
  • Landscape: 768×512
  • Portrait: 512×768

With Enhancement

  • Square: 1920×1920
  • Landscape: 1920×1280
  • Portrait: 1280×1920

Nebula Forge XL

Base Resolutions

  • Square: 1024×1024
  • Landscape: 1024×768
  • Portrait: 768×1024

Upscaled Resolutions

  • Square: 1536×1536
  • Landscape: 1536×1024
  • Portrait: 1024×1536

VisionaryForge

Base Resolutions

  • Square: 1024×1024
  • Landscape: 1024×768
  • Portrait: 768×1024

Upscaled Resolutions

  • Square: 1536×1536
  • Landscape: 1536×1024
  • Portrait: 1024×1536

Supported Styles

Here is a list of supported models:

  • 3d-model
  • analog-film
  • anime
  • cinematic
  • comic-book
  • digital-art
  • enhance
  • fantasy-art
  • isometric
  • line-art
  • low-poly
  • neon-punk
  • origami
  • photographic
  • pixel-art
  • texture
  • craft-clay

Handling errors

When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), an error of the class NftError will be thrown:

import { Errors } from '@chaingpt/nft';

async function main() {
  try {
    const response = await nftInstance.abi();
    console.log(response.data);
  } catch (error) {
    if (error instanceof Errors.NftError) {
      console.log(error.message);
    }
  }
}

main();

Keywords

nft

FAQs

Package last updated on 15 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.