OpenAI Agents SDK Integration

Post to X from the
OpenAI Agents SDK

Add one function tool, or connect the OpenTweet MCP server, and your agent can post, schedule, and thread on X. No X developer account, no OAuth, no per-post billing.

Get your API key

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

What your agent can do on X

Add them as function tools, or get all of them at once through MCP.

Post now

One function tool call publishes a tweet immediately.

Schedule

Pass a time and the agent queues the post for later.

Threads

Send an array of tweets to publish a connected thread.

MCP native

Skip tool code entirely and connect the OpenTweet MCP server.

Analytics

Expose tools so the agent reads its own results and adapts.

No X API

No developer account, no OAuth, no token refresh to build.

One function tool and you are posting

Decorate a function with function_tool, pass it to your Agent, and the model posts to X when it decides to. No X developer portal, no OAuth handshake.

import httpx
from agents import Agent, Runner, function_tool

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

agent = Agent(name="Poster", instructions="Post concise tweets.", tools=[post_to_x])

Runner.run_sync(agent, "Tweet that our API is now live.")

Prefer MCP? The SDK supports it natively. Point it at the OpenTweet MCP server for all 30 tools.

Perfect for

Autonomous posting agents

A single agent that researches, drafts, and posts to X in one run with no human step.

Handoff workflows

Use SDK handoffs so a writer agent passes an approved draft to a poster agent that ships it.

Support and ops updates

An agent posts status updates or incident notes to X the moment they happen.

Migrating from Swarm

Bring your Swarm tools over unchanged and let the Agents SDK run them in production.

Frequently asked questions

How does an OpenAI Agents SDK agent post to Twitter?

Wrap a call to the OpenTweet API in a function tool and pass it to your Agent. The model calls the tool when it decides to post, and the tweet goes live. There is no X developer account or OAuth involved.

Can I use MCP instead of a function tool?

Yes. The OpenAI Agents SDK supports MCP servers natively. Point it at the OpenTweet MCP server and your agent gets all 30 posting, scheduling, and analytics tools without writing any tool code.

Do I need the X (Twitter) API?

No. OpenTweet replaces the X developer account, OAuth, and token management with a single bearer key. Your agent posts to X through OpenTweet, not through the raw X API.

Does this work with the old Swarm framework?

The OpenAI Agents SDK is the production successor to Swarm. The same function tool pattern applies. If you are still on Swarm, migrating the tool over is a copy and paste.

What does it cost?

OpenTweet is a flat $11.99/month and absorbs the underlying X posting cost at normal volumes, with no per-post charge and no link-post surcharge, unlike the pay-per-use X API.

Ship an agent that posts to X

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

Start your 7-day free trial