← All articles · May 10, 2026 · og.hjlabs.in

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

ParameterTypeDefaultDescription
titlestring"Untitled"Main heading. URL-encode special characters.
subtitlestring""Optional secondary line below the title.
brandstring""Brand wordmark (typically your domain).
templateenum"default"One of: default, blog, product, social, minimal, nature.
color1hexvariesPrimary accent color (URL-encode the # as %23).
color2hexvariesSecondary accent color for gradients.
formatenum"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:

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

<meta property="og:image" content="https://og.hjlabs.in/api/og?title=My+Post&template=blog">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://og.hjlabs.in/api/og?title=My+Post&template=blog">

Next.js App Router

export async function generateMetadata({ params }) {
  const post = await getPost(params.slug);
  const ogUrl = `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;
const ogUrl = `https://og.hjlabs.in/api/og?title=${encodeURIComponent(title)}`;
---
<meta property="og:image" content={ogUrl} />

Plain HTML / Hugo / Jekyll

<meta property="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

  1. Always include a fallback static image — if og.hjlabs.in is briefly unreachable, your social shares still have an OG.
  2. Test with the Twitter Card Validator after deploying.
  3. Use HTTPS only — many crawlers reject HTTP image URLs.
  4. 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 →

More from the blog