API Documentation

Generate beautiful OG images with a single GET request. No SDK needed.

Quick Start

1. Create a free account and generate an API key from your dashboard.

2. Make a GET request:

GET https://ogimg.xyz/api/og?title=Hello+World&template=gradient
Authorization: Bearer YOUR_API_KEY

3. You get back a 1200x630 PNG image. Use the URL directly as your og:image meta tag.

Authentication

Pass your API key via Authorization header (recommended) or query parameter:

Header (recommended)
Authorization: Bearer YOUR_API_KEY
Query parameter
/api/og?title=Hello&key=YOUR_API_KEY

Without an API key, requests are treated as free-tier with a rate limit of 30 requests/minute and a watermark on images.

Parameters

All parameters are passed as query strings. None are required — sensible defaults are used.

ParameterTypeDefaultPlanDescription
titlestring"Hello World"FreeMain heading text
descriptionstringFreeSubtitle / description text
templatestring"basic"Free*Template name (see list below)
patternstring"none"Free*Background pattern (see list below)
bgColorstringTemplate defaultFreeBackground color (hex, e.g. #1a1a2e)
textColorstringTemplate defaultHobby+Text color (hex)
accentColorstring"#6366f1"Hobby+Accent / highlight color (hex)
siteNamestringFreeSite name shown on some templates
authorstringFreeAuthor name (blog template)
datestringFreeDate string (blog template, e.g. "Jan 15, 2025")
tagsstringFreeComma-separated tags (e.g. "react,nextjs")
logoURLHobby+URL to your logo image
widthnumber1200Hobby+Image width in px (100-2048)
heightnumber630Hobby+Image height in px (100-2048)
urlURLFreeAuto-fetch title & description from this URL
keystringAPI key (query param). Or use Authorization header.

* Free plan has access to a subset of templates and patterns. See lists below.

Templates

10 professionally designed templates. Free plan includes 4, paid plans unlock all 10.

basic template
basic
Free
blog template
blog
Free
gradient template
gradient
Free
minimal template
minimal
Free
dark template
dark
Hobby+
split template
split
Hobby+
sunset template
sunset
Hobby+
ocean template
ocean
Hobby+
corporate template
corporate
Hobby+
retro template
retro
Hobby+

Background Patterns

10 background patterns to add texture. Free plan includes 3 (none, dots, grid).

none
Free
dots
Free
grid
Free
diagonal
Hobby+
waves
Hobby+
topography
Hobby+
noise
Hobby+
hideout
Hobby+
hexagons
Hobby+
circuit
Hobby+

Code Examples

curl
curl "https://ogimg.xyz/api/og?title=My+Blog+Post&template=gradient" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  --output og-image.png
javascript
const response = await fetch(
  "https://ogimg.xyz/api/og?" + new URLSearchParams({
    title: "My Blog Post",
    description: "A great article about web development",
    template: "gradient",
  }),
  {
    headers: { Authorization: "Bearer YOUR_API_KEY" },
  }
);

const imageBlob = await response.blob();
python
import requests

response = requests.get(
    "https://ogimg.xyz/api/og",
    params={
        "title": "My Blog Post",
        "description": "A great article about web development",
        "template": "gradient",
    },
    headers={"Authorization": "Bearer YOUR_API_KEY"},
)

with open("og-image.png", "wb") as f:
    f.write(response.content)
Next.js
// app/layout.tsx
import type { Metadata } from "next";

export const metadata: Metadata = {
  openGraph: {
    images: [
      {
        url: "https://ogimg.xyz/api/og?title=My+Site&template=gradient&key=YOUR_API_KEY",
        width: 1200,
        height: 630,
      },
    ],
  },
};
go
package main

import (
	"io"
	"net/http"
	"net/url"
	"os"
)

func main() {
	params := url.Values{}
	params.Set("title", "My Blog Post")
	params.Set("template", "gradient")

	req, _ := http.NewRequest("GET", "https://ogimg.xyz/api/og?"+params.Encode(), nil)
	req.Header.Set("Authorization", "Bearer YOUR_API_KEY")

	resp, _ := http.DefaultClient.Do(req)
	defer resp.Body.Close()

	f, _ := os.Create("og-image.png")
	defer f.Close()
	io.Copy(f, resp.Body)
}
HTML Meta Tag
<!-- Add to your HTML <head> -->
<meta property="og:image"
  content="https://ogimg.xyz/api/og?title=My+Page&template=gradient&key=YOUR_API_KEY" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />

URL Auto-Fetch

Pass a url parameter to automatically extract the title and description from any webpage:

GET /api/og?url=https://example.com&template=gradient

The API reads Open Graph meta tags first, then falls back to the HTML title and meta description. You can override either by also passing title or description explicitly.

Rate Limits & Errors

PlanMonthly LimitRate Limit
No API keyUnlimited (watermark)30/min per IP
Free50 images/month
Hobby ($4.90/mo)1,000 images/month
Pro ($9.90/mo)10,000 images/month
Lifetime ($149)10,000 images/month

Error Responses

StatusErrorDescription
401Invalid API keyThe API key is missing, invalid, or deactivated
402feature_lockedYou tried to use a feature not available on your plan (e.g. premium template on free)
429Monthly limit reached / Rate limitUpgrade your plan or wait for the next billing cycle

Integration Guides

Step-by-step tutorials for popular frameworks and platforms.

Ready to get started?

Create a free account and generate your first OG image in seconds.