Skip to main content
X Tool enables agents to post content, reply to posts, create quote posts, manage polls, upload media, and interact with X (formerly Twitter) using the official X API v2.
The user drafts a post; the agent publishes or reads timelines through the X tool.

Quick Start

Get started with X Tool in three simple steps.
1

Simple Post

2

Function Helper

3

Agent Usage


Installation

Install the required packages to get started with X Tool.

How It Works

X Tool supports three authentication modes for different use cases.
OAuth 2.0 app-only bearer tokens cannot post content. Use OAuth 1.0a for posting capabilities.
1

Create X Developer Account

Visit developer.x.com and create a developer account.
2

Create App and Get Keys

  1. Create a new app in the X Developer Portal
  2. Generate API Key and API Key Secret
  3. Enable OAuth 1.0a with read/write permissions
  4. Generate Access Token and Access Token Secret
3

Configure Environment Variables

4

Test Authentication


Configuration Options

Configure X Tool with your API credentials and preferences.

XTool Class

XTool.post() Parameters

text
str
required
The text content of the post (up to 280 characters for basic accounts)
reply_to
str
default:"None"
ID of post to reply to
quote_tweet_id
str
default:"None"
ID of post to quote (Enterprise plan required)
media_ids
List[str]
default:"None"
List of uploaded media IDs to attach
media_paths
List[str]
default:"None"
List of local file paths to upload and attach
poll_options
List[str]
default:"None"
Poll choices (2-4 options, each up to 25 chars)
poll_duration_minutes
int
default:"1440"
Poll duration in minutes (5-10080, default 24 hours)

Function Helpers


Common Patterns


Agent Integration Patterns


Authentication Flow Diagram


Best Practices

OAuth 1.0a provides full posting capabilities, while app-only bearer tokens are read-only.
Implement exponential backoff to handle rate limits (300 posts per 15 minutes).
Split long content into threaded posts for better readability.
Store credentials in environment variables rather than hardcoding them.

Premium Features

Some features require X Premium or Enterprise plans:
  • Extended character limits (Premium: up to 25,000 characters)
  • Advanced search operators (Premium)
Quote Posts:
Extended Posts:

Tools Overview

Explore all available PraisonAI tools

Slack Integration

Send messages to Slack channels

Telegram Bot

Send messages via Telegram bots

Custom Tools

Create your own custom tools