NEW

Smart Generate API

AI that understands what you want. Infographics, charts, logos, or images — one endpoint, intelligent results.

What is Smart Generate?

Smart Generate is an intelligent content generation API that uses AI to analyze your prompt and automatically select the best generation approach. No need to choose between different tools — just describe what you want, and the AI handles the rest.

🧠 AI Intent Detection

The system analyzes your prompt to detect if you want an infographic, chart, diagram, logo, or standard image. Each type gets optimized processing.

⚡ Dual Processing Modes

Infographics, charts, and diagrams render instantly on CPU (no queue). Logos and images get enhanced prompts and queue to GPU workers.

API Endpoint

POST /v1/image/smart-generate

Request Parameters

ParameterTypeRequiredDescription
promptstringYesDescription of what you want to generate
widthintegerNoOutput width (256-2048, default: 1024)
heightintegerNoOutput height (256-2048, default: 1024)

Response Fields

FieldTypeDescription
statusstring"completed" (instant) or "queued" (GPU)
intentstringDetected type: smart-infographic, smart-chart, smart-diagram, smart-logo, smart-standard
credits_usedfloatCredits deducted (2-5)
output_urlstringDirect URL to generated image (if completed)
generation_idstringJob ID for polling (if queued)
enhanced_promptstringAI-enhanced prompt (for logos/standard images)
estimated_secondsfloatEstimated processing time

Code Examples

cURL

# Generate an infographic (instant CPU render)
curl -X POST https://api.pixelapi.dev/v1/image/smart-generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "An infographic about the water cycle with evaporation, condensation, precipitation",
    "width": 1024,
    "height": 1024
  }'

# Response for infographics:
# {"status": "completed", "intent": "smart-infographic", "credits_used": 5,
#  "output_url": "/static/smart-outputs/...png"}

Python

import requests

API_KEY = "YOUR_API_KEY"
BASE_URL = "https://api.pixelapi.dev"

def smart_generate(prompt, width=1024, height=1024):
    response = requests.post(
        f"{BASE_URL}/v1/image/smart-generate",
        headers={"Authorization": f"Bearer {API_KEY}"},
        json={"prompt": prompt, "width": width, "height": height}
    )
    data = response.json()
    
    if data["status"] == "completed":
        return data["output_url"]  # Instant result
    else:
        # Poll for result
        generation_id = data["generation_id"]
        return poll_for_result(generation_id)

# Example 1: Infographic (instant)
url = smart_generate("A bar chart showing Q1-Q4 sales growth")
print(f"Chart ready: {url}")

# Example 2: Logo (queued to GPU)
url = smart_generate("A minimalist coffee shop logo with cup and steam", width=512, height=512)
print(f"Logo ready: {url}")

JavaScript/Node.js

async function smartGenerate(prompt, width = 1024, height = 1024) {
  const response = await fetch('https://api.pixelapi.dev/v1/image/smart-generate', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ prompt, width, height })
  });
  
  const data = await response.json();
  
  if (data.status === 'completed') {
    return data.output_url;
  } else {
    // Poll for completion
    return pollGeneration(data.generation_id);
  }
}

Intent Types & Pricing

Intent DetectedProcessingCreditsCostTime
smart-infographicCPU (instant)5$0.005~1-3s
smart-chartCPU (instant)3$0.003~1-3s
smart-diagramCPU (instant)3$0.003~1-3s
smart-logoGPU (queued)2$0.002~10-15s
smart-standardGPU (queued)2$0.002~10-15s
Note: Logos and standard images use FLUX Schnell with AI-enhanced prompts. The system automatically adds professional details like style guidance, color palettes, and composition tips to your prompt.

Example Prompts

Infographics (Instant - 5 credits)

Charts (Instant - 3 credits)

Diagrams (Instant - 3 credits)

Logos (GPU - 2 credits)

Standard Images (GPU - 2 credits)

Polling for Queued Jobs

When the response has status: "queued", you need to poll the generation status endpoint:

import time

def poll_generation(generation_id, timeout=300):
    """Poll for generation completion. Returns output_url or None."""
    start = time.time()
    
    while time.time() - start < timeout:
        response = requests.get(
            f"{BASE_URL}/v1/image/{generation_id}",
            headers={"Authorization": f"Bearer {API_KEY}"}
        )
        data = response.json()
        
        if data["status"] == "completed":
            return data["output_url"]
        elif data["status"] == "failed":
            raise Exception(f"Generation failed: {data.get('error_message')}")
        
        time.sleep(2)  # Poll every 2 seconds
    
    raise TimeoutError("Generation timed out")

Web Dashboard

You can also use Smart Generate directly in the PixelAPI Dashboard. No coding required — just type your prompt and get results instantly.

Pro Tip: The web dashboard automatically reconnects if you refresh the page during a generation. Your job continues processing in the background.

Error Handling

Status CodeMeaningAction
200SuccessCheck response status field
400Bad RequestCheck prompt length and parameters
401UnauthorizedVerify API key
402Payment RequiredAdd credits or upgrade plan
429Rate LimitedWait and retry