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:
Authorization: Bearer YOUR_API_KEY
/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.
| Parameter | Type | Default | Plan | Description |
|---|---|---|---|---|
| title | string | "Hello World" | Free | Main heading text |
| description | string | — | Free | Subtitle / description text |
| template | string | "basic" | Free* | Template name (see list below) |
| pattern | string | "none" | Free* | Background pattern (see list below) |
| bgColor | string | Template default | Free | Background color (hex, e.g. #1a1a2e) |
| textColor | string | Template default | Hobby+ | Text color (hex) |
| accentColor | string | "#6366f1" | Hobby+ | Accent / highlight color (hex) |
| siteName | string | — | Free | Site name shown on some templates |
| author | string | — | Free | Author name (blog template) |
| date | string | — | Free | Date string (blog template, e.g. "Jan 15, 2025") |
| tags | string | — | Free | Comma-separated tags (e.g. "react,nextjs") |
| logo | URL | — | Hobby+ | URL to your logo image |
| width | number | 1200 | Hobby+ | Image width in px (100-2048) |
| height | number | 630 | Hobby+ | Image height in px (100-2048) |
| url | URL | — | Free | Auto-fetch title & description from this URL |
| key | string | — | — | API 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.
Background Patterns
10 background patterns to add texture. Free plan includes 3 (none, dots, grid).
Code Examples
curl "https://ogimg.xyz/api/og?title=My+Blog+Post&template=gradient" \ -H "Authorization: Bearer YOUR_API_KEY" \ --output og-image.png
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();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)// 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,
},
],
},
};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)
}<!-- 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
| Plan | Monthly Limit | Rate Limit |
|---|---|---|
| No API key | Unlimited (watermark) | 30/min per IP |
| Free | 50 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
| Status | Error | Description |
|---|---|---|
| 401 | Invalid API key | The API key is missing, invalid, or deactivated |
| 402 | feature_locked | You tried to use a feature not available on your plan (e.g. premium template on free) |
| 429 | Monthly limit reached / Rate limit | Upgrade your plan or wait for the next billing cycle |
Integration Guides
Step-by-step tutorials for popular frameworks and platforms.
Next.js OG Images
Add OG images to your Next.js app with generateMetadata
FrameworkReact OG Images
Use react-helmet or react-helmet-async for OG tags
FrameworkHTML Meta Tags
Add OG image meta tags to any HTML page
GuideWhat Is an OG Image?
Everything you need to know about Open Graph images
GuideOG Image Dimensions
Sizes for Twitter, Facebook, LinkedIn, and more
GuideDynamic OG Images
Generate unique images per page automatically
Ready to get started?
Create a free account and generate your first OG image in seconds.