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_music tool. 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 a source_url is given, custom mode when lyrics/style/title are supplied, and simple description mode otherwise; the 0-100 weirdness / style_influence / audio_influence sliders are normalized to Suno’s 0.0-1.0 cfg_coef and weirdness parameters.

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 drives aiohttp calls against studio-api.suno.ai — POST /api/generate/v2/ to create clips and GET /api/feed/ to poll (up to a 5-minute timeout) for a complete status and audio_url. On completion it downloads the MP3 and sends it through ctx.adapter.send_file, appending the bytes to ctx.sent_files. When save_as is set and a game session is active it registers the track as a game asset via game_assets.upload_asset() (passing ctx.redis). It does no LLM work.

Invoked through the tool dispatch registry (this module uses the single-tool TOOL_NAME / run format loaded by tool_loader.py); the auto_cover tool also instructs the model to call generate_suno_music as 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) – When True, 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, and redis are 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:

str