A simple AI agent that plays songs on Spotify using natural language commands and OpenAI's function calling.
- 🎵 Natural Language Control - Say "Play Bohemian Rhapsody" and it plays!
- 🤖 OpenAI Function Calling - Uses modern AI to understand your requests
- 🎧 Smart Device Detection - Plays on available devices or your computer
- 🔍 Song Search - Finds songs by name, artist, or genre
# Using uv (recommended)
uv sync
# Or using pip
pip install -r requirements.txtCreate a .env file with your credentials:
SPOTIFY_CLIENT_ID=your_spotify_client_id
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
SPOTIFY_URI=http://127.0.0.1:8888/callback
OPENAI_API_KEY=your_openai_api_key# Using uv (recommended)
uv run play_my_mode_agent.py
# Or using python directly
python play_my_mode_agent.py- "Play Bohemian Rhapsody"
- "Play some jazz music"
- "Play Imagine by John Lennon"
- Python 3.12+
- Spotify account and developer credentials
- OpenAI API key
- Spotify app open on your computer
- User Input: Natural language like "Play Bohemian Rhapsody"
- AI Analysis: OpenAI determines this needs the
play_songfunction - Function Call: Agent calls
play_song("Bohemian Rhapsody") - Spotify API: Searches and plays the song
- Response: Confirms what's playing
Get your API keys:
- Spotify: Developer Dashboard
- OpenAI: Platform
See SETUP.md for detailed instructions.
- "No Spotify devices found" → Open Spotify on your computer
- "Failed to get access token" → Check your .env file credentials
- "OpenAI API Error" → Verify your OpenAI API key
MIT License - see LICENSE file for details.