LangGraph Integration

Post to X from a
LangGraph agent

Give your LangGraph agent one tool and it can post, schedule, and thread on X. It calls the OpenTweet API, so there is no X developer account, no OAuth, and no per-post billing.

7-day free trial. No X developer account needed.

What your agent can do on X

Expose these as tools and the model decides when to use them inside your graph.

Post now

One tool call publishes a tweet immediately from inside your graph.

Schedule

Pass a time and the tweet is queued. Let the agent plan a whole week.

Threads

Send an array of tweets and OpenTweet posts a connected thread.

Media

Attach images or let OpenTweet generate media for the post.

Read analytics

Give the agent tools to read its own posting analytics and adjust.

No X API

No developer account, no OAuth flow, no token refresh to maintain.

The whole integration is one tool

Define a tool that POSTs to the OpenTweet API, bind it to your agent, and you are done. No X developer portal, no OAuth handshake.

import httpx
from langchain_core.tools import tool
from langgraph.prebuilt import create_react_agent
from langchain_openai import ChatOpenAI

@tool
def post_to_x(text: str) -> str:
    """Post a tweet to X (Twitter). Returns a confirmation."""
    r = httpx.post(
        "https://opentweet.io/api/v1/posts",
        headers={"Authorization": "Bearer ot_your_api_key"},
        json={"text": text, "publish_now": True},
        timeout=30,
    )
    r.raise_for_status()
    return "Posted to X"

agent = create_react_agent(ChatOpenAI(model="gpt-4o"), tools=[post_to_x])

agent.invoke({"messages": [("user", "Tweet that we just shipped v2.")]})

Prefer MCP? Point your agent at the OpenTweet MCP server and it gets all 43 tools automatically.

Perfect for

Social media agents

The LangChain social-media-agent template needs a posting backend. Drop OpenTweet in and skip the raw X API setup.

Research to post pipelines

A graph that gathers news, drafts a take, and posts it, all in one run with no human in the loop.

Multi-agent crews

A writer node drafts, an editor node approves, a poster node ships the tweet through OpenTweet.

Scheduled content bots

Let the agent plan and queue a week of posts, then walk away. OpenTweet handles the timing.

Frequently asked questions

How does a LangGraph agent post to Twitter?

You define a tool that makes one HTTP POST to the OpenTweet API and bind it to your agent or graph node. When the model decides to post, LangGraph calls the tool and the tweet goes live. No X developer account or OAuth code is involved.

Do I need the X (Twitter) API for this?

No. LangChain and LangGraph examples usually assume you hold raw X API credentials, a developer application, and OAuth. OpenTweet replaces all of that with a single bearer key, so your agent posts without touching the X API directly.

Can the agent schedule tweets and post threads, not just single tweets?

Yes. The same API accepts a schedule time, thread arrays, and media. You can expose separate tools for post now, schedule, and thread, or use the OpenTweet MCP server so the agent gets all 43 tools at once.

Does this work with LangChain agents too, not only LangGraph?

Yes. The tool is a standard LangChain tool, so it works in any LangChain agent, a LangGraph state machine, or LangChain's social-media-agent template. Nothing about it is LangGraph specific except where you wire it in.

How much does it cost to run?

OpenTweet is flat, with no per-post billing, unlike the pay-per-use X API. Pro is $11.99/month for plain posts. Posts with links are included on Advanced ($29/month, 10 a day) and Agency ($49/month, 20 a day), and any plan can add link credits.

Wire any agent or framework to X

LangGraph is one of many. Post to X from code, an MCP client, or any AI agent.

OpenTweet vs the X API

Post, schedule, and automate X without a developer account or the $200/mo minimum.

X DM outreach, human-approved

Find and qualify leads, AI-draft DMs, approve each one, and drip-send from your own account via API or MCP.

Post to X without an API

The clean, account-safe way to post to X from your code or an AI agent.

Twitter MCP Server

Give Claude, Cursor, and OpenClaw the ability to post to X. 43 tools included.

Developer docs

Quickstart, API keys, MCP setup, and the REST reference for posting to X from code or an agent.

Cross-posting reference

One call posts to X, Bluesky and LinkedIn. The platforms field, per-network results, and why a network gets skipped.

Social media API for AI agents

Three ways an agent can post to X, Bluesky and LinkedIn, and the trade-offs of each.

LinkedIn MCP server

Post and schedule to a LinkedIn profile from Claude or Cursor through the official LinkedIn API.

XMCP vs OpenTweet

X's official MCP server bills per API call and cannot schedule. Compare it with the flat-fee hosted MCP.

MCP for AI agents

Connect your AI client to X in under two minutes, no X developer account.

Developer API and keys

REST endpoints, one bearer key, and usage tracking. Build on OpenTweet.

OpenTweet for AI agents

The posting layer for autonomous agents and automations that live on X.

Build an AI Twitter persona

Give your AI agent its own X account. Setup, cadence, and the rules that keep it safe.

Best MCP servers for social media

The 2026 ranked list. How the hosted OpenTweet MCP compares with the official X MCP and others.

Cheapest way to post to X via code

Flat fee vs pay-per-use. Why the $0.20 per-link fee flips the math past ~145 link posts a month.

Give your agent a voice on X

Connect X, copy your key, and add the posting tool to your graph today.