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:
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
Pro
Enterprise
Quick Start
Generate your first image in seconds:
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
}'
{
"job_id": "550e8400-e29b-41d4-a716-446655440000",
"status": "queued",
"position": 3,
"estimated_time": 45
}
Generate Image
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
{
"job_id": "550e8400-e29b-41d4-a716-446655440000",
"status": "queued",
"position": 3,
"estimated_time": 45,
"message": "Job queued successfully"
}
Error Responses
{
"error": "Invalid API key"
}
{
"error": "Rate limit exceeded",
"retry_after": 900
}
Check Job Status
Check the status of a generation job.
Success Responses
{
"job_id": "550e8400-e29b-41d4-a716-446655440000",
"status": "processing",
"progress": 65,
"message": "Generating image..."
}
{
"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 real-time queue statistics.
Success Response
{
"pending": 12,
"processing": 4,
"completed_today": 1847,
"average_time": 17.3,
"workers_online": 8
}
Validate API Key
Validate your API key and check your rate limits.
Success Response
{
"valid": true,
"tier": "pro",
"rate_limit": 50,
"requests_remaining": 42,
"reset_time": "2024-01-15T12:45:00Z"
}
Code Examples
Python
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)
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
$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
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