/api/v1/ogOG Image Generator API
Generate beautiful, dynamic Open Graph images for social media sharing. Perfect for blog posts, product pages, and any content that benefits from custom social media previews.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| title | string | Yes | - | The main title text for the OG image. Max 100 characters. |
| description | string | No | - | Subtitle or description text. Max 200 characters. |
| theme | string | No | dark | Color theme: dark, light, gradient, ocean, sunset, forest. |
| logo | string | No | - | URL to a logo image to display in the top-left corner. |
| font | string | No | inter | Font family: inter, roboto, playfair, mono. |
| author | string | No | - | Author name displayed at the bottom of the image. |
| template | string | No | default | Template style: default, blog, product, minimal. |
Available Templates
defaultClean layout with title, description, and optional logo. Great for general purpose use.
blogOptimized for blog posts with author name, reading time badge, and category label.
productProduct-focused with prominent title, price badge, and call-to-action area.
minimalUltra-clean design with just the title and a subtle gradient background.
Code Examples
cURL
# Basic OG image
curl "https://captureapi.dev/api/v1/og?title=My+Blog+Post&description=A+deep+dive+into+APIs&theme=dark" \
-H "X-API-Key: cap_your_key" \
-o og-image.png
# With logo and author
curl "https://captureapi.dev/api/v1/og?title=Product+Launch&description=Introducing+our+new+API&theme=gradient&logo=https://example.com/logo.png&author=Jane+Doe&template=blog" \
-H "X-API-Key: cap_your_key" \
-o og-blog.pngJavaScript
async function generateOgImage(title, options = {}) {
const params = new URLSearchParams({
title,
...(options.description && { description: options.description }),
theme: options.theme || "dark",
...(options.logo && { logo: options.logo }),
...(options.font && { font: options.font }),
...(options.author && { author: options.author }),
template: options.template || "default",
});
const response = await fetch(
`https://captureapi.dev/api/v1/og?${params}`,
{ headers: { "X-API-Key": process.env.CAPTURE_API_KEY } }
);
if (!response.ok) throw new Error("Failed to generate OG image");
return response.arrayBuffer();
}
// Use in Next.js metadata
export async function generateMetadata({ params }) {
const post = await getPost(params.slug);
return {
openGraph: {
images: [
`https://captureapi.dev/api/v1/og?title=${encodeURIComponent(post.title)}&theme=dark`
],
},
};
}Python
import requests
import os
def generate_og_image(title, **kwargs):
params = {
"title": title,
"theme": kwargs.get("theme", "dark"),
"template": kwargs.get("template", "default"),
}
if kwargs.get("description"):
params["description"] = kwargs["description"]
if kwargs.get("author"):
params["author"] = kwargs["author"]
response = requests.get(
"https://captureapi.dev/api/v1/og",
params=params,
headers={"X-API-Key": os.environ["CAPTURE_API_KEY"]}
)
response.raise_for_status()
return response.content
# Usage
image = generate_og_image(
"My Awesome Blog Post",
description="A comprehensive guide to building APIs",
theme="gradient",
author="John Smith"
)
with open("og-image.png", "wb") as f:
f.write(image)Common Use Cases
Blog Posts
Automatically generate social cards for each blog post with the title, author, and category.
Product Pages
Create product-specific OG images with pricing and promotional text for better click-through rates.
Documentation
Generate consistent social previews for your documentation pages with version numbers and section titles.
User Profiles
Create personalized social cards for user profile pages with avatar, name, and stats.