Post to X from Codex

X charges per API request, so an unattended loop on X is the one place where a runaway agent costs real money, and where the 13× link premium is worth encoding as a rule.

Hermoso is a marketing MCP server: 922+ tools over one OAuth’d endpoint that let an agent research the ads already running in a market, generate finished image and video ads, publish them, and build the paid campaigns behind them. Codex reaches all of it through one connection. This page covers one slice of that: what Codex can actually do on X, and what X will not let it do.

Connect Hermoso to Codex

  1. One command, and no key.
    codex plugin marketplace add hermoso-ai/hermoso && codex plugin add hermoso@hermoso
    Codex reads the marketplace file in Hermoso’s public repository and installs its five skills (research, ad-from-brand, generate, product-photoshoot and marketing). The skills run the hermoso command through npx, so no tool list is loaded into your sessions and nothing costs context until a command runs.
  2. Sign in once.
    npx -y hermoso auth login
    It opens a browser sign-in and stores an owner-only credential in ~/.hermoso/config.json. No browser on that machine, say CI or a container? Create a key under MCP & CLI → Terminal & API keys and run npx -y hermoso auth login --token hmk_…. A key carries real spend authority, so treat it like a password.
  3. Optional: the MCP server as well.
    codex mcp add hermoso -- npx -y hermoso mcp
    That writes the server into ~/.codex/config.toml and reads the same stored credential, so no key goes in the file. Prefer the hosted endpoint? codex mcp add hermoso --url https://app.hermoso.ai/mcp, then codex mcp login hermoso for the OAuth sign-in. The skills reach every tool without either.
  4. Ask Codex for something. “Pull my three closest competitors’ longest-running ads and remix the best hook into a 9:16 video,” or “post this render to the channel.” The agent picks the tools; you approve the spend.

Codex keeps MCP servers in ~/.codex/config.toml, or .codex/config.toml in a trusted project, and that file is TOML, not JSON: a copied mcpServers block will not load, and a hand-written entry is [mcp_servers.hermoso] with command = "npx" and args = ["-y", "hermoso", "mcp"]. The trailing mcp is load-bearing: npx -y hermoso with no subcommand prints help and exits. Codex reads plugin marketplaces in the same .claude-plugin layout Claude Code uses, which is why one repository installs in both.

Then connect X itself, once, under Settings → Connectors in Hermoso. That is an OAuth consent screen, so it is the one step that needs a browser. Everything after it is a tool call.

The X tools Codex gets

  • post_to_x: posts text, an image or a video with alt text, a whole thread, a reply, a quote post or a poll, and can restrict who is allowed to reply.
  • post_x_article: publishes a long-form Article. Write it in Markdown and the headings, lists, quotes, links, code blocks and tables all carry across.
  • edit_x_post: rewrites a post you have already published, inside the hour X allows.
  • schedule_post: queues it on the shared calendar.
  • x_post_metrics: the public counts on a post.
  • x_post_insights: advertiser-grade numbers for the last 28 hours only: impressions, link clicks, profile visits, video views and completion quartiles.
  • x_post_insights_historical: the same numbers over any date range, up to 25 posts at a time. This is the one for “how did last month go”.
  • x_mentions: who is talking about the brand.
  • delete_x_post: removes a post.

X is the only connector that costs money per call, and the numbers are published rather than hidden. Meta, TikTok, LinkedIn, YouTube, Threads and Drive cost nothing per request; X charges us, so those calls bill a small number of credits each. A plain post is priced at $0.015 per request and a post containing a link at $0.200, roughly 13× more. Deletes, reads and the alt-text metadata write each carry their own price, and insights bill per post returned. Link detection deliberately errs toward assuming a link is present, because guessing wrong the other way costs us 13×. The practical consequence: on X, one good post beats five, and your agent is quoted the price before it posts. Length is the posting account’s, not a flat 280. Hermoso reads the account’s own X subscription and sends up to 25,000 characters where Premium allows it, so a long post goes out whole rather than coming back refused, and nothing is ever truncated. That happens to be the cheap shape too: one long post is a single billed X call where the same words split across five posts are five. X Premium also unlocks two things Hermoso publishes for you: a long-form Article, written in Markdown with its headings, lists, quotes, code blocks and tables intact, and an edit to a post you have already published, inside the hour X allows.

X limits worth knowing before you automate anything

TextLength is the posting account’s: 280 characters ordinarily, up to 25,000 with X Premium. Hermoso reads the subscription from X, so a long post goes out whole. Nothing is ever truncated. It is enforced when the post is created or queued, so an overlong post is refused while you are still there to fix it instead of being silently cut on the way out.
VisibilityPublic only. A post on X is public the moment it exists. The API has no draft and no unlisted post. Protected accounts exist, but that is an account-wide setting Hermoso neither reads nor controls, not a per-post choice.
CarouselRefused, by name, for a specific reason. “X has no swipeable carousel.” Its API attaches up to 4 media to a post and they render as a grid, every image visible at once with nothing to swipe to, so a numbered “1/6 · SWIPE” slide deck cannot be published there as intended. The refusal says what to do instead: “Post the single strongest slide to X, or drop X from this post.” A deck that instructs the reader to swipe, published as a grid, is worse than not publishing it.
Which accountNone. X publishes to the connected account.

Try it in Codex

Ask for it in ordinary language. These are plain sentences, not a DSL:

“Non-interactive: post one X update per release, under 280 characters, with the link in that single post, and log the billed cost.”

That walks get_brand → generate_text → post_to_x → x_post_insights_historical. Interactively Codex shows the call before it runs it. Non-interactively there is nobody to ask, which is worth designing around on any step that publishes or spends.

Codex on X: the part that bites

Budget this one deliberately. Every post, delete and read is a billed request, insights bill per post returned, and a post carrying a link is priced at roughly 13× a plain one. For an unattended job that means: one post per event rather than a thread, one link rather than several, and a cap on how often the job may run. The character limit is a clean refusal, so a failing job fails loudly rather than posting something half-said.

For unattended runs, prefer the hermoso CLI with --json over the full tool manifest. It is far cheaper in context and easier to assert on.

Research X before you post

There is no X ad library to search. X research here is your own account: mentions, post metrics and the historical advertiser numbers. Everything else in the research surface is unaffected: the Meta, Google and LinkedIn ad libraries, and organic TikTok, Instagram, YouTube, Reddit and Threads.

The paid half

X Ads landed in August 2026, so X is now both halves. The X Ads API is a separate product on a separate host with its own OAuth 1.0a signing, which is why it arrived after the rest. Hermoso now builds the whole promoted-post tree on it: campaign, line item (X’s name for an ad group), promoted tweet, targeting, budgets, status and reporting. An X ad promotes a post, so the creative is a post, the same one Hermoso publishes organically. The switch that arms real money refuses to run without an explicit confirmation, exactly as on the other eleven platforms. One thing to know before you plan a budget: X grants Ads API access per ad account rather than per app, so there is no OAuth button for it: you add Hermoso’s X user to your ad account at business.x.com → Account access, and it appears in list_x_ads_accounts with the permission level X gave it.

What Codex cannot do on its own

An agent with a budget is only useful if the blast radius is bounded, so the fence is in the server rather than in a prompt. Every ad campaign, ad set, ad group and ad is created paused, and the status switches that arm real money refuse to run without an explicit confirmation flag. Every render is quoted first (hermoso_capabilities publishes each model’s exact credit cost before anything spends). Credits are reserved before the first provider call and settled at the exact cost afterwards, so a failed dispatch refunds rather than leaving you billed for nothing. Deletes are confirm-gated too, and every campaign tree is read back from the ad platform before your agent tells you what it built.

One step is deliberately not headless: linking an account is an OAuth consent screen, so you connect the channel once in a browser. Everything after that is a tool call.

The rest of the matrix

From Codex, post to: Facebook · Instagram · Threads · TikTok · YouTube · LinkedIn · Pinterest · Bluesky · Telegram. Or see everything Codex can publish to.

Post to X from: Claude · ChatGPT · Claude Code · Cursor · Cline · OpenClaw · Grok Bot · Hermes · Gemini CLI · Perplexity · Le Chat · Claude Cowork · Perplexity Computer · Paperclip · Ads from the command line

Frequently asked questions

Can Codex post to X?

Yes, with Hermoso's Codex plugin. Run codex plugin marketplace add hermoso-ai/hermoso && codex plugin add hermoso@hermoso, which installs Hermoso's skills, then sign in once with npx -y hermoso auth login. The sign-in opens a browser and stores the credential itself, so there is no key to create and none to paste. For the MCP server as well, run codex mcp add hermoso -- npx -y hermoso mcp. Codex then has 922+ tools, including the ones that publish to X, plus the ones that research the ads already running in your market and render the creative in the first place.

How do I connect X to Codex?

Two steps, once each. Run codex plugin marketplace add hermoso-ai/hermoso && codex plugin add hermoso@hermoso, which installs Hermoso's skills, then sign in once with npx -y hermoso auth login. The sign-in opens a browser and stores the credential itself, so there is no key to create and none to paste. For the MCP server as well, run codex mcp add hermoso -- npx -y hermoso mcp. Then connect X inside Hermoso under Settings → Connectors, which is an OAuth consent screen in a browser. After that Codex publishes to X as an ordinary tool call.

Can Codex post a carousel to X?

No. X’s API attaches up to four media to a post and they render as a grid, with every image visible at once and nothing to swipe to, so a numbered slide deck cannot be published there as intended. Codex calls the same publish tool either way, and a channel that cannot carry a carousel is refused with the real reason attached.

What does it cost to post to X from Codex?

X is the only connector that bills credits per call, because X charges per API request: roughly $0.015 for a post and $0.200 for a post containing a link, about 13 times more. Your agent is quoted the price before it posts. Plans are $29, $69 and $149 a month for 1,200, 3,000 and 7,000 credits, and every feature is on every plan including Free. The only exception is enterprise SSO.

Does Codex need my X password?

No. You connect X to Hermoso once through an OAuth consent screen in a browser, and Codex then reaches it as a tool call. Linking an account is the one step that is not headless; nothing after it needs a password, and no credential is ever handed to the model.

Can Codex schedule a X post for later?

Yes. schedule_post queues it on one calendar shared with every other channel, with a per-channel caption if the copy should differ, and list_scheduled and cancel_scheduled read and pull it back. X is one of the eleven channels that queue.

Start free with 30 credits at signup and 250+ more to earn. Every feature is on every plan. Credits are spent only on AI models and Ad Spy research; posting, scheduling, ads management and analytics are free.

Start free →   See pricing