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.

Get your API key

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 30 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 30 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 a flat $11.99/month and absorbs the underlying X posting cost at normal volumes. There is no per-post charge and no surprise link-post surcharge, unlike pay-per-use X API pricing.

Give your agent a voice on X

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

Start your 7-day free trial