flowmusic-cli
Make music with Google Flow Music (Lyria) from your terminal, your scripts, or your AI agent.
fmusic is a command-line client and MCP server for flowmusic.app. You sign in once with your own Google account. After that it works without a browser: you describe a song, and a few minutes later you have a WAV file plus a JSON file with its details.
mcp-name: io.github.JvanLeeuwen4/flowmusic-cli
[!IMPORTANT]
Unofficial project. It is not affiliated with, endorsed by, or supported by Google. It uses the same endpoints as the flowmusic.app website, so it can break when the site changes. You use your own account and credits. Follow the Flow Music terms and the generative AI use policy, and don't use it for spam or mass generation.
Quick start
Example output:
What you need:
- Python 3.10+, via uv or pipx.
- Google Chrome or Edge, for the one-time sign-in.
- A Google account with Flow Music access. A Google AI subscription gives the most credits.
What you can do
The full reference for every command and flag is in docs/commands.md.
How generation works
Flow Music has an AI co-producer. Your prompt goes to it, and it decides what to make: often one or two takes. It rewrites your prompt into a detailed "sound prompt" and may suggest next steps. Each generation belongs to a conversation, and fmusic chat <conversation_id> "…" continues that conversation, for example to tweak, extend or remix a take.
If you want exact control without the co-producer, use the experimental --direct mode. Your prompt goes to the song model as-is, and -n sets the number of takes:
Game music: seamless loops
Lyria songs have an intro and a real ending, so looping the raw file jumps from the final chord straight back to the start. --loop fixes that:
[Waveform around the loop seam: the raw file fades out and restarts from a quiet intro; the fmusic loop keeps playing]
Listen to 16 seconds around the seam of a 1-minute Lyria jingle: 🔊 raw file, looped · 🔊 fmusic loop. The seam is at 0:08.
- The prompt gets a short "loopable: steady groove, no intro, no ending" instruction.
<name>_loop.ogg is cut and crossfaded so it loops cleanly when you turn looping on in any engine (Godot, Unity, web audio). Use --loop-format wav|both for WAV.
- The full WAV keeps its intro and gets the loop points as a
smpl chunk. In Godot, import it with Loop Mode: Detect From WAV to play the intro once and then loop.
- The JSON gets
loop: {start_s, end_s, length_s, start_sample, end_sample, similarity, quality}. When quality is poor, the seam may be audible; try the other take.
- Songs you already have don't cost credits:
fmusic loop <clip_id> or fmusic loop theme.wav.
How the loop is found is described in docs/how-it-works.md.
Install
The package installs two equivalent commands, fmusic and flowmusic.
Sign in
- You sign in once. Tokens refresh automatically, so you won't need to sign in again unless you log out or the session is revoked.
- To use several accounts, add
--profile work (or set FMUSIC_PROFILE=work) to any command.
- Can't open a browser (for example on a server)? Sign in on flowmusic.app on another machine. In the browser's DevTools, open the Network tab and copy the
Cookie header of any __api request. Then run:
Use it from AI agents
fmusic is built to be driven by agents. There are three ways:
1. Claude Code plugin (skill + MCP server)
Then run fmusic auth login once in a terminal. The plugin starts the MCP server through uvx, so you don't need to install anything else.
2. Any MCP client (Claude Desktop, Cursor, VS Code, Codex, …)
Add this to the client's MCP configuration. It only needs uv:
If fmusic is already installed, this command writes the config for you:
The tools and their parameters are listed in docs/mcp.md.
3. The CLI with --json
Every command accepts --json:
- Results go to stdout as one JSON object:
{"status":"ok","data":…} or {"status":"fail","error":{…}}.
- Progress messages go to stderr.
- Exit codes are stable. See docs/troubleshooting.md.
Agents working on this repository should read AGENTS.md.
Where files go
By default, songs are saved to ~/Music/flowmusic-cli/<date>/. Use -o DIR to choose a folder; the files then go directly in it. Each clip produces:
Configuration
All settings are optional environment variables.
Troubleshooting
The most common issues:
- Uploads with vocals fail with "not available in your region". In some regions, including the EU, Flow Music doesn't allow uploading tracks with vocals or removing vocals from them. Upload instrumentals instead.
Session expired (exit code 3). Run fmusic auth login again.
- Google won't let you sign in. Make sure Chrome or Edge is installed. You can also use
fmusic auth import instead.
Everything else is in docs/troubleshooting.md.
Documentation
Contributing
Issues and pull requests are welcome. See AGENTS.md for the layout and test commands:
The sign-in approach is inspired by gflow-cli. MIT licensed.