API reference
A GET request to one endpoint returns a 1200×630 PNG.
Endpoint
GET /api/og
Returns image/png on success. Errors return JSON with an error field: 400 invalid parameters, 401 bad key, 429 quota or rate limit exceeded.
Parameters
| Param | Type | Default | Description |
|---|---|---|---|
| key | string | none | Your API key (og_…). Omit for watermarked, rate-limited demo renders. |
| template | gradient | minimal | split | terminal | quote | announce | link | cover | gradient | Which card layout to render. |
| title | string (≤ 200 chars) | Hello, world | Main headline. Font size auto-scales with length. |
| subtitle | string (≤ 300 chars) | none | Supporting line under the title. |
| site | string (≤ 100 chars) | none | Site or brand name shown in the footer of the card. |
| theme | dark | light | dark | Base color scheme (the terminal template is always dark). |
| accent | hex color | #6366f1 | Accent color. URL-encode the hash: %236366f1. |
| size | og | square | story | youtube | wide | og | Canvas the card is rendered at. See Sizes. Ignored with tpl, where the size belongs to the design. |
| exp | string | none | Slug of one of your experiments. Picks a design variant for this page and records that a card was served. See Experiments. |
| k | string (≤ 500 chars) | url, if given | Identifies the page under test, for exp. Must be a stable id, such as a post slug or database id, never the title. Defaults to the url value when you pass one. |
| url | https URL | none | Read this page and use its title, description, site name and image. Anything you pass explicitly wins. See Cards from a URL. |
| tpl | string | none | Slug of one of your own templates from the visual editor. Replaces template; every other parameter becomes a {{placeholder}} value. |
| v | string (≤ 32 chars) | none | Cache-busting token. Ignored when rendering; changing it is what forces social platforms to re-fetch. See Refreshing cached cards. |
| acct + sig | string | none | Signed-URL auth: your account ID plus an HMAC signature. An alternative to key. See Signed URLs. |
Use it in your HTML
<meta property="og:image" content="https://ogsmith.app/api/og?key=og_yourkey&template=split&title=My%20post&site=example.com&accent=%23f43f5e" /> <meta name="twitter:card" content="summary_large_image" />
Next.js example
export function generateMetadata({ params }) {
const og = new URL("https://ogsmith.app/api/og");
og.searchParams.set("key", process.env.OGSMITH_KEY);
og.searchParams.set("title", post.title);
og.searchParams.set("site", "example.com");
return { openGraph: { images: [og.toString()] } };
}Account defaults
Set default template, theme, accent, and site values in the dashboard (Brand defaults). They apply to authenticated renders whenever the parameter is omitted, so a URL can be as short as /api/og?key=…&title=Hello. Parameters in the URL always override defaults. You can create up to 10 named API keys and revoke each one separately. The dashboard shows render counts per key. On paid plans, an uploaded logo (dashboard → Brand defaults) renders on every card next to the site name.
More in the docs
- Signed URLsSign each OGsmith image URL with your account secret instead of putting your API key in the markup.
- SizesRender the same card at 1200×630, square, story, YouTube and wide sizes with one parameter.
- Check an existing linkSee what X, LinkedIn, Slack, WhatsApp and other platforms will show for a link, and what is wrong with its Open Graph tags.
- Cards from a URLPoint OGsmith at a page and it builds the card from the page's own title, description and image.
- Your own templatesDesign your own card layouts in the visual editor, with your fonts and images, and render them by name.
- ExperimentsA/B test card designs across your pages and read the result with a significance test.
- Refreshing cached cardsMake X, Slack, Discord and WhatsApp show your new card when a link is shared again, even after they cached the old one.
- BatchesRender many cards at once and download them as a zip.
- WebhooksReceive a signed POST when a batch finishes or you near your quota, and verify that it came from OGsmith.
- Usage, quotas and keysHow to check usage from the API, how quotas and caching work, and how to look after your API key.