OG Image API: Generate Social Images From a URL

An OG image API takes some text, such as a page title, and returns an image you can put in og:image. There are two common shapes:

  1. Request/response APIs. You call an endpoint (usually POST) from your code, the service renders an image, and you store or link the result.
  2. URL APIs. The image is a URL. You build a URL with parameters, put it straight in your meta tag, and the service renders it the first time a crawler asks.

For OG images, the second shape is the most convenient: social crawlers fetch the image directly, so there's no upload step and nothing to store. This guide covers what to look for in either kind, then documents Unfurlkit's URL API from our spec.

What to look for in an OG image API

Output that meets platform limits. The safe target is 1200×630, PNG or JPEG, under 600 KB, because that satisfies Meta's Facebook guidance (at least 1200×630, max 8 MB), LinkedIn's (min 1200×627, max 5 MB) and WhatsApp's (under 600 KB, at least 300 px wide, ratio ≤ 4:1). Sources and details are in OG image size.

Caching. Crawlers will request the same image many times. The service should cache rendered images at a CDN so repeat requests are fast and, ideally, don't count against your quota.

Abuse protection. A URL API that renders any text can be misused to generate arbitrary images under your account. Look for signed URLs, which use an HMAC of the parameters with a secret only your server knows, or encrypted parameters.

Predictable failure. What happens when you hit your limit or pass a bad parameter? Some services refuse requests once credits run out. For OG images, a broken image means a broken preview, so check this before you commit.

Templates vs. freeform. Some APIs render templates you design in an editor. Others take fixed templates with parameters. Freeform gives more control. Fixed templates are quicker to adopt.

Pricing you can predict. Per-render credits, shared credits, or flat tiers. Check what counts as a render (first render only, or every request?).

For how specific tools handle these, see our comparison of OG image tools.

Unfurlkit's URL API

Everything below comes from Unfurlkit's published spec.

Endpoint

GET https://unfurlkit.com/v1/{template}.png?{params}

Output: a 1200×630 PNG. Templates: basic, plus blog, product, changelog, repo, event and podcast (params for each).

basic parameters

Param Values Default
title required, non-empty text, clamped to 120 chars — (missing or empty → 400)
subtitle text, clamped to 160 chars —
theme dark | light dark
accent 6-digit hex without # 7c3aed
v any string (version / cache-buster) —
k, s public key and signature (Pro) —

Example:

<meta property="og:image"
  content="https://unfurlkit.com/v1/basic.png?title=Launch%20week&subtitle=unfurlkit.com&theme=light&accent=0ea5e9" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta name="twitter:card" content="summary_large_image" />

Responses

Status Meaning
200 PNG image
400 Invalid parameter. Body: invalid param: <name>. Unknown keys are rejected.
400 (image) Missing or empty title: an error PNG ("missing title"), not cached
404 Unknown template (blog and product until they launch)
429 Too many unsigned renders from one IP (fallback PNG, Retry-After: 60)

Free vs. signed (Pro) requests

  • Every image URL needs your key. Get a free one at unfurlkit.com/signin; no card is needed.
  • Signed Free keys get 10 renders in total (no monthly reset).
  • Signed URLs add your public key k and a 16-character signature s, computed on your server with HMAC-SHA256 over the path and sorted parameters. With Pro ($9/mo or $90/yr) you get 10,000 renders a month, no watermark, and custom fonts (Inter, Roboto, Playfair Display, JetBrains Mono) and logo. See Signing Pro URLs for tested Node and Python snippets.

Here's a short Node version:

import { createHmac } from 'node:crypto';
const enc = (s) => encodeURIComponent(s).replace(/[!'()*]/g, (c) => '%' + c.charCodeAt(0).toString(16).toUpperCase());

export function signedOgUrl(params, publicKey, secretKey, path = '/v1/basic.png') {
  const query = Object.entries({ ...params, k: publicKey })
    .sort(([a, av], [b, bv]) => (a < b ? -1 : a > b ? 1 : av < bv ? -1 : av > bv ? 1 : 0))
    .map(([k, v]) => `${enc(k)}=${enc(String(v))}`)
    .join('&');
  const s = createHmac('sha256', secretKey).update(`${path}?${query}`).digest('base64url').slice(0, 16);
  return `https://unfurlkit.com${path}?${query}&s=${s}`;
}

Never sign in browser code. The secret key must stay on your server or in your build environment.

What counts as a render

A render is counted only when a unique image is generated and wasn't already cached. Shares and cache hits don't count. Re-generating an expired or purged image counts, but cached images last about a year, so that's rare.

Over the limit

Images keep rendering past the limit:

  • Signed Free keys: after 10 renders, new images get a plain version (your title on the basic card, with the small mark) that doesn't count. The free allowance doesn't reset.
  • Pro: nothing changes past 10,000. There's no hard stop and no overage charge, and we may contact you about your usage.

Upgrade to Pro to remove watermarks from all your images. Full details on the pricing section.

Limitations at launch

  • Seven ready-made templates. You can't design your own.
  • Fonts: the four bundled ones (Inter, Roboto, Playfair Display, JetBrains Mono), on Pro. No uploaded fonts.
  • Right-to-left scripts such as Arabic and Hebrew aren't supported yet at launch.

Choosing values that render well

The API won't fail on long text. It clamps it, so a 200-character title gets cut at 120. Clamping keeps the image valid, but a cut-off sentence looks careless. Some tips:

  • Keep titles under about 70 characters so they fit on a few lines at a readable size. Use your page's <title> without the site suffix, not the full SEO title.
  • Use subtitle for context, like your domain, the section name or the author, rather than a second sentence.
  • Pick one accent per site and keep it in a config constant, so every image looks like part of the same set.
  • Pick theme to contrast with where the image appears. Most feeds have both light and dark modes, so either works. Choose the one that matches your brand.

Versioning and cache busting

Images are cached at the CDN for about a year, which is why repeat requests are free. That means changing a page title creates a new image automatically, because the URL changes. But if you want to force a refresh with the same text, change v:

/v1/basic.png?title=Pricing&v=2

A good default is to set v to your post's last-updated date. A new v is a new unique image, so it counts as one render. Social platforms also cache previews on their side. After changing an image, re-scrape the page in each platform's debugger. See Twitter card validator and OG image not showing.

Security checklist

  • Keep the secret key in an environment variable on the server or in CI. Never commit it.
  • Sign in server code only (getServerSideProps, +page.server.js, a Hugo build step, a WordPress filter).
  • If the secret leaks, rotate the key (see below).
  • Don't put private data in parameters. Image URLs are public and appear in your page source.

Rotating a key

  • Rotating a key revokes the old secret immediately.
  • URLs signed with the old secret that are already published keep rendering, but with the watermark, so your pages don't break, until you re-sign them with the new key.
  • Images that are already cached may keep serving until they're purged.
  • Need help? We reply within 1 business day at support@unfurlkit.com.

Using the API from different stacks

Because it's a URL, every stack just prints a meta tag:

  • Next.js: return the URL from generateMetadata. (guide)
  • Astro: pass it to your layout's ogImage prop. (guide)
  • Hugo: build it with querify in a partial. (guide)
  • WordPress: return it from a Yoast or Rank Math filter, or print it on wp_head. (guide)
  • Ghost: write it into og_image with the Admin API. (guide)
  • Eleventy: set it with computed data. (guide)
  • SvelteKit: sign in +page.server.js and print it in <svelte:head>. (guide)

Testing

  1. Open the image URL in a browser. You should see the PNG.
  2. A 400 names the bad parameter. Check theme (light/dark) and accent (6 hex digits, no #).
  3. If a signed image still has the watermark, check the X-Unfurlkit-Signature response header. stale means the signature doesn't match (or was made with a rotated-out secret). invalid means an unknown or revoked key. Sign exactly the params you send, in the same order, and don't re-encode afterwards.
  4. Check the page with the Free OG Image Checker to see previews on X, LinkedIn, Facebook, WhatsApp, Slack, Discord and iMessage. We don't store the URLs you check.

FAQ

Which languages and scripts are supported? Right-to-left scripts such as Arabic and Hebrew aren't supported yet at launch.

Is there a POST endpoint? Not in the spec. The API is URL-only (GET), which is what social crawlers need.

Do I need an API key for Free? Yes. Every image URL needs your key. A free key needs no card and carries the watermark.

Can I change the size? Output is 1200×630 at launch.

Does every crawler request cost a render? No. Only uncached, unique renders count.

Updated 2026-10-21

Try it freePricing