OG Image API
Generate beautiful 1200×630 Open Graph images from templates. Pass your data, get a perfect social preview image.
The OG Image API requires a Starter plan or above. Free plan requests return 403 plan_required. View plans →
/v1/og-imageRequest body
{
"template": "blog-post",
"data": {
"title": "How to Scale Your Startup",
"author": "Jane Doe",
"date": "March 25, 2026",
"reading_time": "5 min",
"tag": "Engineering"
},
"width": 1200,
"height": 630,
"format": "png"
}| Parameter | Type | Default | Description |
|---|---|---|---|
template* | string | — | Template ID. See /v1/templates for available templates. |
data* | object | — | Template variables as key-value pairs. |
width | number | 1200 | Output width in pixels. Min 100, max 3840. |
height | number | 630 | Output height in pixels. Min 100, max 2160. |
format | enum | png | Output format: png, jpeg, or webp. |
cache | boolean | true | Cache the result in Redis. |
cache_ttl | number | 3600 | Cache TTL in seconds. |
Available templates
| Template ID | Variables |
|---|---|
blog-post | title, author, date, avatar_url, reading_time, tag, bg_color |
social-card | title, description, logo_url, site_name, bg_color |
product-card | name, tagline, price, image_url, badge, bg_color |
github-readme | repo, description, stars, forks, language, owner_avatar |
quote-card | quote, author, role, avatar_url, bg_color |
Example
Generate a blog post OG image:
curl -X POST "https://api.snapsharp.dev/v1/og-image" \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{
"template": "blog-post",
"data": {
"title": "Why Your Headless Chrome Keeps Crashing",
"author": "Alex Chen",
"date": "March 25, 2026",
"reading_time": "8 min",
"tag": "DevOps"
}
}' -o og.pngResponse
Returns binary image data directly in the response body.
| Header | Value |
|---|---|
Content-Type | image/png, image/jpeg, or image/webp (based on format param) |
X-Response-Time | Render time in milliseconds |
X-Cache | HIT or MISS |
Use format: "jpeg" or format: "webp" for smaller file sizes (30–50% smaller than PNG). Most social platforms accept JPEG for OG images. WebP offers the best compression but isn't supported by all unfurlers.
Custom templates
In addition to the 5 built-in templates, you can design your own with HTML/CSS using the Custom Templates feature (Growth+ plan). Use your template's slug as the template parameter.
SDK examples
Using the official SDKs:
// Node.js
import { SnapSharp } from '@snapsharp/sdk';
const snap = new SnapSharp('sk_live_...');
const image = await snap.ogImage('blog-post', {
title: 'My Article',
author: 'Jane Doe',
});# Python
from snapsharp import SnapSharp
snap = SnapSharp("sk_live_...")
image = snap.og_image("blog-post", {"title": "My Article", "author": "Jane Doe"})See all SDKs at SDKs & Libraries.