Skip to content

Generate Image API

The core endpoint for generating Open Graph images.

Endpoint

POST /api/generate

Authentication

Include your API key in the X-API-Key header:

bash
-H "X-API-Key: og_your_api_key_here"

Request Body

Send a JSON object with your image parameters.

Core Parameters

ParameterTypeRequiredDescription
titlestringYesMain headline (max 200 chars)
subtitlestringNoSecondary text (max 300 chars)
templatestringNoTemplate name (default: default)
themestringNodark or light (default: dark)

Author Parameters

ParameterTypeDescription
author_namestringAuthor/creator name
author_avatar_urlstringURL to avatar image (supports PNG, JPG, WebP)

Product Parameters (Product Template)

ParameterTypeDescription
product_image_urlstringProduct image URL
pricestringPrice display (e.g., "$99.99")
original_pricestringOriginal price for discount display
brandstringBrand name
ratingnumberRating (0-5)
badgestringBadge text (e.g., "SALE", "NEW")

Real Estate Parameters

ParameterTypeDescription
property_image_urlstringProperty photo URL
addressstringProperty address
bedsnumberNumber of bedrooms
bathsnumberNumber of bathrooms
sqftstringSquare footage
logo_urlstringAgency/brand logo

Stats Parameters

ParameterTypeDescription
stat_valuestringMain statistic (e.g., "$1.2M")
stat_labelstringLabel for the stat
trend_iconstringup, down, or neutral
trend_valuestringTrend percentage

Event Parameters

ParameterTypeDescription
datestringEvent date
timestringEvent time
locationstringEvent location
speaker_namestringSpeaker name
speaker_avatar_urlstringSpeaker photo

Meme Parameters

ParameterTypeDescription
image_urlstringBackground image
caption_topstringTop caption text
caption_bottomstringBottom caption text

Grid Parameters

ParameterTypeDescription
grid_imagesarrayArray of image URLs (2-4 images)
grid_titlestringGrid section title

Response

Success (200)

Returns the generated image as binary data:

Content-Type: image/png

Error Responses

CodeDescription
400Invalid request body
401Missing or invalid API key
403Rate limit exceeded
500Server error

Error response body:

json
{
  "error": "Error message description"
}

Examples

Basic Title + Subtitle

bash
curl -X POST https://ogimageapi.io/api/generate \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "title": "Getting Started with React",
    "subtitle": "A comprehensive guide for beginners",
    "theme": "dark"
  }' \
  --output og-image.png

Blog Post with Author

bash
curl -X POST https://ogimageapi.io/api/generate \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "title": "10 Tips for Better Code",
    "subtitle": "Write cleaner, more maintainable code",
    "author_name": "Sarah Chen",
    "author_avatar_url": "https://example.com/avatar.jpg",
    "template": "blog",
    "theme": "dark"
  }' \
  --output blog-og.png

Product Card

bash
curl -X POST https://ogimageapi.io/api/generate \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "title": "Premium Wireless Headphones",
    "product_image_url": "https://example.com/headphones.png",
    "price": "$199.99",
    "original_price": "$299.99",
    "brand": "AudioTech",
    "rating": 4.5,
    "badge": "SALE",
    "template": "product",
    "theme": "dark"
  }' \
  --output product-og.png

Real Estate Listing

bash
curl -X POST https://ogimageapi.io/api/generate \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "title": "$1,250,000",
    "subtitle": "Luxury Modern Home",
    "property_image_url": "https://example.com/house.jpg",
    "address": "123 Oak Street, Beverly Hills",
    "beds": 4,
    "baths": 3,
    "sqft": "3,200",
    "template": "realestate",
    "theme": "light"
  }' \
  --output listing-og.png

Stats Card

bash
curl -X POST https://ogimageapi.io/api/generate \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "stat_value": "$1.2M",
    "stat_label": "Total Revenue",
    "trend_icon": "up",
    "trend_value": "+24%",
    "template": "stats",
    "theme": "dark"
  }' \
  --output stats-og.png

Event Announcement

bash
curl -X POST https://ogimageapi.io/api/generate \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "title": "DevConf 2024",
    "date": "March 15, 2024",
    "time": "9:00 AM PST",
    "location": "San Francisco, CA",
    "speaker_name": "Alex Johnson",
    "template": "event",
    "theme": "dark"
  }' \
  --output event-og.png

Rate Limits

PlanRequests/MonthRate Limit
Free251/second
Starter1005/second
Pro50010/second
Agency2,00025/second
Publishing10,00050/second

Caching

Generated images include caching headers:

Cache-Control: public, max-age=86400

This means images can be cached by CDNs for 24 hours.

Best Practices

  1. Use HTTPS image URLs — Remote images must be accessible via HTTPS
  2. Optimize source images — Large source images may slow generation
  3. Handle errors gracefully — Always check response status codes
  4. Cache generated images — Store images locally to reduce API calls
  5. Use appropriate templates — Choose templates that match your content

Generate stunning Open Graph images programmatically.