API Documentation

Authentication

The API supports two authentication methods:

  • JWT Token: Use for web dashboard access
  • API Key: Use for programmatic access

JWT Token

Authorization: Bearer <your-jwt-token>

API Key

X-API-Key: <your-api-key>

Generate Image

Generate a new image using DALL-E 3.

Endpoint

POST /api/images/generate

Request Body

{
  "prompt": "A futuristic city at sunset",
  "size": "1024x1024",
  "style": "standard"
}

Parameters

ParameterTypeRequiredDescription
promptstringYesText description of the image (max 1000 chars)
sizestringNoImage size: 1024x1024, 1792x1024, or 1024x1792 (default: 1024x1024)
stylestringNoStyle: "standard" or "vivid" (default: "standard")

Response

{
  "success": true,
  "image": {
    "id": "abc123...",
    "url": "https://...",
    "prompt": "A futuristic city at sunset",
    "size": "1024x1024",
    "style": "standard",
    "createdAt": "2024-01-15T10:30:00Z"
  },
  "credits_remaining": 9
}

Example (cURL)

curl -X POST https://api.imagify.ca/api/images/generate \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A futuristic city at sunset",
    "size": "1024x1024",
    "style": "standard"
  }'

Example (JavaScript)

const response = await fetch('https://api.imagify.ca/api/images/generate', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_JWT_TOKEN',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    prompt: 'A futuristic city at sunset',
    size: '1024x1024',
    style: 'standard'
  })
});

const data = await response.json();
console.log(data.image.url);

Get Image History

Retrieve your generated images with pagination.

Endpoint

GET /api/images/history?page=1&limit=20

Query Parameters

ParameterTypeDefaultDescription
pagenumber1Page number
limitnumber20Items per page

Error Responses

401 Unauthorized

{
  "error": "Authentication required"
}

402 Payment Required

{
  "error": "Insufficient credits",
  "credits": 0,
  "message": "Please purchase more credits to continue"
}

400 Bad Request

{
  "error": "Prompt is required"
}

Rate Limits

API requests are limited to 100 requests per 15 minutes per IP address. Additional rate limits may apply based on your subscription tier.