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 🙏

© 2026 – Pkg Stats / Ryan Hefner

dalle3

v0.0.1

Published

A powerful Node.js package for generating high-quality images using Microsoft's DALL-E 3 through Bing Image Creator. Create stunning AI-generated artwork with a simple, professional API.

Readme

DALL-E 3 Image Generator 🎨

A powerful Node.js package for generating high-quality images using Microsoft's DALL-E 3 through Bing Image Creator. Create stunning AI-generated artwork with a simple, professional API.

✨ Features

  • 🎨 High-Quality Generation: Leverage DALL-E 3's advanced AI capabilities
  • 🔗 Flexible Output: Get image URLs or download files as base64
  • 📝 Professional Logging: Colored console output with detailed error messages
  • 🎯 Simple API: Intuitive methods for quick integration
  • 🔧 Configurable: Customizable temp directories and verbose logging
  • Fast & Reliable: Built-in retry logic and robust error handling
  • 🛡️ Type Safety: Comprehensive error types for better debugging

🚀 Installation

npm install dalle3

⚡ Quick Start

import DalleClient from 'dalle3';

// Initialize with your cookie string
const dalle = new DalleClient('YOUR_FULL_COOKIE_STRING_HERE', { verbose: true });

// Generate image links
const links = await dalle.generate('A majestic dragon soaring over a medieval castle at sunset', 'links');
console.log('🖼️ Generated images:', links);

// Generate and download files
const files = await dalle.generate('A futuristic robot playing chess', 'files');
console.log(`💾 Downloaded ${files.length} image files`);

🍪 Getting Your Bing Cookies (Required)

You need a Microsoft account for this to work. Follow these steps carefully:

Step 1: Navigate to Bing Create

  1. Go to https://www.bing.com/create
  2. Sign in with your Microsoft account if not already signed in
  3. Make sure you can access the image creation interface

Step 2: Extract Required Cookies

  1. Open Developer Tools (Press F12 or Ctrl+Shift+I)
  2. Go to the Console tab
  3. Type exactly: allow pasting and press Enter
  4. Copy and paste this code into the console:
// Extract only the necessary cookies - copy this entire block
const requiredCookies = ['MUID', 'ANON', '_U', 'MSPTC', 'ak_bmsc', '_RwBf', '_SS', 'SRCHUSR', 'SRCHUID', 'SRCHHPGUSR'];
const cookieObj = {};
document.cookie.split(';').forEach(cookie => {
  const [name, value] = cookie.trim().split('=');
  if (requiredCookies.includes(name)) {
    cookieObj[name] = value;
  }
});
Object.keys(cookieObj).map(key => `${key}=${cookieObj[key]}`).join('; ');
  1. Press Enter - this will output your filtered cookie string
  2. Copy the output - it should look something like this:
MUID=7ACD4F29D1287E634A1BC987D56F8B2C; ANON=B; _U=9Ks82Ylo3Vw7DbQT2nXpGJmHeLZ8p5kUYraTq-m2083r4FtXcZw1hOVn6LsFeD715jtz; MSPTC=test456; ak_bmsc=2C7731F59DA284B65C3AEF9D7C4F92E1~111111111111; _RwBf=s; _SS=SID=demo123; SRCHUSR=DOB=20231225; SRCHUID=V=2&GUID=xyz789; SRCHHPGUSR=SRCHLANG=fr

🔍 What Each Cookie Does:

  • MUID, ANON, _U, MSPTC: Authentication and session management
  • ak_bmsc, _RwBf: Anti-bot and security validation
  • _SS, SRCHUSR, SRCHUID, SRCHHPGUSR: Search personalization and session continuity

Step 3: Use Your Cookie String

// Use only the filtered cookie string from step 2
const cookieString = "MUID=...; ANON=...; _U=...; MSPTC=..."; // Your filtered cookies here
const dalle = new DalleClient(cookieString);

⚠️ Important Cookie Notes:

  • Use ONLY the filtered cookies - using all cookies may trigger Microsoft's bot detection
  • Keep your cookies secure - treat them like passwords
  • Cookies expire - you may need to refresh them periodically
  • One account per session - don't share cookies between users

API Reference

Constructor

const dalle = new DalleClient(cookieString, options);

Parameters:

  • cookieString (string): Your complete Bing cookie string (see setup guide above)
  • options (object, optional):
    • verbose (boolean): Enable detailed console logging (default: false)
    • tempDir (string): Directory for temporary file downloads (default: './temp')

Methods

generate(prompt, format, verbose)

Generate images from a text prompt.

Parameters:

  • prompt (string): Text description of the image to generate
  • format (string): Output format - 'links' or 'files' (default: 'links')
  • verbose (boolean, optional): Override verbose logging for this call

Returns:

  • For 'links': Array of image URLs
  • For 'files': Array of objects with filename and data (base64) properties

generateLinks(prompt)

Convenience method to generate image links only.

generateFiles(prompt)

Convenience method to generate image files as base64.

setVerbose(verbose)

Enable or disable verbose logging.

setTempDir(tempDir)

Set the temporary directory for file downloads.

📚 Examples

🎯 Basic Usage

import DalleClient from 'dalle3';

// Initialize with your filtered cookie string (10 cookies only)
const cookieString = "MUID=...; ANON=...; _U=...; MSPTC=..."; // Your filtered cookies here
const dalle = new DalleClient(cookieString, { verbose: true });

try {
  // Generate stunning image links
  const spaceImages = await dalle.generate(
    'A breathtaking view of Earth from a space station with aurora borealis', 
    'links'
  );
  console.log('🌌 Space images:', spaceImages);

  // Download images as base64 files
  const robotImages = await dalle.generate(
    'A friendly robot gardener tending to colorful flowers in a sunny garden',
    'files'
  );
  
  robotImages.forEach((file, index) => {
    console.log(`🤖 Image ${index + 1}: ${file.filename} (${Math.round(file.data.length/1024)}KB)`);
  });

} catch (error) {
  console.error('❌ Generation failed:', error.message);
}

🛡️ Advanced Error Handling

import DalleClient from 'dalle3';

async function generateWithRetry(prompt, maxRetries = 3) {
  const dalle = new DalleClient(process.env.BING_COOKIES);
  
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
    try {
      console.log(`🎯 Attempt ${attempt}: Generating images...`);
      const images = await dalle.generateLinks(prompt);
      console.log(`✅ Success! Generated ${images.length} images`);
      return images;
      
    } catch (error) {
      console.log(`❌ Attempt ${attempt} failed: ${error.message}`);
      
      switch (error.code) {
        case 'VALIDATION_ERROR':
          console.log('🔍 Check your prompt and parameters');
          return null; // Don't retry validation errors
          
        case 'CONTENT_BLOCKED_ERROR':
          console.log('🚫 Content blocked - try a different prompt');
          if (attempt === maxRetries) return null;
          break;
          
        case 'NETWORK_ERROR':
          console.log('🌐 Network issue - retrying...');
          if (attempt < maxRetries) {
            await new Promise(resolve => setTimeout(resolve, 2000 * attempt));
          }
          break;
          
        case 'GENERATION_ERROR':
          console.log('⚡ Generation failed - retrying with different approach...');
          break;
          
        default:
          console.log('❓ Unknown error - retrying...');
      }
    }
  }
  
  console.log('💥 All attempts failed');
  return null;
}

// Usage
const images = await generateWithRetry('A magical forest with glowing mushrooms');

⚙️ Configuration Examples

import DalleClient from 'dalle3';

// Quiet mode for production
const productionClient = new DalleClient(cookieString, { 
  verbose: false,
  tempDir: '/var/tmp/dalle-images'
});

// Development mode with detailed logging
const devClient = new DalleClient(cookieString, { 
  verbose: true,
  tempDir: './debug-images'
});

// Runtime configuration changes
devClient.setVerbose(false); // Turn off logging
devClient.setTempDir('./new-temp-dir'); // Change temp directory

// Convenience methods
const landscapes = await devClient.generateLinks('Mountain landscape at golden hour');
const portraits = await devClient.generateFiles('Professional headshot of a CEO');

🎨 Creative Prompt Examples

const dalle = new DalleClient(cookieString, { verbose: true });

// Artistic styles
const artworks = await dalle.generateLinks('Van Gogh style painting of a modern cityscape');

// Photorealistic scenes  
const photos = await dalle.generateLinks('Professional photograph of a cozy coffee shop interior, warm lighting, 4K');

// Fantasy and sci-fi
const fantasy = await dalle.generateLinks('Epic dragon battle in a stormy sky, fantasy art, detailed');

// Abstract and conceptual
const abstract = await dalle.generateLinks('Abstract representation of music and colors flowing together');

// Architecture and design
const architecture = await dalle.generateLinks('Modern minimalist house with large glass windows, surrounded by forest');

🔧 Error Types & Troubleshooting

| Error Type | Description | Solution | |------------|-------------|----------| | ValidationError | Invalid input parameters | Check prompt and format parameters | | GenerationError | Image generation failed | Try different prompt or retry | | NetworkError | Network/connection issues | Check internet connection, retry | | ContentBlockedError | Content violates Bing policies | Modify prompt to be more appropriate | | AuthenticationError | Invalid/expired cookies | Refresh your cookie string | | FileSystemError | File operation failures | Check temp directory permissions |

🚨 Common Issues

❌ "Authentication Error"

# Your cookies have expired or are invalid
# Solution: Get fresh cookies using the guide above

❌ "Content Blocked"

# Your prompt violates content policy  
# Solution: Try more general, appropriate language

❌ "Network Error"

# Connection issues or rate limiting
# Solution: Wait a moment and retry, check internet connection

⚡ Performance & Limits

  • Generation Time: Typically 30-120 seconds per batch
  • Images Per Request: Usually 4 images returned
  • Rate Limiting: Subject to Microsoft's limits (be reasonable)
  • Timeout: 5-minute maximum per generation
  • Image Quality: High-resolution DALL-E 3 output

🛡️ Best Practices

🔒 Security

// ✅ DO: Store cookies in environment variables
const dalle = new DalleClient(process.env.BING_COOKIES);

// ❌ DON'T: Hard-code cookies in source code
const dalle = new DalleClient("MUID=abc123..."); // Never do this!

// ✅ DO: Use only required cookies (reduces detection risk)
// Our extraction script automatically filters to safe cookies

// ❌ DON'T: Use all browser cookies (may trigger bot detection)

🎯 Effective Prompting

// ✅ Good prompts are specific and descriptive
"Professional portrait of a business woman in a modern office, natural lighting, sharp focus"

// ✅ Include style and quality keywords  
"Watercolor painting of a sunset over mountains, soft brushstrokes, artistic"

// ❌ Avoid vague or potentially problematic prompts
"Person doing something"

🚀 Performance

// ✅ Use appropriate logging levels
const dalle = new DalleClient(cookies, { verbose: process.env.NODE_ENV === 'development' });

// ✅ Handle errors gracefully
try {
  const images = await dalle.generateLinks(prompt);
} catch (error) {
  logger.error(`Image generation failed: ${error.message}`);
  return fallbackImages;
}

📋 Requirements

  • Node.js 16.0.0+ (ES Modules support required)
  • Microsoft Account (free, required for Bing access)
  • Internet Connection (for API calls)
  • Valid Cookie String (see setup guide above)

⚠️ Important Limitations

  • 🚫 Rate Limited: Don't spam requests - be respectful
  • 🚫 Content Policy: Subject to Microsoft's content guidelines
  • 🚫 Cookie Expiry: Cookies expire and need periodic refresh
  • 🚫 Geographic Restrictions: May not work in all countries
  • 🚫 Commercial Use: Check Microsoft's terms for commercial usage

📦 What's Included

dalle3/
├── src/
│   ├── DalleClient.js          # Main client class
│   ├── BingImageGenerator.js   # Core generation logic  
│   └── utils/
│       ├── Logger.js           # Colored console logging
│       └── Errors.js           # Custom error types
├── examples/
│   └── basic-usage.js          # Usage examples
├── index.js                    # Package entry point
├── package.json               # Package configuration
└── README.md                  # This file

License

MIT

Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

Changelog

0.0.1

  • Initial release
  • DALL-E 3 image generation via Bing
  • Professional error handling and colored logging
  • Filtered cookie extraction for security
  • Comprehensive documentation