A modern AI image generation web application that supports multiple AI platforms, providing real-time image generation, download, and management features.
Deploy with EdgeOne Pages.
- 🎯 Multi-Platform Support - Integrated with mainstream AI platforms like Hugging Face, Nebius, Replicate
- 🚀 Real-time Generation - Support for real-time image generation with progress indicators
- 💾 One-Click Download - Support for image download with automatic filename generation
- 🎨 Multiple Models - Support for various AI models including SDXL, Flux, Pixel Art, and more
- 📱 Responsive Design - Perfect adaptation for desktop and mobile devices
- Next.js 15.3.4 - React full-stack framework
- React 19.0.0 - User interface library
- TypeScript 5.0 - Type-safe JavaScript
- Tailwind CSS 4.0 - Utility-first CSS framework
- TDesign React - Enterprise-class UI component library
- EdgeOne Functions - Edge computing functions
- Multi-Platform API Integration - Hugging Face, Nebius, Replicate
- Node.js 18.0 or higher
- npm or yarn package manager
- Valid AI platform API tokens
-
Clone the Repository
git clone <repository-url> cd generate-graph
-
Install Dependencies
npm install # or yarn install -
Configure Environment Variables Create a
.envfile and add the following configuration (not all required):# Hugging Face API Token HF_TOKEN=your_huggingface_token_here # Nebius API Token NEBIUS_TOKEN=your_nebius_token_here # Replicate API Token REPLICATE_TOKEN=your_replicate_token_here # OPENAI API Key OPENAI_API_KEY=your_openai_api_key_here # FAL API Key FAL_KEY=your_fal_key_here
The EdgeOne Pages deployment console environment variable configuration is consistent with the above
.envfile. -
Start Development Server
npm run dev # or yarn dev -
Access the Application Open your browser and visit http://localhost:3000
- Visit Hugging Face
- Register and login to your account
- Go to Settings > Access Tokens
- Create a new access token
- Copy the token to the
HF_TOKENenvironment variable
- Visit Nebius Studio
- Register and login to your account
- Go to API settings page
- Generate an API key
- Copy the key to the
NEBIUS_TOKENenvironment variable
- Visit Replicate
- Register and login to your account
- Go to Account Settings
- Create an API token
- Copy the token to the
REPLICATE_TOKENenvironment variable
- Visit OpenAI
- Register and login to your account
- Go to API Keys
- Create a new API key
- Copy the key to the
OPENAI_API_KEYenvironment variable
- Visit FAL
- Register and login to your account
- Go to API Keys
- Create an API key
- Copy the key to the
FAL_KEYenvironment variable
The application automatically checks the availability of tokens for each platform and displays the status in the interface:
- ✅ Available - Token is configured and valid
- ❌ Missing - Token is not configured or invalid
-
Select Model
- Choose from available AI models in the left panel
- Different models support different image styles and generation effects
-
Enter Prompt
- Input image description in the text box
- Supports both Chinese and English descriptions
- The system automatically adds model style suffixes
-
Generate Image
- Click the "Generate" button to start generation
- Real-time display of generation progress and time
- Automatically displays results when generation is complete
-
Download Image
- Hover over the image to show download button
- Click download button to save the image
- Automatically generates filename containing the prompt
Endpoint: POST /v1/generate
Request Body:
{
"image": "Image description text",
"platform": "huggingface",
"model": "Model identifier"
}Response:
{
"success": true,
"prompt": "Original prompt",
"imageData": "Base64 encoded image data or URL",
"message": "Generation success message"
}Endpoint: GET /v1/token-status
Response:
{
"hfToken": true,
"nebiusToken": true,
"replicateToken": false
}All API endpoints include unified error handling:
400- Request parameter errors or content violations429- Request rate limit exceeded500- Internal server error
generate-graph/
├── functions/ # EdgeOne Functions
│ ├── v1/
│ │ ├── generate/ # Image generation API
│ │ │ ├── index.js # Main processing logic
│ │ │ ├── fetch_utils.js # API call utilities
│ │ │ └── nfsw_limit.js # Content filtering
│ │ └── token-status/ # Token status API
│ └── helloworld/ # Example function
├── src/
│ ├── components/ # React components
│ │ ├── ImageDisplay.tsx # Image display component
│ │ └── ModelDropdown.tsx # Model selection component
│ ├── pages/ # Next.js pages
│ │ ├── _app.tsx # Application entry
│ │ ├── _document.tsx # Document configuration
│ │ └── index.tsx # Main page
│ └── styles/ # Style files
│ └── globals.css # Global styles
├── public/ # Static assets
├── package.json # Project configuration
├── next.config.ts # Next.js configuration
├── tailwind.config.js # Tailwind configuration
└── README.md # Project documentation