AI that understands what you want. Infographics, charts, logos, or images — one endpoint, intelligent results.
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.
The system analyzes your prompt to detect if you want an infographic, chart, diagram, logo, or standard image. Each type gets optimized processing.
Infographics, charts, and diagrams render instantly on CPU (no queue). Logos and images get enhanced prompts and queue to GPU workers.
POST /v1/image/smart-generate
| Parameter | Type | Required | Description |
|---|---|---|---|
| prompt | string | Yes | Description of what you want to generate |
| width | integer | No | Output width (256-2048, default: 1024) |
| height | integer | No | Output height (256-2048, default: 1024) |
| Field | Type | Description |
|---|---|---|
| status | string | "completed" (instant) or "queued" (GPU) |
| intent | string | Detected type: smart-infographic, smart-chart, smart-diagram, smart-logo, smart-standard |
| credits_used | float | Credits deducted (2-5) |
| output_url | string | Direct URL to generated image (if completed) |
| generation_id | string | Job ID for polling (if queued) |
| enhanced_prompt | string | AI-enhanced prompt (for logos/standard images) |
| estimated_seconds | float | Estimated processing time |
# 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"}
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}")
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 Detected | Processing | Credits | Cost | Time |
|---|---|---|---|---|
| smart-infographic | CPU (instant) | 5 | $0.005 | ~1-3s |
| smart-chart | CPU (instant) | 3 | $0.003 | ~1-3s |
| smart-diagram | CPU (instant) | 3 | $0.003 | ~1-3s |
| smart-logo | GPU (queued) | 2 | $0.002 | ~10-15s |
| smart-standard | GPU (queued) | 2 | $0.002 | ~10-15s |
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")
You can also use Smart Generate directly in the PixelAPI Dashboard. No coding required — just type your prompt and get results instantly.
| Status Code | Meaning | Action |
|---|---|---|
| 200 | Success | Check response status field |
| 400 | Bad Request | Check prompt length and parameters |
| 401 | Unauthorized | Verify API key |
| 402 | Payment Required | Add credits or upgrade plan |
| 429 | Rate Limited | Wait and retry |