tools.suno_music module
GameGirl Color – Suno AI Music Generation (direct, no proxy).
Calls Suno’s internal API directly using session cookies. Star IS the API proxy. No separate deployment needed. Auth flow: cookie -> Clerk session refresh -> studio-api.suno.ai # 🎵💀 DIRECT NEURAL AUDIO PIPELINE
- async tools.suno_music.run(prompt, style='', title='', lyrics='', source_url='', instrumental=False, save_as='', weirdness=64, style_influence=64, audio_influence=28, ctx=None)[source]
Generate a music track end-to-end via Suno’s internal studio API.
The entry point for the
generate_suno_musictool. It authenticates, submits a generation request, polls until the track is rendered, then downloads the audio and delivers it to the originating channel. Three request shapes are chosen automatically from the arguments: cover/remix mode when asource_urlis given, custom mode when lyrics/style/title are supplied, and simple description mode otherwise; the 0-100weirdness/style_influence/audio_influencesliders are normalized to Suno’s 0.0-1.0cfg_coefandweirdnessparameters.Side effects span auth, HTTP, the platform, and optionally the game session. It pulls the cookie via
_get_cookie()(off-thread) and a JWT via_refresh_token()(re-refreshing roughly every 60s mid-poll), then drivesaiohttpcalls againststudio-api.suno.ai— POST/api/generate/v2/to create clips and GET/api/feed/to poll (up to a 5-minute timeout) for acompletestatus andaudio_url. On completion it downloads the MP3 and sends it throughctx.adapter.send_file, appending the bytes toctx.sent_files. Whensave_asis set and a game session is active it registers the track as a game asset viagame_assets.upload_asset()(passingctx.redis). It does no LLM work.Invoked through the tool dispatch registry (this module uses the single-tool
TOOL_NAME/runformat loaded bytool_loader.py); theauto_covertool also instructs the model to callgenerate_suno_musicas a follow-up step.- Parameters:
prompt (
str) – Text description of the music to generate.style (
str) – Optional Suno style tags.title (
str) – Optional track title.lyrics (
str) – Optional lyrics with[Verse]/[Chorus]tags; empty implies instrumental.source_url (
str) – Optional existing-track URL for cover/remix mode.instrumental (
bool) – WhenTrue, suppress vocals.save_as (
str) – Optional asset name; when set and a game is active, the track is saved as a game asset.weirdness (
int) – 0-100 weirdness slider (default 64).style_influence (
int) – 0-100 style-influence slider (default 64).audio_influence (
int) – 0-100 audio-influence slider (default 28).ctx (
ToolContext|None) – Execution context;channel_id,adapter,sent_files,config,user_id, andredisare used.
- Returns:
- A JSON string with the track metadata and delivered file info on
success, or an
{"error": ...}payload on any failure (missing cookie/context, auth failure, Suno API error, no clips, timeout, or a download/send error).
- Return type: