A powerful AI-powered image processing API that lets you enhance images, generate new ones from text, remove backgrounds, and generate text - all through simple HTTP endpoints.
Transform your images with AI-powered upscaling and enhancement.
Create stunning images from text descriptions using advanced AI models.
Automatically remove backgrounds from any image.
Generate text content based on your prompts.
- Node.js v14+
- Docker (optional)
# Clone and setup
git clone https://github.com/hode2002/ai-huggingface.git
cd ai-huggingface
npm install
# Configure
cp .env.example .env
# Start the server
npm run dev
http://localhost:3002
POST /enhance
// Request
{
"image": "https://example.com/image.jpg",
"size": "2x" // Optional: "2x" | "4x" | "8x"
}
// Response
{
"success": true,
"data": {
"enhancedImageUrl": "https://..."
}
}
POST /generate?model=fluxDev
// Request
{
"prompt": "A beautiful sunset over mountains",
"negative_prompt": "blurry, low quality", // Optional
"num_inference_steps": 50, // Optional
"guidance_scale": 7.5 // Optional
}
// Response
{
"success": true,
"data": {
"generatedImageUrl": "https://..."
}
}
POST /remove-background
// Request
{
"imageUrl": "https://example.com/image.jpg"
}
// Response
{
"success": true,
"data": {
"imageUrl": "https://..."
}
}
POST /text
// Request
{
"prompt": "Write a story about a magical forest",
"maxLength": 100 // Optional
}
// Response
{
"success": true,
"data": {
"prompt": "Generated text..."
}
}
// Enhance an image
const enhanceImage = async (imageUrl: string) => {
const response = await fetch('http://localhost:3002/enhance', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ image: imageUrl, size: '2x' })
});
return response.json();
};
// Generate an image
const generateImage = async (prompt: string) => {
const response = await fetch('http://localhost:3002/generate?model=fluxDev', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
prompt,
negative_prompt: 'blurry, low quality',
num_inference_steps: 50,
guidance_scale: 7.5
})
});
return response.json();
};
// Remove background
const removeBackground = async (imageUrl) => {
const response = await fetch('http://localhost:3002/remove-background', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ imageUrl })
});
return response.json();
};
// Generate text
const generateText = async (prompt) => {
const response = await fetch('http://localhost:3002/text', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ prompt, maxLength: 100 })
});
return response.json();
};
src/
βββ controllers/ # API route handlers
βββ services/ # Business logic
βββ interfaces/ # TypeScript interfaces
βββ types/ # Type definitions
βββ config/ # Configuration
βββ server.ts # Entry point