OpenAI Agents SDK + PostNinja

Add Social Media Posting to Agents Built with the OpenAI Agents SDK

Building a marketing agent? Point the OpenAI Agents SDK at PostNinja's MCP server and your agent can list accounts, schedule posts and check results across 7 platforms, without you writing a single platform integration.

  • Connect once with an API key
  • Draft, schedule and publish by asking
  • 7 platforms: X, Instagram, TikTok, Facebook and more

Setup

How do I connect PostNinja to OpenAI Agents SDK?

  1. 1

    Create an API key

    In PostNinja, go to Settings → API and create a key. It starts with pn_ and is shown once, so copy it somewhere safe.

  2. 2

    Add PostNinja to OpenAI Agents SDK

    Install openai-agents, set POSTNINJA_API_KEY, and connect over Streamable HTTP:

    Python
    import os
    from agents import Agent, Runner
    from agents.mcp import MCPServerStreamableHttp
    
    async with MCPServerStreamableHttp(
        name="PostNinja",
        params={
            "url": "https://postninja.app/api/mcp",
            "headers": {"Authorization": f"Bearer {os.environ['POSTNINJA_API_KEY']}"},
        },
        cache_tools_list=True,
    ) as postninja:
        agent = Agent(name="Social", instructions="You schedule social posts.", mcp_servers=[postninja])
        result = await Runner.run(agent, "Schedule a post about our launch for tomorrow 9am on X.")
  3. 3

    Just ask

    OpenAI Agents SDK finds the PostNinja tools on its own. Try:

    • “Schedule a post about our launch for tomorrow at 9am on X.”
    • “Write a Facebook version of this announcement and post it now.”
    • “Which posts failed this week?”

Tools

What can OpenAI Agents SDK do with PostNinja?

Write and schedule

Drafts posts, gives each platform its own text, and schedules them for any date and time.

Threads and Stories

Builds multi-post X threads and posts photos or videos as Instagram Stories.

Check what's planned

Lists upcoming posts, drafts and what went out, with links to the live posts.

Fix and reschedule

Moves, edits or deletes drafts and scheduled posts when plans change.

Add images

Uploads images to attach to posts. Larger files and video go through the REST API.

Spot failures

Reads each account's status and error, so it can tell you what didn't go out and why.

One connection, seven platforms

Connect your accounts in PostNinja once. From then on OpenAI Agents SDK can post to any of them, and PostNinja publishes at the time you set.

FAQ

OpenAI Agents SDK and PostNinja questions

Do I need a separate integration for each social network?

No. PostNinja handles the platform APIs, logins, media uploads and rate limits. Your agent only talks to one MCP server.

Does OpenAI Agents SDK post without asking me?

That depends on OpenAI Agents SDK's own settings; most ask before each tool call. If you'd rather review everything, ask it to save posts as drafts, then schedule them from the PostNinja calendar.

Is my API key safe?

PostNinja only stores a hash of each key and shows its first characters so you can tell keys apart. A key works for one workspace, and you can revoke it any time under Settings → API.

Which platforms can OpenAI Agents SDK post to?

Every account you've connected: X, Instagram, Threads, Facebook Pages, TikTok, YouTube Shorts and Pinterest.

Do posts scheduled by an AI agent cost extra?

No. They're ordinary posts on your plan. As always, X posts use credits (10 each, 80 with a link) because X charges for every post; other platforms are unlimited.

Works with other AI agents too

Let OpenAI Agents SDK run your social media.

Connect OpenAI Agents SDK to PostNinja in a couple of minutes. Plans from $15 a month.