ThumbAPI logoThumbAPI

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

generate-x-image.sh
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:

ContextSizeAspectThumbAPI format
In-post image (attached media)1200×67516:9x
Link card (summary_large_image)1200×6301.91:1blogpost 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.

  1. POST your title with format: "x" and optional flags for category, style, photo, or logo overlay.
  2. The layout is selected from the format and a set of title heuristics — same deterministic pipeline as every other format on ThumbAPI.
  3. 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 via photoImage (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 via logoImage (max 1MB) or save a Logo asset. Combine with usePhoto for 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:

  1. Generate the image: POST to /v1/generate with format: "x".
  2. Decode the base64 from response.image into binary bytes.
  3. Upload to X via POST media/upload (X API v1.1) or the v2 media upload endpoint. You get back a media_id.
  4. Post the tweet via POST /2/tweets with the media.media_ids field 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.

PlanCredits / monthPrice
Free50$0
Creator750$19/month
Pro2,500$49/month
Business10,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 Free