OG Image API Reference 2026 — Free REST Endpoints + Templates
This is the complete API reference for og.hjlabs.in's URL-based OG image generator. Pass query string parameters, get a 1200x630 image back. Free, no signup, edge-cached.
Endpoint
GET https://og.hjlabs.in/api/og
Returns an SVG image (default) or PNG (optional). Accepts URL-encoded query parameters.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
title | string | "Untitled" | Main heading. URL-encode special characters. |
subtitle | string | "" | Optional secondary line below the title. |
brand | string | "" | Brand wordmark (typically your domain). |
template | enum | "default" | One of: default, blog, product, social, minimal, nature. |
color1 | hex | varies | Primary accent color (URL-encode the # as %23). |
color2 | hex | varies | Secondary accent color for gradients. |
format | enum | "svg" | "svg" or "png" (PNG adds ~30ms latency). |
Templates
default
Clean gradient background, large title, brand at bottom-left. Best for general web pages.
https://og.hjlabs.in/api/og?title=Hello+World&brand=mysite.com&template=default
blog
"BLOG" tag at top-left, large title, author/brand at bottom. Best for editorial content.
https://og.hjlabs.in/api/og?title=My+Blog+Post&subtitle=A+subtitle+here&brand=author.com&template=blog
product
Product launch design with feature emphasis. Bold typography, accent stripe.
https://og.hjlabs.in/api/og?title=Launching+v2.0&subtitle=Now+with+AI&template=product
social
High-energy social design for promotions and announcements. Bright colors, large text.
https://og.hjlabs.in/api/og?title=50%25+Off+Today&template=social&color1=%23ef4444
minimal
Centered title on a near-white background. Maximum elegance, minimum noise.
https://og.hjlabs.in/api/og?title=A+Quiet+Thought&template=minimal
nature
Green/earth gradient with organic feel. Best for nature, sustainability, wellness content.
https://og.hjlabs.in/api/og?title=Forest+Walks&template=nature
Color overrides
Every template accepts color1 and color2 overrides. URL-encode the # as %23:
?title=Hello&color1=%233b82f6&color2=%238b5cf6
Recommended palettes:
- Blue/Violet —
color1=%233b82f6&color2=%238b5cf6 - Green/Cyan —
color1=%2310b981&color2=%2306b6d4 - Orange/Red —
color1=%23f59e0b&color2=%23ef4444 - Pink/Purple —
color1=%23ec4899&color2=%238b5cf6
Response headers
Content-Type: image/svg+xml (or image/png if format=png) Cache-Control: public, max-age=31536000, immutable CDN-Cache-Control: public, max-age=31536000 Access-Control-Allow-Origin: *
Images are cached at the Cloudflare edge for 1 year. Once a URL is generated and cached, subsequent requests return in 5-20ms anywhere in the world.
Caching strategy
Because the same URL always returns the same image, Cloudflare's edge cache hit rate is >99% in production. To bust the cache, change any query parameter (e.g., add ?v=2).
Rate limits
Free tier: unlimited GET requests per IP for normal browsing patterns. Abusive traffic (high-volume scrapers, automation) is throttled. For higher SLAs and dedicated quotas, see Pro plans.
Usage examples
HTML meta tags
<metaproperty="og:image"content="https://og.hjlabs.in/api/og?title=My+Post&template=blog"> <metaproperty="og:image:width"content="1200"> <metaproperty="og:image:height"content="630"> <metaname="twitter:card"content="summary_large_image"> <metaname="twitter:image"content="https://og.hjlabs.in/api/og?title=My+Post&template=blog">
Next.js App Router
export async functiongenerateMetadata({ params }) {constpost =awaitgetPost(params.slug);constogUrl =`https://og.hjlabs.in/api/og?title=${encodeURIComponent(post.title)}&template=blog&brand=mysite.com`;return{ openGraph: { images: [ogUrl] }, twitter: { images: [ogUrl] } }; }
Astro
--- Layout.astro ---const{ title } = Astro.props;constogUrl =`https://og.hjlabs.in/api/og?title=${encodeURIComponent(title)}`;---<metaproperty="og:image"content={ogUrl} />
Plain HTML / Hugo / Jekyll
<metaproperty="og:image"content="https://og.hjlabs.in/api/og?title={{ .Title | urlquery }}&template=blog">
POST endpoint (alternative)
For complex titles or when you don't want to URL-encode, POST a JSON body:
POST https://og.hjlabs.in/api/og
Content-Type: application/json
{
"title": "Special characters < & > OK",
"template": "blog",
"brand": "mysite.com"
}
Returns the same image content as GET. Note: POST responses are not cached at the edge — prefer GET for production.
Browser preview
Open any of these URLs directly in a browser to preview:
Production tips
- Always include a fallback static image — if og.hjlabs.in is briefly unreachable, your social shares still have an OG.
- Test with the Twitter Card Validator after deploying.
- Use HTTPS only — many crawlers reject HTTP image URLs.
- For 50+ unique URLs per day, pre-warm the edge cache by hitting each URL once after publish.
Self-hosting
The og.hjlabs.in source is open under MIT on GitHub. Deploy your own Cloudflare Worker in 5 minutes if you want full control.
Bottom line
Pass ?title=Your+Title and you have an OG image. Try the visual builder for a no-code workflow, or copy the URL pattern straight into your meta tags.
Generate your OG images and favicons
Free. URL-based API. Edge-cached. No signup.
Open the generator →