OG Pilot
astro og image

Astro OG image: static, build-time, or on-demand API

An Astro OG image is the preview file a crawler reads from og:image. This page compares three ways to ship an Astro open graph image: a static file in public/, a build-time endpoint in the Satori or astro-og-canvas style, and a dynamic OG image from a hosted API. Figures below come from the Astro docs, the astro-og-canvas README, the Satori README, and this app. Where a number is missing, the cell says so.

Static, build-time, and on-demand

Use the table when you are choosing how a dynamic OG image in Astro gets its bytes. A prerendered endpoint and a hosted API called from prerendered frontmatter both run during astro build. They differ in who draws the card, and in what you maintain afterward. Request-time rendering is a separate switch: prerender = false plus an adapter.

ApproachBuild time impactFreshness for dynamic / CMS contentSSR / adapterFonts / emojiCachingCost / maintenance
Static file in public/Astro copies public/ into the build untouched. The docs describe these files as unprocessed. There is no image render step for that file.The bytes change when you replace the file and deploy. A CMS edit does not update the file.No adapter. The default static output is enough.Whatever you exported from the design tool. Astro does not read or subset the file.The host serves the copied file. Social platforms cache the URL they fetched. This page does not publish their TTL. Change the file or the URL, then recheck the preview.No image API. You maintain the artwork. One shared card is a poor fit when every post needs its own title.
Build-time endpoint (Satori or astro-og-canvas)On a static site, Astro calls the endpoint at build time and writes a file. astro-og-canvas OGImageRoute exports getStaticPaths and GET, one image per key in pages. More entries means more images during astro build. The package caches renders in ./node_modules/.astro-og-canvas by default. Set cacheDir to false to disable that. No duration is published here.The image matches the pages object at build: getCollection(), a markdown glob, or any object you pass. A remote CMS edit shows up after a rebuild that includes that entry. prerender = false runs the endpoint on request instead, and that requires an adapter.A prerendered dynamic route uses getStaticPaths and does not need an adapter. An on-demand route skips getStaticPaths and needs an adapter. Official adapters include Node, Netlify, Vercel, and Cloudflare.Satori requires font data for any text. Formats are TTF, OTF, and WOFF. WOFF2 is not supported. Emoji and missing glyphs go through loadAdditionalAsset. For emoji, return an image data URL when the code is emoji. Satori returns SVG, so a PNG response rasterizes that SVG. astro-og-canvas takes font paths or URLs and a families stack so a later family covers a missing glyph. Its README does not document an emoji image callback. pnpm also installs canvaskit-wasm.astro-og-canvas cacheDir is a build cache, not a social-crawler cache. The emitted file stays static until the next build.You run the library. npm lists astro-og-canvas as MIT. This page does not quote a host's build-minute price. You maintain the endpoint and the font files.
On-demand API (OG Pilot)createImage in prerendered frontmatter runs during astro build and returns a CDN URL. The Astro process does not rasterize the card. createImage on an on-demand route runs when that route is requested, so the build does not call the API for that page.The card matches the signed claims: template, title, description, path, and the other documented fields. A URL baked into static HTML stays there until the next build. An on-demand page can sign again when CMS data changes. If iat is set, the image cache is valid for 24 hours from that timestamp. If iat is omitted, the cache does not expire on its own. A newer iat can serve the previous image with stale: true while a new render is queued.No adapter when the call runs at build time. An adapter is required when the layout must run on each request. Keep the API key off the client: Astro exposes only PUBLIC_ variables to client code. Do not prefix OG_PILOT_API_KEY with PUBLIC_.The documented JWT claims do not include a font file or an emoji parameter. You pass title, description, colors, logo_url, and image_url. Named templates render the card. image_type may be jpeg, png, webp, or gif. The JSON response reports width 1200 and height 630.Pass { iat: Date.now() } in the JavaScript SDK. The SDK converts milliseconds to seconds. Omit iat for a cache that does not expire on its own. Social crawlers still cache the URL they fetched. Recheck the public URL after the artwork changes.7-day trial, no card, 100 completed images in this app. The API accepts a trial after DNS TXT verification. A trial is not enough for MCP generate_og_image. API: 600 requests per minute and 60,000 per hour per key. MCP generation: 10 per hour. The plan catalog lists Starter at $5/month ($50/year, 10,000-image quota), Builder at $49/month ($99/year, 100,000-image quota), and Growth at $99/month ($199/year, unlimited image quota). A Stripe image_quota feature can replace the quota. The catalog has no per-image price.

Checked 2026-10-09. Sources: Astro project structure, Astro endpoints, Astro on-demand rendering, Astro environment variables, astro-og-canvas README, Satori, and the OG Pilot API docs. Pixel floors for the 1200×630 card are on the og:image size cheat sheet.

Which one to ship

public/

One designed card covers the site, and you will replace the file when the artwork changes. A blog where every post title should appear on the card outgrows this quickly.

Build-time endpoint

Every entry is known at build, from a content collection or markdown, and you want the PNG in the build output. You own the font files. Satori is JSX-to-SVG. astro-og-canvas is a CanvasKit route helper, and its README is the layout contract.

Hosted API

The same templates should work from Astro, Rails, or WordPress, or an agent should call MCP. The Astro build stores a CDN URL. It does not store a font pipeline.

A remote CMS that edits a title between deploys needs the HTML to be generated again. Rebuild the static site, or render that route on demand. Calling the API from prerendered frontmatter does not watch the CMS after the build finishes. The shorter copy-paste setup, without this comparison, stays on the Astro OG image generator page.

BaseHead meta tags with the OG Pilot API

Install og-pilot-js@^0.4.2, the JavaScript SDK version in the API docs. configure reads OG_PILOT_API_KEY and OG_PILOT_DOMAIN. createImage signs the JWT and returns the image URL. template defaults to page. Use blog_post on a post layout when you have an author and a date. Pass iat when you want the documented 24-hour cache window. The frontmatter runs on the server during the build, or on each request when the page sets prerender = false.

src/components/BaseHead.astro

npm install og-pilot-js@^0.4.2

---
// src/components/BaseHead.astro
import { configure, createImage } from "og-pilot-js"

interface Props {
  title: string
  description: string
}

const { title, description } = Astro.props

configure((config) => {
  config.apiKey = import.meta.env.OG_PILOT_API_KEY
  config.domain = import.meta.env.OG_PILOT_DOMAIN
})

const ogImage = await createImage(
  {
    template: "page",
    title,
    description,
    path: Astro.url.pathname,
  },
  { iat: Date.now() },
)
---
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="og:url" content={Astro.url.href} />
<meta property="og:image" content={ogImage} />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content={ogImage} />

Underlying HTTP call

POST https://ogpilot.com/api/v1/images
Content-Type: application/json
Accept: application/json

{"token":"YOUR_JWT_TOKEN"}

Required JWT claims: iss (verified domain), sub (API key prefix).
Optional: iat, template, title, description, path, logo_url, image_url,
bg_color, text_color, accent_color, image_type, quality, max_bytes.
image_type: jpeg, png, webp, or gif.
The JavaScript SDK signs this token. Prefer the SDK over a hand-rolled JWT.
Docs: https://ogpilot.com/docs

Put BaseHead in the layout <head>. The documented JSON response includes width 1200 and height 630. There is no width or height request field. After the tags are live, check the public URL in the Open Graph debugger. The same API from Next.js is on the Next.js OG image guide, and the longer Satori comparison is on the OG image API page.

MCP install for an agent

The remote server is https://ogpilot.com/mcp. Transport is Streamable HTTP. Auth is OAuth 2.1 with PKCE. The config file does not contain an API key. generate_og_image takes a public url and an optional style, and it needs an active plan and one credit. A trial can call the API after the domain is verified. It cannot call generate_og_image. debug_open_graph, compress_image, and extract_color_palette work on a guest connector session.

Remote MCP config

{
  "mcpServers": {
    "og-pilot": {
      "type": "streamable-http",
      "url": "https://ogpilot.com/mcp"
    }
  }
}

# Auth: OAuth 2.1 with PKCE. No API key in this file.
# Docs: https://ogpilot.com/docs/mcp

generate_og_image
{ "url": "https://example.com/blog/launch" }

Claude and ChatGPT do not read this file. Follow the connector steps on /docs/mcp. Full field lists stay on /docs.

How to choose an Astro OG image

  1. Use a file in public/ when one designed card covers the site.
  2. Prerender an endpoint with getStaticPaths when each content entry needs its own image at build time.
  3. Call the OG Pilot API from server-side layout frontmatter when the card should come from a hosted template.
  4. Render that route on demand, with an adapter, when CMS edits must change og:image without a full-site rebuild.
  5. Install the MCP server when an agent should call generate_og_image with the page URL.

Get an API key or install the MCP server

Pick public/ or a prerendered endpoint when the card lives entirely in the Astro repo. Get an API key when the preview should come from a hosted template, including from one-click generation while you are still wiring the layout. Install MCP when the next step is an agent with the page URL.

  • Get an API key

    Create an account, verify the domain with a DNS TXT record, and issue a signing key.

  • Install MCP

    Connect https://ogpilot.com/mcp so an agent can call generate_og_image.

  • API docs

    JWT claims, templates, the iat cache rule, and og-pilot-js.

  • Astro setup page

    The shorter layout sample, without the three-way comparison.

  • og:image size

    1200×630 and the platform floors this card is aimed at.

  • Open Graph debugger

    Confirm the tags on the public URL before a crawler caches them.

Astro OG image questions

What is an Astro OG image?

The file your layout puts in og:image. It can be a static file copied from public/, a file an endpoint writes at build time, or a CDN URL returned by a hosted API such as OG Pilot.

Does a static file in public/ add a render step to the Astro build?

No. Astro's project-structure docs say files in public/ are copied into the build untouched. The image is whatever you exported. A CMS edit does not update that file.

Do I need an adapter for a build-time OG endpoint?

A prerendered endpoint does not need an adapter. Astro calls it at build time, and getStaticPaths decides which files to write. Set prerender to false, or output to server, when the endpoint should run on request. That path needs an adapter. Official adapters include Node, Netlify, Vercel, and Cloudflare.

When should Astro call a hosted OG image API?

When you want a named template and a CDN URL, and you do not want to ship font files and a rasterizer inside the Astro build. og-pilot-js createImage signs the request from server-side frontmatter. On a static page the returned URL is baked in until the next build. An on-demand route can sign again when the page is requested.

Can an agent generate the card without waiting for the Astro build?

Yes. The remote MCP server is https://ogpilot.com/mcp, Streamable HTTP, OAuth 2.1 with PKCE. generate_og_image takes a public url and an optional style. It needs a signed-in account with an active plan and a credit. A trial is not enough. Setup is at /docs/mcp.

Will this page publish latency or price benchmarks?

No. This page does not publish a build duration or an API latency. The plan catalog lists Starter at $5/month ($50/year, 10,000-image quota), Builder at $49/month ($99/year, 100,000-image quota), and Growth at $99/month ($199/year, unlimited image quota). Those defaults are on /#pricing. A Stripe image_quota feature can replace the quota. The catalog has no per-image price. The 7-day trial includes 100 completed images and does not require a card.

Ship the Astro card from an API key or MCP

Keep a static file or a build-time endpoint when you want the PNG in the repo output. Use OG Pilot when the layout should store a CDN URL and an agent should be able to generate the same card.