Skip to content
reelspanDocs

Integrations

Pydantic AI

Connect a Pydantic AI agent to Reelspan's hosted MCP server with MCPToolset so it can publish, schedule and check posts on 22 social networks.

Pydantic AI connects agents to MCP servers as toolsets, so an agent can use Reelspan's hosted MCP server to publish, schedule and read results. There is no separate Reelspan package to install.

Install

pip install "pydantic-ai-slim[mcp,openai]"

Swap openai for the extra of the model provider you use.

API key

Create a key under Developers → API keys and export it with your model provider's key. Start with a test key (rs_test_…): every check runs, but nothing is posted.

export REELSPAN_API_KEY=rs_test_...
export OPENAI_API_KEY=sk-...

Example

This agent publishes a text post to the sandbox network, which needs no connected account, and then checks the result.

import asyncio
import os

from pydantic_ai import Agent
from pydantic_ai.mcp import MCPToolset

reelspan = MCPToolset(
    "https://api.reelspan.com/mcp",
    headers={"Authorization": f"Bearer {os.environ['REELSPAN_API_KEY']}"},
)
agent = Agent(
    "openai:gpt-6.1-sol",
    toolsets=[reelspan],
    instructions="You publish and check social media posts with the Reelspan tools.",
)


async def main():
    async with agent:
        result = await agent.run(
            "Publish 'Hello from my Pydantic AI agent' as a text post to the sandbox network for the profile my-brand, "
            "then check its status and tell me the result."
        )
        print(result.output)


asyncio.run(main())

Replace my-brand with one of your profiles (the agent can find them with list_profiles).

Notes

  • One key per customer. headers= also takes a function, called at the start of each run with the run context, so it can read each customer's key from deps.
  • Posting runs in the background. The publish tools return a request_id; the agent calls upload_status to read each network's result.
  • Media goes in as URLs. upload_video and upload_photos take public https URLs, not local files.
  • Going live: swap the test key for a live one (rs_live_…) and use real networks instead of sandbox.

The full tool list is on the MCP server page. Pydantic AI's own guide: pydantic.dev/docs/ai/mcp/client.

Something unclear or missing? Write to [email protected] and we’ll fix the page.