X (Twitter) Image API — Generate Post Images From Any Title
ThumbAPI generates 1200×675 (16:9) images for X (Twitter) posts from any title. One REST call returns a production-ready image you can attach directly to a tweet — no design tool, no template, no manual crop.
Threads that lead with an image outperform text-only posts in feed. The bottleneck is making one for every post. ThumbAPI replaces that work with a single HTTP POST: send the title, get back a base64 WebP sized to the X player aspect ratio.
Quick start
curl -X POST https://api.thumbapi.dev/v1/generate \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "5 patterns I learned shipping a SaaS solo",
"format": "x"
}'X Image Sizes — Post vs Link Card
X renders images at two different aspect ratios depending on context. Pick the right one or your image gets cropped:
| Context | Size | Aspect | ThumbAPI format |
|---|---|---|---|
| In-post image (attached media) | 1200×675 | 16:9 | x |
| Link card (summary_large_image) | 1200×630 | 1.91:1 | blogpost → OG Image API |
This page covers in-post images — the media you attach when composing a tweet. For link cards that render when a URL is pasted into a tweet, generate with format: "blogpost" and add a Twitter Card meta tag pointing to it (see the OG Image API guide).
How It Works
Three steps. No SDK, no polling — the image is returned inline in the same HTTP response.
- POST your title with
format: "x"and optional flags for category, style, photo, or logo overlay. - The layout is selected from the format and a set of title heuristics — same deterministic pipeline as every other format on ThumbAPI.
- Receive a 1200×675 base64 image in the JSON response. Save it to disk, upload directly to X via the X API, or push it into a scheduling tool.
Three style options:
- Faceless (default, no flags) — text-and-graphic design, no people. Best for opinion threads, tutorials, and tech/SaaS commentary.
- Personalized (
usePhoto: true) — includes your face or a photo. Pass inline viaphotoImage(max 2MB) or save a Personal Photo asset and just toggle the flag. Good for personal brands and creator accounts. - Branded (
useLogo: true) — your company or product logo overlaid on the image. Pass vialogoImage(max 1MB) or save a Logo asset. Combine withusePhotofor creator-brand posts.
Posting to X Automatically
ThumbAPI returns the image as base64 — decode it and pass straight to X's media upload, then attach to a tweet:
- Generate the image: POST to
/v1/generatewithformat: "x". - Decode the base64 from
response.imageinto binary bytes. - Upload to X via
POST media/upload(X API v1.1) or the v2 media upload endpoint. You get back amedia_id. - Post the tweet via
POST /2/tweetswith themedia.media_idsfield set.
Prefer no-code? Use Zapier, Make.com, or n8n — every one of them has an official X / Twitter node that accepts a base64 or binary image and posts it automatically.
Who Uses This
Indie hackers & builders
You ship in public and post 2–5 times a day. Custom images per post double engagement but kill your time. One API call generates the image while you stay in code.
B2B & SaaS marketing
Threads, product updates, launch announcements — every X post needs a visual. ThumbAPI fits into your content scheduler and generates branded images at publish time.
Newsletter operators
Promoting each issue on X needs a custom 16:9. Pull the title from your CMS, call ThumbAPI, attach to a scheduled tweet — all automated.
Social media tools
Building a scheduler, AI writer, or content tool? Add "auto image" as a feature for your users. One integration covers X, LinkedIn, Instagram, and YouTube formats.
Pricing
Pricing is metered in credits. A standard 1K X image costs 10 credits; add-ons (saved photo, saved logo, custom reference set) add +2 each; a 2K (hd) render costs 20 credits instead of 10.
| Plan | Credits / month | Price |
|---|---|---|
| Free | 50 | $0 |
| Creator | 750 | $19/month |
| Pro | 2,500 | $49/month |
| Business | 10,000 | $199/month |
All plans include every format and style. Free-tier output carries a small ThumbAPI watermark — paid plans (Creator and up) return watermark-free images. See full pricing details.
FAQ
What size should X (Twitter) post images be?
X recommends 16:9 for in-post media — the player and feed display them edge-to-edge without cropping. ThumbAPI generates 1200×675 (16:9) when you set format: "x". For link cards, X renders summary_large_image at 1200×630 — use format: "blogpost" for that case (see the OG Image API guide).
How is this different from the OG Image API?
OG images are link previews — they appear when a URL is pasted into a post, rendered as a card. The X (Twitter) Image API generates images you attach directly to a tweet (1200×675, 16:9 native ratio). One is for shared links, the other for in-post media.
Can I auto-post the image to X?
Yes. Decode the base64 from the response, upload via X's media endpoint, then attach to a tweet via the X API. The full flow takes about a dozen lines of code, or zero lines if you go through Zapier, Make.com, or n8n.
Can I include my face or logo on the image?
Yes. Set usePhoto: true for a personal photo overlay, useLogo: true for a brand logo overlay, or both at once. Pass assets inline (photoImage, logoImage) or save them once via custom assets.
How long does generation take?
Typical end-to-end latency is 15–25 seconds. The image is returned in the same HTTP response — no polling, no webhook for basic use.
Start generating X images via API — free tier, no credit card
Try It for FreeRelated Pages
All formats — YouTube, OG, blog covers, Instagram, X, LinkedIn — in one API.
LinkedIn Post Image API1200×627 — LinkedIn post images and article banners.
OG Image API1200×630 — Twitter/X link cards, LinkedIn link previews, Slack/Discord.
YouTube Thumbnail API1280×720 video thumbnails — faceless, personalized, or branded.
API DocumentationEndpoint reference, all parameters, authentication, errors.