Gemini + PostNinja

Schedule Social Media Posts with Gemini

Give Gemini a social media team. Through the Gemini API, a Gemini agent can use PostNinja's MCP tools to write posts for every platform, schedule them and check how they did. Prefer the terminal? Gemini CLI connects in one command.

  • 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 Gemini?

  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 Gemini

    In the Gemini app, add PostNinja as a custom app and sign in. Building your own agent? Pass PostNinja to the Gemini API as an MCP server instead (code below).

    1. On gemini.google.com, open Settings → Connected Apps → Custom apps.
    2. Click Add a custom app and paste the server URL from the first box below.
    3. Log in to PostNinja when asked and click Allow.
    Server URL for the Gemini app
    https://postninja.app/api/mcp
    Interactions API (Antigravity agent)
    curl "https://generativelanguage.googleapis.com/v1beta/interactions" \
      -H "x-goog-api-key: $GEMINI_API_KEY" -H "Content-Type: application/json" \
      -d '{
        "agent": "antigravity-preview-09-2026",
        "environment": "remote",
        "input": "Schedule a post about our launch for tomorrow 9am on X and Threads",
        "tools": [{
          "type": "mcp_server",
          "name": "postninja",
          "url": "https://postninja.app/api/mcp",
          "headers": { "Authorization": "Bearer pn_YOUR_KEY" }
        }]
      }'
    Python (google-genai + mcp)
    import asyncio, os
    from google import genai
    from mcp import ClientSession
    from mcp.client.streamable_http import streamablehttp_client
    
    client = genai.Client()
    
    async def main():
        headers = {"Authorization": f"Bearer {os.environ['POSTNINJA_API_KEY']}"}
        async with streamablehttp_client("https://postninja.app/api/mcp", headers=headers) as (read, write, _):
            async with ClientSession(read, write) as session:
                await session.initialize()
                response = await client.aio.models.generate_content(
                    model="gemini-flash-latest",
                    contents="Schedule a post about our launch for tomorrow 9am on X",
                    config=genai.types.GenerateContentConfig(tools=[session]),
                )
                print(response.text)
    
    asyncio.run(main())

    Replace pn_YOUR_KEY with a key from Settings → API.

    MCP in the Interactions API is in preview, and the SDK's MCP support is experimental, so details may change.

    Custom apps in the Gemini app are for personal Google accounts, 18 and over, in the US, in English, with Keep Activity on.

  3. 3

    Just ask

    Gemini finds the PostNinja tools on its own. Try:

    • “Schedule a post about our launch for tomorrow at 9am on X and Threads.”
    • “Write a week of Instagram captions for these product photos and save them as drafts.”
    • “Which of my posts failed this week?”

Tools

What can Gemini 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 Gemini can post to any of them, and PostNinja publishes at the time you set.

FAQ

Gemini and PostNinja questions

Can I add PostNinja to the Gemini app?

Yes, as a custom app: Settings → Connected Apps → Custom apps → Add a custom app, then sign in with your PostNinja account. Google currently limits custom apps to personal accounts in the US.

Is there a simpler way than writing code?

Yes: Gemini CLI connects with one command. See the Gemini CLI setup guide.

Does Gemini post without asking me?

That depends on Gemini'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 Gemini 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 Gemini run your social media.

Connect Gemini to PostNinja in a couple of minutes. Plans from $15 a month.