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

ailyze

v1.0.5

Published

A Node.js package that provides AI-powered image generation and text optimization using Cloudflare Workers AI

Downloads

58

Maintainers

mehmetfaahemmehmetfaahem

Keywords

aicloudflareimage-generationtext-optimizationreactnextjsreact-nativevuesvelteangularnuxtjsgatsbyjsastrohonoexpresskoafastifynestjsadonisjssappersveltekitvuepressdocusaurusgridsomegatsbynextjsnuxtjsreactjs image generator packagereactjs image optimization packagereactjs image generatorreactjs image optimizationreactjs image generator cloudflarereactjs image optimization cloudflarereactjs image generator cloudflare workers aireactjs image optimization cloudflare workers aireactjs image generator cloudflare workers ai typescriptreactjs image optimization cloudflare workers ai typescriptreactjs image generator cloudflare workers ai typescript reactreactjs image optimization cloudflare workers ai typescript reactreactjs image generator cloudflare workers ai typescript react nextjsreactjs image optimization cloudflare workers ai typescript react nextjsreactjs image generator cloudflare workers ai typescript react nextjs react-nativereactjs image optimization cloudflare workers ai typescript react nextjs react-nativereactjs image generator cloudflare workers ai typescript react nextjs react-native vuenextjs image generatornextjs image optimizationnextjs image generator cloudflarenextjs image optimization cloudflarenextjs image generator cloudflare workers ainextjs image optimization cloudflare workers ainextjs image generator cloudflare workers ai typescriptreactjs text generatorreactjs text optimizationreactjs text generator cloudflarereactjs text optimization cloudflarereactjs text generator cloudflare workers aireactjs text optimization cloudflare workers aireactjs text generator cloudflare workers ai typescriptreactjs text optimization cloudflare workers ai typescriptreactjs text generator cloudflare workers ai typescript reactreact js text and image generatorreact js text and image optimizationreact js text and image generator cloudflarereact js text and image optimization cloudflarereact js text and image generator cloudflare workers ainext js text and image generatornext js text and image optimizationnext js text and image generator cloudflarenext js text and image optimization cloudflarenext js text and image generator cloudflare workers aireact js text and image generator cloudflare workers aireact js text and image optimization cloudflare workers aireact js text and image generator cloudflare workers ai typescriptreact js text and image optimization cloudflare workers ai typescript

Readme

Ailyze

A Node.js package that provides AI-powered image generation and text optimization using Cloudflare Workers AI. Generated image will be stored to Cloudinary if you provide credentials of Cloudinary. This package provides a simple and efficient way to generate images and optimize texts using AI.

Features

  • Image Generation: Generate images from text prompts
  • Text Optimization: Enhance and optimize texts
  • Cloudinary Integration: Optional integration with Cloudinary for image storage

Installation

npm install ailyze
# or
yarn add ailyze

Usage

Instructions

  1. Create a Cloudflare account and obtain your API key and account ID
  2. Set up Cloudinary for image storage (optional)

Implementation

import { initialize, generatePhoto, optimizeText } from "ailyze";
import { NextResponse } from "next/server";

// Initialize ailyze with credentials
initialize({
  cloudflareApiKey: process.env.CLOUDFLARE_API_KEY!,
  cloudflareAccountId: process.env.CLOUDFLARE_ACCOUNT_ID!,
  cloudinaryConfig: {
    cloudName: process.env.CLOUDINARY_CLOUD_NAME!, // Optional
    apiKey: process.env.CLOUDINARY_API_KEY!, // Optional
    apiSecret: process.env.CLOUDINARY_API_SECRET!, // Optional
  },
});

export async function POST(request: Request) {
  try {
    const { type, prompt } = await request.json();

    if (type === "image") {
      const result = await generatePhoto(prompt);
      return NextResponse.json(result);
    }

    if (type === "text") {
      const result = await optimizeText(prompt);
      return NextResponse.json(result);
    }

    return NextResponse.json(
      { error: "Invalid type specified" },
      { status: 400 }
    );
  } catch (error) {
    return NextResponse.json({ error: "Processing failed" }, { status: 500 });
  }
}
import express from "express";
import dotenv from "dotenv";
import { initialize, generatePhoto, optimizeText } from "ailyze";

dotenv.config();

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

// Initialize ailyze with credentials
initialize({
  cloudflareApiKey: process.env.CLOUDFLARE_API_KEY,
  cloudflareAccountId: process.env.CLOUDFLARE_ACCOUNT_ID,
  cloudinaryConfig: {
    cloudName: process.env.CLOUDINARY_CLOUD_NAME, // Optional
    apiKey: process.env.CLOUDINARY_API_KEY, // Optional
    apiSecret: process.env.CLOUDINARY_API_SECRET, // Optional
  },
});

app.post("/generate", async (req, res) => {
  try {
    const { type, prompt } = req.body;

    if (type === "image") {
      const result = await generatePhoto(prompt);
      return res.json(result);
    }

    if (type === "text") {
      const result = await optimizeText(prompt);
      return res.json(result);
    }

    return res.status(400).json({ error: "Invalid type specified" });
  } catch (error) {
    return res.status(500).json({ error: "Processing failed" });
  }
});

const PORT = process.env.PORT || 5000;
app.listen(PORT, () => console.log(`Server running on port ${PORT}`));

Initialize the Package

First, initialize the package with your Cloudflare API credentials:

import { initialize, generatePhoto, optimizeText } from "ailyze";

// Initialize with Cloudflare credentials
initialize({
  cloudflareApiKey: process.env.CLOUDFLARE_API_KEY,
  cloudflareAccountId: process.env.CLOUDFLARE_ACCOUNT_ID,
  // Optional: Cloudinary configuration for image storage
  cloudinaryConfig: {
    cloudName: process.env.CLOUDINARY_CLOUD_NAME, // Optional
    apiKey: process.env.CLOUDINARY_API_KEY, // Optional
    apiSecret: process.env.CLOUDINARY_API_SECRET, // Optional
  },
});

Env Variables

CLOUDFLARE_API_KEY=your_api_key
CLOUDFLARE_ACCOUNT_ID=your_account_id
CLOUDINARY_CLOUD_NAME=your_cloud_name (Optional)
CLOUDINARY_API_KEY=your_api_key (Optional)
CLOUDINARY_API_SECRET=your_api_secret (Optional)

Generate an Image

const generateImage = async () => {
  const result = await generatePhoto("A beautiful sunset over mountains");

  if (result.success) {
    // Use the image URL
    console.log("Generated image URL:", result.image_url);
  } else {
    console.error("Error generating image:", result.error);
  }
};

Optimize Text

const enhanceText = async () => {
  const result = await optimizeText(
    "This is a simple text that needs improvement"
  );

  if (result.success) {
    // Use the enhanced text
    console.log("Enhanced text:", result.enhanced);
  } else {
    console.error("Error optimizing text:", result.error);
  }
};

API Reference

initialize(config)

Initializes the package with your API credentials.

Parameters:

  • config (Object): Configuration object with the following properties:
    • cloudflareApiKey (string): Your Cloudflare API key
    • cloudflareAccountId (string): Your Cloudflare account ID
    • cloudinaryConfig (Object, optional): Cloudinary configuration
      • cloudName (string): Your Cloudinary cloud name
      • apiKey (string): Your Cloudinary API key
      • apiSecret (string): Your Cloudinary API secret

generatePhoto(prompt)

Generates an image based on the provided text prompt.

Parameters:

  • prompt (string): Text description of the image to generate

Returns:

  • Promise that resolves to an object with:
    • image_url (string): URL of the generated image
    • success (boolean): Whether the operation was successful
    • error (string, optional): Error message if unsuccessful

optimizeText(prompt)

Optimizes and enhances the provided text using AI.

Parameters:

  • prompt (string): Text to optimize

Returns:

  • Promise that resolves to an object with:
    • enhanced (string): The enhanced text
    • success (boolean): Whether the operation was successful
    • error (string, optional): Error message if unsuccessful

Notes

  • This package requires a Cloudflare account with Workers AI access
  • For production use, it's recommended to use Cloudinary for image storage
  • If Cloudinary configuration is not provided, images will be returned as base64 data URLs