X Space Agent
AI agents that join and talk in X/Twitter Spaces
Quick Start •
Features •
Structure •
Architecture •
Examples •
Docs •
Contributing
Multi-agent AI voice conversations in X/Twitter Spaces — real-time transcription, LLM responses, and voice synthesis
What is this?
X Space Agent is a TypeScript SDK that lets you build AI agents that autonomously join, listen, and speak in X/Twitter Spaces. Connect any LLM, any voice provider, and ship in minutes. No Twitter API approval needed.
import { XSpaceAgent } from 'xspace-agent'
const agent = new XSpaceAgent({
auth: { token: process.env.X_AUTH_TOKEN!, ct0: process.env.X_CT0! },
ai: { provider: 'openai', apiKey: process.env.OPENAI_API_KEY! },
})
agent.on('transcription', ({ text }) => console.log('Heard:', text))
agent.on('response', ({ text }) => console.log('Said:', text))
await agent.join('https://x.com/i/spaces/YOUR_SPACE_ID')
Or skip the code entirely with the CLI:
node packages/cli/bin/xspace-agent join https://x.com/i/spaces/YOUR_SPACE_ID --provider openai
(Once the packages are published this becomes npx xspace-agent join <url>.)
Features
🎤 Multi-Provider LLM OpenAI, Claude, Groq, or any custom API | 👥 Multi-Agent Teams Run multiple personalities with turn management | 🔧 Middleware Pipeline Hook into STT → LLM → TTS at any stage |
💻 Zero-Code CLI
xspace-agent join <url> no SDK needed | 📊 Admin Dashboard Web UI to monitor and control live agents | 🔷 TypeScript-First Full type safety, autocomplete included |
Requirements
- Node.js >= 18 (tested on 18, 20, 22)
- pnpm >= 9 (for monorepo development) or npm/yarn for consuming the SDK
- Chromium — bundled with Puppeteer, or provide your own via
BROWSER_MODE=connect
- X (Twitter) account — cookie-based auth (
X_AUTH_TOKEN + X_CT0) or username/password
- At least one AI provider key — OpenAI, Anthropic, or Groq
Quick Start
1. Install
npm install xspace-agent # the SDK
npm create xspace-agent@latest # or scaffold a new project
To work on the monorepo itself, install from source:
git clone https://github.com/nirholas/xspace-AI.git
cd xspace-AI
pnpm install
pnpm build
The CLI (packages/cli) is not on npm yet; run it from packages/cli/bin/xspace-agent.
2. Set environment variables
# .env
<!-- three.ws:badges -->
[](https://github.com/nirholas/xspace-AI/stargazers) [](https://github.com/nirholas/xspace-AI/commits) [](https://github.com/nirholas/xspace-AI/pulls) [](https://github.com/nirholas/xspace-AI/blob/HEAD/AGENTS.md)
<!-- /three.ws:badges -->
X_AUTH_TOKEN=your_x_auth_token
X_CT0=your_x_ct0_cookie
OPENAI_API_KEY=sk-...
Get X_AUTH_TOKEN and X_CT0 from your browser cookies after logging into X. Guide →
3. Run
import { XSpaceAgent } from 'xspace-agent'
const agent = new XSpaceAgent({
auth: { token: process.env.X_AUTH_TOKEN!, ct0: process.env.X_CT0! },
ai: {
provider: 'openai',
apiKey: process.env.OPENAI_API_KEY!,
model: 'gpt-4o',
systemPrompt: 'You are a helpful AI analyst. Be concise and data-driven.',
},
voice: {
sttProvider: 'deepgram',
ttsProvider: 'elevenlabs',
voiceId: 'rachel',
},
})
agent.on('transcription', ({ text, speaker }) => console.log(`${speaker}: ${text}`))
agent.on('response', ({ text }) => console.log(`Agent: ${text}`))
await agent.join('https://x.com/i/spaces/YOUR_SPACE_ID')
Or skip the code entirely with the CLI:
node packages/cli/bin/xspace-agent join https://x.com/i/spaces/YOUR_SPACE_ID --provider openai
(Once the packages are published this becomes npx xspace-agent join <url>.)
Deploy