API Documentation

Generate stunning AI images programmatically with our RESTful API

Overview

The DABGPT API provides programmatic access to our AI image generation system. Generate high-quality images using state-of-the-art AI models through simple HTTP requests.

🚀 Fast Generation

Average generation time of 15-20 seconds per image

🎨 High Quality

1024x1024 resolution with advanced AI models

📊 Queue System

Efficient distributed processing with real-time status

Authentication

All API requests require authentication using an API key. Include your API key in the request headers:

Request Header
X-API-Key: dabgpt_YOUR_API_KEY_HERE

Get your API key from the Dashboard after signing in.

Rate Limits

Rate limits are based on your account tier and apply to 15-minute windows:

Trial

5
requests / 15 min

Pro

50
requests / 15 min

Enterprise

200
requests / 15 min

Quick Start

Generate your first image in seconds:

cURL Example
curl -X POST https://dabgpt.com/api/v1/generate \
  -H "X-API-Key: dabgpt_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "futuristic city with neon lights at night",
    "negative_prompt": "blur, low quality",
    "width": 1024,
    "height": 1024
  }'
200 OK
{
  "job_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "queued",
  "position": 3,
  "estimated_time": 45
}

Generate Image

POST /api/v1/generate

Submit an image generation request to the queue.

Parameters

Parameter Type Required Description
prompt string Required Text description of the image to generate
negative_prompt string Optional Elements to avoid in generation
width integer Optional Image width (default: 1024, max: 1024)
height integer Optional Image height (default: 1024, max: 1024)
steps integer Optional Inference steps (default: 25, range: 20-50)

Success Response

200 OK
{
  "job_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "queued",
  "position": 3,
  "estimated_time": 45,
  "message": "Job queued successfully"
}

Error Responses

401 Unauthorized
{
  "error": "Invalid API key"
}
429 Too Many Requests
{
  "error": "Rate limit exceeded",
  "retry_after": 900
}

Check Job Status

GET /api/v1/status/{job_id}

Check the status of a generation job.

Success Responses

200 OK - Processing
{
  "job_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "processing",
  "progress": 65,
  "message": "Generating image..."
}
200 OK - Completed
{
  "job_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "completed",
  "image_url": "https://dabgpt.com/images/550e8400-e29b-41d4-a716-446655440000.png",
  "generation_time": 18.5,
  "prompt": "futuristic city with neon lights at night",
  "width": 1024,
  "height": 1024
}

Queue Statistics

GET /api/v1/queue/stats

Get real-time queue statistics.

Success Response

200 OK
{
  "pending": 12,
  "processing": 4,
  "completed_today": 1847,
  "average_time": 17.3,
  "workers_online": 8
}

Validate API Key

POST /api/v1/validate

Validate your API key and check your rate limits.

Success Response

200 OK
{
  "valid": true,
  "tier": "pro",
  "rate_limit": 50,
  "requests_remaining": 42,
  "reset_time": "2024-01-15T12:45:00Z"
}

Code Examples

Python

Python with requests
import requests
import time

API_KEY = "dabgpt_YOUR_API_KEY"
BASE_URL = "https://dabgpt.com/api/v1"

# Generate image
response = requests.post(
    f"{BASE_URL}/generate",
    headers={"X-API-Key": API_KEY},
    json={
        "prompt": "cyberpunk cat with neon eyes",
        "negative_prompt": "blur, distorted",
        "width": 1024,
        "height": 1024
    }
)

job = response.json()
job_id = job["job_id"]

# Poll for status
while True:
    status = requests.get(
        f"{BASE_URL}/status/{job_id}",
        headers={"X-API-Key": API_KEY}
    ).json()
    
    if status["status"] == "completed":
        print(f"Image ready: {status['image_url']}")
        break
    elif status["status"] == "failed":
        print(f"Generation failed: {status['error']}")
        break
    
    time.sleep(5)  # Wait 5 seconds before checking again

JavaScript (Node.js)

Node.js with fetch
const API_KEY = 'dabgpt_YOUR_API_KEY';
const BASE_URL = 'https://dabgpt.com/api/v1';

async function generateImage(prompt) {
    // Submit generation request
    const response = await fetch(`${BASE_URL}/generate`, {
        method: 'POST',
        headers: {
            'X-API-Key': API_KEY,
            'Content-Type': 'application/json'
        },
        body: JSON.stringify({
            prompt: prompt,
            width: 1024,
            height: 1024
        })
    });
    
    const job = await response.json();
    
    // Poll for completion
    while (true) {
        const status = await fetch(`${BASE_URL}/status/${job.job_id}`, {
            headers: { 'X-API-Key': API_KEY }
        }).then(r => r.json());
        
        if (status.status === 'completed') {
            return status.image_url;
        } else if (status.status === 'failed') {
            throw new Error(status.error);
        }
        
        await new Promise(r => setTimeout(r, 5000));
    }
}

// Usage
generateImage('futuristic robot in a garden')
    .then(url => console.log('Image:', url))
    .catch(err => console.error('Error:', err));

PHP

PHP with cURL
<?php
$api_key = 'dabgpt_YOUR_API_KEY';
$base_url = 'https://dabgpt.com/api/v1';

// Generate image
$ch = curl_init($base_url . '/generate');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'X-API-Key: ' . $api_key,
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'prompt' => 'magical forest with glowing mushrooms',
    'width' => 1024,
    'height' => 1024
]));

$response = curl_exec($ch);
$job = json_decode($response, true);
curl_close($ch);

// Check status
$job_id = $job['job_id'];
while (true) {
    $ch = curl_init($base_url . '/status/' . $job_id);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, ['X-API-Key: ' . $api_key]);
    
    $response = curl_exec($ch);
    $status = json_decode($response, true);
    curl_close($ch);
    
    if ($status['status'] == 'completed') {
        echo "Image ready: " . $status['image_url'];
        break;
    }
    
    sleep(5);
}
?>

Response Examples

Successful Generation Flow

1. Job Queued

{
  "job_id": "abc123",
  "status": "queued",
  "position": 5,
  "estimated_time": 90
}

2. Processing

{
  "job_id": "abc123",
  "status": "processing",
  "progress": 45,
  "message": "Generating..."
}

3. Completed

{
  "job_id": "abc123",
  "status": "completed",
  "image_url": "https://...",
  "generation_time": 16.8
}

Error Handling

The API uses standard HTTP status codes to indicate success or failure:

Status Code Meaning Description
200 Success Request processed successfully
400 Bad Request Invalid parameters or malformed request
401 Unauthorized Invalid or missing API key
429 Rate Limited Too many requests in time window
500 Server Error Internal server error (rare)

Frequently Asked Questions

Q: How fast is image generation?
A: Average generation time is 15-20 seconds per image, depending on queue size and complexity. Enterprise customers get priority processing for faster generation.
Q: What image sizes are supported?
A: Currently we support up to 1024x1024 pixels. Common sizes include 512x512, 768x768, and 1024x1024. Aspect ratios like 16:9 and 9:16 are also supported within the maximum dimensions.
Q: How long are generated images stored?
A: Generated images are stored for 30 days for Trial users, 90 days for Pro users, and indefinitely for Enterprise customers. You can also lock important images to prevent automatic deletion.
Q: Can I use the images commercially?
A: Yes! All generated images are yours to use commercially. You retain full rights to images generated with your API key.
Q: What happens if I exceed my rate limit?
A: You'll receive a 429 status code with a retry_after field indicating when you can make requests again. Rate limits reset every 15 minutes.
Q: Can I generate multiple images in one request?
A: Currently, each request generates one image. For batch processing, submit multiple requests and track them using their job IDs. Enterprise plans support batch endpoints.
Q: Is there a webhook for completion notifications?
A: Webhook support is available for Enterprise customers. Contact support to configure webhook URLs for your account.
Q: What's the best practice for polling status?
A: Poll every 5 seconds for optimal balance between responsiveness and API usage. The status endpoint doesn't count against your rate limit.
Q: Can I cancel a job in progress?
A: Yes, use DELETE /api/v1/jobs/{job_id} to cancel a queued or processing job. Cancelled jobs don't count against your quota.
Q: How do I handle network timeouts?
A: Set client timeout to at least 30 seconds for generation requests. If timeout occurs, check job status using the job_id - the generation continues server-side.

Support

📧 Email Support

api@dabgpt.com
Response within 24 hours

💬 Discord Community

Join our Discord for real-time help and updates

📚 GitHub Examples

github.com/dabgpt/examples
Full code examples in multiple languages

Need Higher Limits?

Contact our sales team for custom Enterprise plans with dedicated infrastructure, SLA guarantees, and priority support.

enterprise@dabgpt.com