Background API

A unique background for every page, from one URL

Put a URL in an <img> tag or in your og:image and get a low poly background back. Use the post slug as the seed and every article gets its own image, the same one every time, with no design work and no files to store.

<img src="https://trianglebg.com/api/bg?seed=my-first-post&palette=ocean" alt="" />

Examples

OG image with a title
OG image with a title/api/bg?seed=hello-world&palette=midnight&title=Hello%2C%20world
Brand colors
Brand colors/api/bg?seed=acme&colors=0f172a,0ea5e9,f0f9ff
Vertical gradient, small triangles
Vertical gradient, small triangles/api/bg?seed=42&palette=sunset&direction=y&cell=50

Dynamic OG images in Next.js

Every post gets a 1200×630 social image with its title on it. Because the output depends only on the URL, the image is cached by the CDN after the first request.

// app/blog/[slug]/page.tsx
export async function generateMetadata({ params }) {
  const { slug } = await params;
  const post = await getPost(slug);
  const og = new URL("https://trianglebg.com/api/bg");
  og.searchParams.set("seed", slug);
  og.searchParams.set("title", post.title);
  og.searchParams.set("palette", "midnight");

  return { openGraph: { images: [{ url: og.toString(), width: 1200, height: 630 }] } };
}

Parameters

GET https://trianglebg.com/api/bg. All parameters are optional.

NameValuesDefaultNotes
seedany text, up to 200 charstrianglebgSame seed and settings always give the same image. Use a post slug or title.
w, h16–40961200, 630Output size in pixels.
paletteocean, sunset, dark, forest, midnight, pasteloceanBuilt-in palette.
colors3 hex colors, comma separated–Your own gradient, dark to light. Overrides palette.
cell10–100090Triangle size. Smaller means more triangles.
variance0–10.45How irregular the triangles are.
intensity0–10.35Color difference between neighbouring triangles.
directionx, y, diagonal, diagonalReversediagonalGradient direction.
formatpng, svgpngSVG needs an API key.
titletext, up to 120 chars–Centered headline over the background. PNG only.
keyyour API key–Unlocks SVG and sizes above the free limit.

Invalid parameters return a 400 response with a JSON error message.

Free

  • PNG up to 1280×720 (or 720×1280)
  • Covers OG images (1200×630) and blog headers
  • Titles, custom colors, all settings
  • No signup

With an API key

  • PNG up to 4096×4096
  • SVG output
  • For wallpapers, print and retina hero images
Request an API key

Prefer to design by hand? Open the editor.