Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
pollinations
Advanced tools
A Node.js package that allows you to easily generate images using Pollinations's free API.
A Node.js package that allows you to easily generate images using Pollinations's free API.
Install pollinations to your project with npm:
npm install pollinations
Integrating pollinations to a Discord bot using discord.js.
npm install discord.js
const { Client, GatewayIntentBits, AttachmentBuilder } = require("discord.js");
const Pollinations = require("pollinations")
const pollinations = new Pollinations()
const Bot = new Client({
intents: [
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.DirectMessages
]
});
Bot.on("messageCreate", async (message) =>{
if(message.bot) return;
if(!message.content) return;
if(message.content.toLowerCase().startsWith("!generate")){
const prompt = message.content.substring("!generate".length).trim();
if(prompt.length === 0) return message.reply(":x: Please provide a prompt.");
message.react("✅")
pollinations.generate({
prompt: prompt
})
.then(result =>{
const imagesBuffers = []
result.images.forEach(image =>{
imagesBuffers.push(
new AttachmentBuilder(image, {
name: "pollinations-image.jpg
})
)
})
message.reply({
content: "Here is your image",
files: imagesBuffers
})
})
.catch(error =>{
return message.reply(":x: Something went wrong.");
})
}
})
Bot.login("VERY_SECRET_TOKEN")
const Pollinations = require("pollinations")
const pollinations = new Pollinations(defaultParameters)
Parameter | Type | Default | Description |
---|---|---|---|
images | number | 1 | Default number of images to generate when using the generate() function |
width | number | 512 | Default width for images in pixels |
height | number | 512 | Default height for images in pixels |
seed | number | -1 (-1 indicates random) | Default seed used to generate images |
nologo | number | false | Whether the images should have the Pollinations logo or not |
pollinations.generate(generateParameters).then(results)
The pollinations.generate()
returns images by sending HTTPS requests to the official Pollinations website; It takes an Object
parameter and return an Object
.
Parameter | Type | Default | Description |
---|---|---|---|
prompt | string | N/A | (REQUIRED) Description of the image(s) to generate |
images | number | defaultParameters or 1 | Number of images to generate |
width | number | defaultParameters or 512 | Width for images in pixels |
height | number | defaultParameters or 512 | Height for images in pixels |
seed | number | defaultParameters or -1 | Seed to use to generate images |
nologo | number | defaultParameters or false | Whether the images should include the Pollinations logo or not |
Name | Type | Description |
---|---|---|
Object.requestId | string | Unique 36-character alphanumeric string you can use to identify the generate request |
Object.prompt | string | The prompt used for the generation |
Object.width | number | The width used for the generation |
Object.height | number | The height used for the generation |
Object.seed | number | The seed used for the generation |
Object.nologo | boolean | Whether the images include the Pollinations logo or not |
Object.expectedImages | number | Requested number of images to generate |
Object.errors | number | How many errors happened during the process |
Object.images | array | Array of buffers |
Object.isComplete | boolean | true if the number of images in the images array is the same as expectedImages |
If you're having issues with Pollinations or want to share your projects, ideas or feedbacks, you can join my support server!
FAQs
A Node.js package that allows you to easily generate images using Pollinations's free API.
We found that pollinations demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.