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

pollinations-image-gen

v1.0.0

Published

Gera imagens com IA de graça, sem API key, usando a API pública da Pollinations.ai

Readme

pollinations-image-gen

Gere imagens com IA de graça e sem precisar de API key, usando a API pública da Pollinations.ai.

Instalação

Copie a pasta do módulo para o seu projeto e instale (não há dependências externas, só o Node.js):

npm install

Requer Node.js 18+ (usa fetch nativo).

Uso rápido

const { generateImage, generateImageToFile } = require('./index.js');

// Gerar e salvar direto em arquivo
await generateImageToFile('um gato astronauta no espaço', './saida.png');

// Ou gerar e receber o Buffer (útil pra enviar em bots do Discord/Telegram/WhatsApp)
const buffer = await generateImage('um dragão de cristal em uma floresta mágica');

API

generateImage(prompt, options?) → Promise<Buffer>

Gera uma imagem e retorna o Buffer (não salva em disco).

generateImageToFile(prompt, outputPath, options?) → Promise<string>

Gera uma imagem e salva em disco. Retorna o caminho absoluto do arquivo salvo.

Opções (options)

| Opção | Tipo | Padrão | Descrição | |-----------|-----------|----------|--------------------------------------------------------------------| | width | number | 1024 | Largura da imagem em pixels | | height | number | 1024 | Altura da imagem em pixels | | model | string | 'flux' | Modelo de geração (veja MODELS abaixo) | | seed | number | — | Seed fixa, útil para reproduzir a mesma imagem depois | | nologo | boolean | true | Remove a marca d'água da Pollinations | | enhance | boolean | false | Deixa a IA melhorar automaticamente o seu prompt antes de gerar | | timeout | number | 60000 | Tempo máximo de espera em milissegundos |

Modelos disponíveis (MODELS)

['flux', 'flux-realism', 'flux-anime', 'flux-3d', 'turbo']

A lista de modelos pode mudar com o tempo, já que depende do serviço da Pollinations.

Exemplo completo

Veja example.js:

node example.js

Usando em um bot (Discord/Telegram/WhatsApp)

Como generateImage() retorna um Buffer, você pode enviar direto sem salvar em disco:

const { generateImage } = require('./index.js');

// Exemplo genérico
const buffer = await generateImage('um sapo mago lançando um feitiço');
// discordChannel.send({ files: [{ attachment: buffer, name: 'imagem.png' }] });

Tratamento de erros

O módulo lança Error em caso de:

  • Prompt vazio ou inválido
  • Falha HTTP (status diferente de 2xx)
  • Timeout excedido
try {
  const buffer = await generateImage('...');
} catch (err) {
  console.error('Falha ao gerar imagem:', err.message);
}

Aviso

Este módulo depende de um serviço público de terceiros (Pollinations.ai) que pode ter instabilidades, limites de uso informais ou mudanças na API sem aviso prévio. Não há garantia de SLA — é uma opção gratuita, ideal para projetos pessoais, bots e protótipos.

Licença

MIT