A full-stack web application demonstrating the Akool Image Generation API. This demo supports both text-to-image and image-to-image generation, with features for creating 4K upscales and variations.
- 🔐 Dual Authentication: Support for both API Key and Client Credentials (OAuth2) authentication
- 🎨 Text-to-Image: Generate images from text prompts
- 🖼️ Image-to-Image: Transform existing images using prompts
- 📐 Multiple Aspect Ratios: Support for various image scales (1:1, 4:3, 16:9, etc.)
- ⬆️ 4K Upscaling: Generate high-resolution versions of images
- 🔄 Variations: Create multiple variations of generated images
- 📊 Real-time Status: Polling system to track generation progress
- 🖼️ Image Gallery: View and manage multiple generated images
- 💾 Download Support: Save generated images locally
- Node.js with Express.js
- Express Session for authentication management
- Axios for HTTP requests to Akool API
- CORS enabled for frontend communication
- React.js with Vite
- React Router for navigation
- Tailwind CSS for styling (dark navy theme)
- Axios for API communication
image-generation/
├── backend/
│ ├── routes/
│ │ └── akool.js # Akool API proxy routes
│ ├── server.js # Express server
│ └── package.json
├── frontend/
│ ├── src/
│ │ ├── components/
│ │ │ ├── Login.jsx # Authentication component
│ │ │ └── Demo.jsx # Main demo interface
│ │ ├── services/
│ │ │ └── api.js # API service layer
│ │ ├── App.jsx # Main app component
│ │ ├── main.jsx # Entry point
│ │ └── index.css # Global styles
│ ├── index.html
│ ├── vite.config.js
│ ├── tailwind.config.js
│ └── package.json
└── README.md
- Node.js (v18 or higher)
- npm or yarn
- Akool API credentials (API Key or Client ID/Secret)
./start.shor
cd backend
npm startcd frontend
npm run dev- Navigate to the backend directory:
cd backend- Install dependencies:
npm install- (Optional) Create a
.envfile:
PORT=5000
SESSION_SECRET=your-random-secret-key-here- Start the backend server:
npm startThe server will run on http://localhost:5000
- Navigate to the frontend directory:
cd frontend- Install dependencies:
npm install- Start the development server:
npm run devThe frontend will run on http://localhost:5173
When you first open the application, you'll be prompted to login. You can choose between two authentication methods:
- Select "API Key" radio button
- Enter your Akool API Key
- Click "Login"
- Select "Client Credentials" radio button
- Enter your Client ID and Client Secret
- Click "Login"
The backend will handle token retrieval automatically for client credentials.
- Enter a Prompt: Describe the image you want to generate
- Select Aspect Ratio: Choose from available scales (1:1, 4:3, 16:9, etc.)
- Optional - Source Image URL: For image-to-image generation, provide a URL to an existing image
- Click "Generate Image": The system will start processing your request
- The status will update automatically (Queueing → Processing → Completed)
- Images appear in the gallery once generation is complete
- Failed generations will show an error status
Once an image is completed:
- U1-U4 buttons: Generate 4K upscaled versions
- V1-V4 buttons: Generate variations of the image
- Click any button to create a new generation based on the original
- Click the "Download" button on any completed image
- Images are valid for 7 days - download them promptly!
POST /api/login- Authenticate with API key or client credentialsPOST /api/logout- Clear sessionGET /api/auth/check- Check authentication statusPOST /api/generate- Generate image from promptPOST /api/variant- Create variant or upscaleGET /api/status/:id- Get image generation status
All Akool API calls are proxied through the backend for security:
POST /api/open/v3/content/image/createbyprompt- Text/Image to ImagePOST /api/open/v3/content/image/createbybutton- Variants/UpscalesGET /api/open/v3/content/image/infobymodelid- Get Status
The application handles various error codes from the Akool API:
- 1003: Parameter error or missing parameters
- 1008: Content does not exist
- 1009: Permission denied
- 1010: Cannot operate this content
- 1101: Invalid authorization or expired token
- 1102: Authorization cannot be empty
- 1108: Image generation error
- 1200: Account banned
cd backend
npm run dev # Uses node --watch for auto-reloadcd frontend
npm run dev # Vite dev server with hot reloadFrontend:
cd frontend
npm run buildThe built files will be in frontend/dist/
- Ensure the backend CORS is configured for your frontend URL
- Check that credentials are enabled in axios requests
- Verify your API key or client credentials are correct
- Check that the session is being maintained (cookies enabled)
- Try logging out and logging back in
- Check the error message for specific error codes
- Verify your account has sufficient credits
- Ensure prompts are appropriate and not violating content policies
- Check browser console for errors
- Verify the image model ID is correct
- Ensure the backend is running and accessible
MIT License - Feel free to use this demo for learning and development purposes.
For API documentation and support, visit:
This is a demo application. Feel free to fork and modify for your own use.
Built with ❤️ for the Akool Image Generation API