OG Image Templates
Soku can render dynamic Open Graph (OG) images from your templates via the API. OG images are the preview graphics that appear when a URL is shared on social media, in messaging apps, or in search results. Instead of creating a static image for every page, you can use Soku to generate unique, branded OG images on the fly from a single template.How It Works
- Design a template in the Soku template editor with dynamic parameters for the values that change per page (title, author, background image, etc.).
- Call the Templates API with the template slug and a config object containing the dynamic values.
- Soku renders the template as a PNG image and stores it in cloud storage.
- A hosted URL is returned that you can use as your page’s
og:imagemeta tag value.
API Endpoint
POSThttps://api.mysoku.io/v1/templates
Authentication
Include your API key in the request header:You can generate and manage API keys from Settings > API Keys in your Soku dashboard. See API Key Management for details.
Request Body
Example Request
Response
A successful response returns the hosted URL of the rendered image:The alias endpoint
POST /v1/media/render-og provides identical functionality. Both endpoints accept the same request body and return the same response format.Using the Rendered URL as an OG Image
Once you have the rendered image URL, set it as theog:image meta tag on your web page:
Practical Examples
Blog Post OG Images
Generate a unique OG image for each blog post on your site. In your server-side rendering or build step, call the Soku API with the post’s title and author:Product Page OG Images
For an e-commerce site, generate OG images that show the product name, price, and a product photo:Combining Template Rendering with Post Publishing
You can render a template and immediately use the output to create a social media post, all through the API:Designing Templates for OG Images
When creating a template specifically for OG image use, keep these guidelines in mind:Recommended Dimensions
The standard OG image size is 1200 x 630 pixels. This works well across most social media platforms and messaging apps. Set your template canvas to these dimensions.Design Tips
- Keep text large and readable. OG images are often displayed at small sizes in link previews. Use a minimum font size of 36px for titles and 24px for secondary text.
- Use high contrast. Make sure text is clearly readable against the background. A semi-transparent overlay between a background image and text helps significantly.
- Leave margins. Some platforms crop OG images slightly. Keep important content at least 60px from the edges.
- Limit the amount of text. OG images work best with a short title and optionally an author name or tagline. Avoid paragraphs of text.
- Test across platforms. Different social networks display OG images at different aspect ratios and sizes. Test your output on X (Twitter), Facebook, LinkedIn, and messaging apps like Slack and iMessage.
Template Layout Example
A common OG image template layout:- Background — Full-canvas rectangle with your brand color, or a dynamic background image.
- Overlay — A semi-transparent rectangle (e.g., black at 50% opacity) to ensure text readability.
- Logo — Your brand logo in one corner (top-left or bottom-left).
- Title — A large
{{title}}text element, centered or left-aligned. - Author — A smaller
{{author}}text element below the title.
Available Template Slugs
Any template you create in the Soku template editor is available via its slug. You can find the slug for each template on the template detail page or in the template catalog. Common built-in template slugs:
Custom templates you create are also available via their slug immediately after saving.
Rate Limits
Template rendering requests are rate limited to 20 requests per minute per API key. If you exceed this limit, the API returns a429 Too Many Requests response.