New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

devquarks-image-sdk

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

devquarks-image-sdk

SDK for generating high-quality images via Devquarks API at 10x cheaper cost

latest
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

Devquarks Image SDK

Generate high-quality AI images in your apps/websites at 10x cheaper cost using Devquarks API. This SDK provides a simple interface to integrate AI image generation into your Node.js applications.

Features

  • 🚀 Ultra-fast image generation
  • 💰 10x cheaper than competitors
  • 🎨 High-quality AI-generated images
  • 📦 Simple and lightweight SDK
  • 🔒 Secure API authentication
  • 📱 Works with any Node.js application

Installation

npm install devquarks-image-sdk

Quick Start

import { generateImage } from 'devquarks-image-sdk';
import fs from 'fs';

async function createImage() {
  try {
    const imageBuffer = await generateImage({
      token: 'your-api-token',
      prompt: 'A beautiful sunset over mountains'
    });
    
    // Save the image to file
    fs.writeFileSync('generated-image.png', imageBuffer);
    console.log('Image generated successfully!');
  } catch (error) {
    console.error('Error generating image:', error.message);
  }
}

createImage();

API Reference

generateImage(options)

Generates an AI image based on the provided prompt.

Parameters

  • options (Object): Configuration object
    • token (string): Your Devquarks API token
    • prompt (string): Text description of the image you want to generate

Returns

  • Promise<Buffer>: A Promise that resolves to a Buffer containing the generated image data

Example

const imageBuffer = await generateImage({
  token: 'your-api-token',
  prompt: 'A futuristic city with flying cars'
});

Usage Examples

Basic Usage

import { generateImage } from 'devquarks-image-sdk';

const imageBuffer = await generateImage({
  token: 'your-api-token',
  prompt: 'A serene lake with mountains in the background'
});

Saving to File

import { generateImage } from 'devquarks-image-sdk';
import fs from 'fs';

async function saveImage() {
  const imageBuffer = await generateImage({
    token: 'your-api-token',
    prompt: 'A magical forest with glowing mushrooms'
  });
  
  fs.writeFileSync('magical-forest.png', imageBuffer);
}

Using with Express.js

import express from 'express';
import { generateImage } from 'devquarks-image-sdk';

const app = express();
app.use(express.json());

app.post('/generate-image', async (req, res) => {
  try {
    const { prompt } = req.body;
    const imageBuffer = await generateImage({
      token: process.env.DEVQUARKS_API_TOKEN,
      prompt
    });
    
    res.set('Content-Type', 'image/png');
    res.send(imageBuffer);
  } catch (error) {
    res.status(500).json({ error: error.message });
  }
});

Converting to Base64

import { generateImage } from 'devquarks-image-sdk';

async function getBase64Image() {
  const imageBuffer = await generateImage({
    token: 'your-api-token',
    prompt: 'A cyberpunk cityscape at night'
  });
  
  const base64Image = imageBuffer.toString('base64');
  console.log(`data:image/png;base64,${base64Image}`);
}

Getting Your API Token

  • Visit Devquarks Dashboard
  • Sign up for an account or log in
  • Navigate to API Keys section
  • Generate a new API token
  • Copy and use the token in your application

Error Handling

The SDK throws errors for various scenarios. Always wrap your calls in try-catch blocks:

try {
  const imageBuffer = await generateImage({
    token: 'your-api-token',
    prompt: 'A beautiful landscape'
  });
} catch (error) {
  console.error('Failed to generate image:', error.message);
  // Handle the error appropriately
}

Common Error Scenarios

  • Invalid API Token: Check your token is correct and active
  • Network Issues: Ensure stable internet connection
  • Invalid Prompt: Make sure your prompt is descriptive and appropriate
  • Rate Limiting: Implement proper rate limiting in your application

Best Practices

  • Environment Variables: Store your API token in environment variables

    const token = process.env.DEVQUARKS_API_TOKEN;
    
  • Error Handling: Always implement proper error handling

    try {
      const imageBuffer = await generateImage({ token, prompt });
    } catch (error) {
      // Handle error appropriately
    }
    
  • Prompt Quality: Use descriptive and specific prompts for better results

    // Good prompt
    const prompt = "A detailed oil painting of a red rose on a wooden table with soft lighting";
    
    // Better than generic prompt
    const prompt = "flower";
    

TypeScript Support

This SDK is written in TypeScript and includes type definitions:

import { generateImage, ImageGenOptions } from 'devquarks-image-sdk';

const options: ImageGenOptions = {
  token: 'your-api-token',
  prompt: 'A majestic eagle soaring through clouds'
};

const imageBuffer: Buffer = await generateImage(options);

Requirements

  • Node.js 14.0 or higher
  • Active Devquarks API token

License

MIT License - see LICENSE file for details

Support

Made with ❤️ by Devquarks

Keywords

image

FAQs

Package last updated on 06 Jul 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