A web application that combines AI capabilities with Twitter/X functionality to create an advanced social media management tool. You can also just use it to chat with AI and generate images to upload to your cloudflare images gallery.
- AI-Assisted Tweet Crafting: Chat interface to describe tweet ideas, AI generates optimized tweet text
- Image Generation: DALL-E 3 integration for generating custom images for tweets
- Advanced Twitter Preview: Real-time rendering of how tweets will appear with character count
- Thread Management: Smart thread creation for longer content
- Direct Posting: Post directly to Twitter with one click
- Twitter Timeline: View your home timeline, like, retweet, and reply to tweets directly
- Configurable AI Models: Support for different OpenAI models - Can use xAI and Grok
- Cloudflare Image Gallery: Store and reuse generated images with Cloudflare Images integration
- Tweet Management: View and delete your posted tweets
cfx.mp4
- Frontend: Next.js with Chakra UI for a cyberpunk aesthetic
- Backend: Python FastAPI for high-performance API endpoints
- AI Integration: OpenAI or xAI for text generation and DALL-E 3 for image creation
- Twitter API: For posting tweets, threads, and images, and interacting with the timeline
- Cloudflare Images: Optional integration for image hosting
The application includes a full Twitter timeline integration:
- View your home timeline with tweets from accounts you follow
- Like, retweet, and reply to tweets directly from the interface
- See media attachments, quoted tweets, and other rich content
- Automatic handling of rate limits with caching for better performance
The application includes integration with Cloudflare Images for persistent storage of AI-generated images:
- Generated images can be uploaded to Cloudflare with a single click
- The Cloudflare Gallery tab displays all previously uploaded images
- Images from the gallery can be selected for use in new tweets
- Requires Cloudflare account with Images service enabled
To configure Cloudflare integration:
- Create a Cloudflare account and enable the Images service
- Generate an API token with Images Write permissions
- Add your Account ID and API token to the
.env
file
- Node.js (v18+)
- Python (v3.10+)
- Twitter/X API credentials
- OpenAI API key
- (Optional) Cloudflare account for image hosting
- Clone the repository
- Copy
.env.sample
to.env
and fill in your API keys:# Twitter (X) API credentials X_CONSUMER_KEY=your_consumer_key X_CONSUMER_SECRET=your_consumer_secret X_ACCESS_TOKEN=your_access_token X_ACCESS_TOKEN_SECRET=your_access_token_secret # OpenAI API OPENAI_API_KEY=your_openai_api_key OPENAI_TEXT_MODEL=gpt-4o OPENAI_IMAGE_MODEL=dall-e-3 # XAI API XAI_API_KEY=your_xai_api_key XAI_MODEL=grok-2-1212 # Cloudflare (optional) CLOUDFLARE_ACCOUNT_ID=your_cloudflare_account_id CLOUDFLARE_API_TOKEN=your_cloudflare_api_token
CFX-Terminal requires the following Twitter API access:
- API v2 endpoints: For posting tweets, viewing timeline, and tweet interactions
- API v1.1 endpoints: For media uploads and OAuth authentication
- Elevated access: Basic access is sufficient for most features, but elevated access provides better rate limits
The application is designed to work with the free tier of Twitter API access, but some features may be limited based on your access level.
You can configure different AI models by changing the environment variables:
-
Text Generation Models:
gpt-4o
: Latest GPT-4 model (default) or use minigrok-2-1212
: Grok 2 model (if you have access)
-
Image Generation Models:
dall-e-3
: Latest DALL-E model (default)
-
Navigate to the backend directory:
cd backend
-
Install dependencies:
pip install -r requirements.txt
-
Start the backend server:
uvicorn main:app --reload
-
Navigate to the frontend directory:
cd frontend
-
Install dependencies:
npm install
-
Start the development server:
npm run dev
-
Access the application at http://localhost:3000
Alternatively, you can use the provided start script to run both frontend and backend:
./start.sh
For a containerized deployment, you can use Docker:
- Make sure Docker and Docker Compose are installed on your system
- Configure your
.env
file as described in the Environment Setup section - Run the Docker start script:
./docker/docker-start.sh
This will build and start both the frontend and backend services in Docker containers. The application will be available at:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
To stop the Docker containers:
cd docker && docker-compose down
The Docker setup includes:
- Separate containers for frontend and backend
- Volume mounts for development (changes to code are reflected without rebuilding)
- Persistent storage for generated images
- Proper networking between services
You can customize the Docker configuration by editing the files in the docker
directory:
Dockerfile.frontend
: Frontend container configurationDockerfile.backend
: Backend container configurationdocker-compose.yml
: Service definitions and networking
- Craft a Tweet: Enter your tweet idea in the chat interface and let AI generate optimized content
- Generate Images: Describe the image you want and let DALL-E 3 create it
- Preview & Edit: Review how your tweet will appear and make any necessary edits
- Post to Twitter: Send your creation directly to X with one click
- Browse Timeline: View your Twitter timeline and interact with tweets
- Toggle on Chat: Just chat with the model, you can also just generate images with Dalle-3
MIT