Skip to content

Reddit and X data in the OpenAI Agents SDK

MCPServerStreamableHttp in the OpenAI Agents SDK connects an agent to ChatterAPI's hosted MCP server, with your key in a header. The agent can then search Reddit and X and read threads through tool calls.

MCP server URLhttps://api.chatterapi.com/mcp

What you get

  • Every live Reddit and X tool, listed for the agent by the server.
  • Tool results include credits, so you can stop a run when the balance drops.
  • The same key works for REST calls in the rest of your app.

Set it up

  1. Create an API key

    Sign in at chatterapi.com/signup with Google and create a key on the Keys page. You get 100 free credits. A ca_test_ key returns recorded samples for 0 credits, which helps while you set things up.

  2. Install the SDK

    Install it from PyPI.

    terminal
    pip install openai-agents
  3. Connect the server

    Pass the URL and header in params. The default request timeout is 5 seconds. Some Reddit reads take longer than that, so raise it.

    agent.py
    import asyncio, os
    from agents import Agent, Runner
    from agents.mcp import MCPServerStreamableHttp
    
    async def main():
        async with MCPServerStreamableHttp(
            name="ChatterAPI",
            params={
                "url": "https://api.chatterapi.com/mcp",
                "headers": {"Authorization": f"Bearer {os.environ['CHATTERAPI_KEY']}"},
                "timeout": 60,
            },
            client_session_timeout_seconds=60,
            cache_tools_list=True,
        ) as server:
            agent = Agent(name="Researcher", mcp_servers=[server])
            result = await Runner.run(agent, "Find recent tweets asking for a CRM recommendation.")
            print(result.final_output)
    
    asyncio.run(main())

The tool call it makes

For that prompt the agent calls x_search with arguments like these. The response is a real recorded call.

Try this prompt

Find recent tweets asking for a CRM recommendation.

{
  "method": "tools/call",
  "params": {
    "name": "x_search",
    "arguments": {
      "q": "\"crm recommendation\""
    }
  }
}
response, first 2 rows
{
  "data": [
    {
      "id": "2099495333231288346",
      "text": "meta ads: how important is the “connect to your crm” recommendation?\n\nthis essentially will tell meta if the lead was good or bad (ie converted), any experience how how is actually helps?\n\nthis particular client doesn’t …",
      "url": "https://x.com/HesomParhizkar/status/2099495333231288346",
      "createdAt": "2026-09-14T13:47:48.000Z",
      "lang": "en",
      "likes": 2,
      "retweets": 0,
      "replies": 2,
      "quotes": 0,
      "views": 138,
      "bookmarks": 0,
      "isReply": false,
      "inReplyToId": null,
      "conversationId": "2099495333231288346",
      "isRetweet": false,
      "quotedTweetId": null,
      "author": {
        "id": "35363135",
        "handle": "HesomParhizkar",
        "name": "Hesom",
        "bio": "Startup Founder/Executive, investor, nba fan",
        "followers": 584,
        "following": 2010,
        "tweets": null,
        "verified": false,
        "blueVerified": true,
        "canDm": true,
        "protected": null,
        "location": "Marietta, GA",
        "url": null,
        "avatarUrl": "https://pbs.twimg.com/profile_images/1871033188081942528/comvGkRg_normal.jpg",
        "createdAt": "2009-04-26T01:18:19.000Z"
      },
      "media": []
    },
    {
      "id": "2040879100261458222",
      "text": "Here's a live audit on what happens when buyers ask AI for a CRM recommendation. You can't miss it...",
      "url": "https://x.com/apoorvshrm/status/2040879100261458222",
      "createdAt": "2026-04-05T19:47:49.000Z",
      "lang": "en",
      "likes": 4,
      "retweets": 0,
      "replies": 1,
      "quotes": 0,
      "views": 145,
      "bookmarks": 0,
      "isReply": false,
      "inReplyToId": null,
      "conversationId": "2040879100261458222",
      "isRetweet": false,
      "quotedTweetId": "2040878095415304308",
      "author": {
        "id": "1459048370371137542",
        "handle": "apoorvshrm",
        "name": "Apoorv Sharma | SEO and GEO for B2B SaaS",
        "bio": "SEO + GEO for B2B SaaS. I help SaaS brands rank on Google and get recommended by Claude, Gemini, and Google AI.\nCo-Founder, DerivateX",
        "followers": 2316,
        "following": 519,
        "tweets": null,
        "verified": false,
        "blueVerified": true,
        "canDm": true,
        "protected": null,
        "location": "Bengaluru",
        "url": null,
        "avatarUrl": "https://pbs.twimg.com/profile_images/2069124654112149504/AWTErF4d_normal.jpg",
        "createdAt": "2021-11-12T06:40:23.000Z"
      },
      "media": []
    }
  ],
  "page": {
    "nextCursor": "AcWN…",
    "hasMore": true
  }
}

Recorded from a live call on . Long text is shortened and the cursor is cut. A live key is charged 3 credits for this call. A test key returns this same sample for 0 credits.

Limits worth knowing

  • MCPServerStreamableHttp takes url, headers and timeout in params, and cache_tools_list to skip listing tools on every run. source
  • The SDK also has a hosted MCP tool that the Responses API runs for you. In the SDK docs it sends an authorization value instead of custom headers, so with an API key the local client above is simpler. source

Last checked . Sources: OpenAI Agents SDK MCP docs.

Questions

Does it cost more through the OpenAI Agents SDK than through REST?
No. MCP and REST call the same tools, cost the same credits and draw from one balance.
Can I try it without spending credits?
Yes. Use a ca_test_ key. Every tool returns a recorded sample for 0 credits, whatever you ask.
Is ChatterAPI part of Reddit or X?
No. ChatterAPI is independent and not affiliated with Reddit, Inc. or X Corp.

What people build with it

Agent frameworks

Give your agent Reddit and X data

Sign up and get 100 free credits. No card required.