Social Image Generator API
Generate Open Graph / Twitter preview images (1200×630 PNG or JPEG) from a title, subtitle and site name, with correct Vietnamese typography and themes.
The OG image API draws the picture shown when a link is shared on Facebook, Zalo, X, LinkedIn or Slack. Give it a title, an optional subtitle, a small tag (“Mới”, “Blog”…) and a site name; it lays them out on a 1200×630 canvas with a colour band and returns a PNG (or JPEG). The title takes the largest size that fits in four lines and long titles end with an ellipsis.
Text is rendered from the Be Vietnam Pro typeface, designed for Vietnamese, so stacked diacritics (ặ, ễ, ỗ) are positioned correctly, which many generic image services get wrong. Choose a theme (light, dark, brand), your own background, background2 (gradient), color and accent, align=center, and the size: og (1200×630), twitter (1200×675), linkedin, square (1080×1080) or story (1080×1920).
Use the URL directly in <meta property="og:image">: images are cacheable for a day, so social networks fetch them once.
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
title | query|body | string | yes | Main title (max 300 characters). | |
subtitle | query|body | string | no | Subtitle. | |
tag | query|body | string | no | Small label above the title. | |
site | query|body | string | no | Site / brand name at the bottom. | |
theme | query|body | string | no | light | light, dark or brand. |
size | query|body | string | no | og | og, twitter, linkedin, square, story. |
background | query|body | string | no | Background colour (hex); background2 for a gradient. | |
color | query|body | string | no | Text colour. | |
accent | query|body | string | no | Accent colour (band, tag). | |
align | query|body | string | no | left | left or center. |
format | query|body | string | no | png | png or jpeg. |
Example
curl "https://apibox.io.vn/v1/og-image?title=Bộ API cho lập trình viên Việt Nam&subtitle=VietQR, tỉnh thành, lịch âm&site=apibox.io.vn&tag=Mới" \
-H "Authorization: Bearer YOUR_API_KEY" \
-o outputconst res = await fetch('https://apibox.io.vn/v1/og-image?title=Bộ API cho lập trình viên Việt Nam&subtitle=VietQR, tỉnh thành, lịch âm&site=apibox.io.vn&tag=Mới', {
method: 'GET',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
},
});
const blob = await res.blob();import requests
res = requests.get(
"https://apibox.io.vn/v1/og-image?title=Bộ API cho lập trình viên Việt Nam&subtitle=VietQR, tỉnh thành, lịch âm&site=apibox.io.vn&tag=Mới",
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=30,
)
open("output", "wb").write(res.content)<?php
$ch = curl_init('https://apibox.io.vn/v1/og-image?title=Bộ API cho lập trình viên Việt Nam&subtitle=VietQR, tỉnh thành, lịch âm&site=apibox.io.vn&tag=Mới');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY'],
]);
$response = curl_exec($ch);
file_put_contents('output', $response);Response
binary image/png
Use cases
- og:image for every blog post and product page
- Share cards for events, job posts and announcements
- Thumbnails for Zalo and Facebook link previews
- Instagram / story covers from a headline
FAQ
How do I use it in my pages?
Put the API URL with your parameters in <meta property="og:image" content="…">, or generate the image once and store it.
Can I add a logo?
Not yet; use the site name and accent colour as a brand line.
Why PNG and not SVG?
Social networks only accept bitmap images (PNG, JPEG) for previews.
Related APIs
QR Code Generator
Generate QR codes as PNG or SVG with one GET request: URLs, text, WiFi logins, vCards, e-mail, SMS, phone and geo links. Custom colours, size and ECC.
|||Barcode Generator
Create Code 128 barcodes for labels, SKUs and shipping with a single request. SVG with human-readable text or PNG, custom height, width and colours.
▭Placeholder Image
Get placeholder images of any size for mockups and tests: /v1/placeholder/600x400.png. SVG with custom text and colours, or a solid-colour PNG.