Dynamic OG Image Gen
Programmatically create social preview images from metadata. Custom titles, subtitles, colors, and dimensions.
/api/og-image
Description
The Dynamic OG Image Generator transforms your content metadata into visually appealing social preview images. Whether you're sharing blog posts, product pages, or landing pages, this API ensures your links look professional and engaging when shared on social media platforms.
Key Features
- Auto-sizing text — Word-wrapped text that automatically adjusts to fit your design
- Custom color scheme — Set background, title, subtitle, and accent colors via hex values
- Domain branding — Display your domain name on the generated image
- Standard dimensions — 1200x630 default for optimal social sharing
- Fast generation — Powered by SkiaSharp for lightning-fast rendering
Code Examples
curl -X POST https://api.atomicapis.dev/api/og-image \
-H "X-RapidAPI-Proxy-Secret: YOUR_SECRET" \
-H "Content-Type: application/json" \
-d '{
"title": "Building Scalable APIs with Microservices",
"subtitle": "Learn the best practices for designing APIs that scale",
"domain": "techblog.dev",
"backgroundColor": "#1a1a2e",
"titleColor": "#ffffff",
"width": 1200,
"height": 630,
"outputFormat": "base64"
}'
const response = await fetch('https://api.atomicapis.dev/api/og-image', {
method: 'POST',
headers: {
'X-RapidAPI-Proxy-Secret': 'YOUR_SECRET',
'Content-Type': 'application/json'
},
body: JSON.stringify({
title: 'Building Scalable APIs with Microservices',
subtitle: 'Learn the best practices for designing APIs that scale',
domain: 'techblog.dev',
backgroundColor: '#1a1a2e',
titleColor: '#ffffff',
width: 1200,
height: 630,
outputFormat: 'base64'
})
});
const data = await response.json();
console.log(data.base64);
import requests
response = requests.post(
'https://api.atomicapis.dev/api/og-image',
headers={
'X-RapidAPI-Proxy-Secret': 'YOUR_SECRET',
'Content-Type': 'application/json'
},
json={
'title': 'Building Scalable APIs with Microservices',
'subtitle': 'Learn the best practices for designing APIs that scale',
'domain': 'techblog.dev',
'backgroundColor': '#1a1a2e',
'titleColor': '#ffffff',
'width': 1200,
'height': 630,
'outputFormat': 'base64'
}
)
data = response.json()
print(data['base64'])
using System;
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading.Tasks;
var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-RapidAPI-Proxy-Secret", "YOUR_SECRET");
var request = new
{
title = "Building Scalable APIs with Microservices",
subtitle = "Learn the best practices for designing APIs that scale",
domain = "techblog.dev",
backgroundColor = "#1a1a2e",
titleColor = "#ffffff",
width = 1200,
height = 630,
outputFormat = "base64"
};
var response = await client.PostAsJsonAsync(
"https://api.atomicapis.dev/api/og-image",
request
);
var data = await response.Content.ReadFromJsonAsync<OgImageResponse>();
Console.WriteLine(data.Base64);
Parameters
| Name | Type | Required | Description | Example |
|---|---|---|---|---|
title |
string | Yes | The main title text for the OG image | "Building Scalable APIs" |
subtitle |
string | No | Subtitle text displayed below the title | "Learn best practices..." |
domain |
string | No | Domain name displayed on the image | "techblog.dev" |
backgroundColor |
string | No | Background color (hex) | "#1a1a2e" |
titleColor |
string | No | Title text color (hex) | "#ffffff" |
subtitleColor |
string | No | Subtitle text color (hex) | "#cccccc" |
accentColor |
string | No | Accent color (hex) | "#a855f7" |
width |
integer | No | Image width in pixels (default: 1200) | 1200 |
height |
integer | No | Image height in pixels (default: 630) | 630 |
outputFormat |
string | No | Set to "base64" to return JSON; default returns raw PNG |
"base64" |
Response Format
{
"base64": "iVBORw0KGgoAAAANSUhEUgAABLAAAAJ2CAYAAAB...",
"mimeType": "image/png",
"width": 1200,
"height": 630,
"sizeBytes": 45230
}
| Field | Type | Description |
|---|---|---|
base64 |
string | Base64-encoded image data |
mimeType |
string | MIME type of the generated image (e.g., "image/png") |
width |
integer | Width of the generated image in pixels |
height |
integer | Height of the generated image in pixels |
sizeBytes |
integer | Size of the image in bytes |
Use Cases
Social Sharing
Automatically generate eye-catching preview images when users share your content on Twitter, Facebook, LinkedIn, and other social platforms.
<meta property="og:image" content="{{ogImageUrl}}">
Blog Post Previews
Create consistent, branded preview cards for every blog post with auto-generated images featuring post titles, subtitles, and your domain name.
title: "My Post", domain: "myblog.dev"
Product Cards
Generate professional product preview images with product names, custom colors, and branded domain text for e-commerce sharing.
title: "Widget Pro", accentColor: "#e94560"
Build Constraints
SkiaSharp 2.88.9
Powered by SkiaSharp with NoDependencies native assets for cross-platform compatibility. No additional system dependencies required.
Auto-sizing Word-wrapped Text
Text automatically wraps and scales to fit within the image boundaries. Title wraps to 3 lines max with font size auto-adjusted to fit.
1200x630 Default Dimensions
Optimized for Open Graph and Twitter Card specifications. Custom dimensions supported from 100x100 to 4096x4096 pixels.
Rate Limits
Free tier: 100 requests/minute. Pro tier: 1000 requests/minute. Enterprise: Custom limits. Images cached for 24 hours.
Error Codes
| Code | Status | Description | Resolution |
|---|---|---|---|
400 |
Bad Request | Invalid parameters or missing required fields | Check request body and parameter types |
401 |
Unauthorized | Invalid or missing API key | Include valid Authorization header |
400 |
Bad Request | Dimensions must be between 100 and 4096 pixels | Use width/height values within the allowed range |
429 |
Too Many Requests | Rate limit exceeded | Wait and retry or upgrade plan |
500 |
Server Error | Image generation failed | Retry request or contact support |