Skip to main content
This recipe chains three capabilities: a vision model reads the mood of an image, structured outputs turn that into a style and lyrics, and the music API turns those into a song. You end up with an .mp3 that fits the picture. The connection between them is plain JSON: the vision model returns a style and lyrics, and the music API takes exactly those two fields.

The plan

1

Read the image

POST /v1/chat/completions with a vision model and the image, asking for JSON with a style prompt and lyrics.
2

Generate the song

POST /v1/audio/generations with prompt set to the style and lyrics_prompt set to the lyrics.
3

Poll and download

Poll GET /v1/audio/generations/{id} until completed, then download audio[0].url.

Full script

Notes

  • Use a vision-capable model for step 1. deepshi-3.0 reads images and returns JSON. Send the image as a URL or a base64 data: URI.
  • minimax-music-v2 is a vocal model, so it needs lyrics_prompt. Asking the vision model to write the lyrics keeps the whole chain in one pass.
  • Cost: the chat call reports its cost inline in usage.cost. The song is billed once on completion; see music pricing.

Next steps

Music generation

All music parameters, models, and pricing.

Animate an image

Chain image generation into a video clip.