Skip to main content
POST
/
v1
/
image_to_song
Python
import requests

url = "https://api.musicgpt.com/api/public/v1/image_to_song"
headers = {"Authorization": "<API_KEY>"}
data = {
    "image_url": "https://mybucket.s3.amazonaws.com/image.png",
    "prompt": "Generate a relaxing acoustic track inspired by this scene.",
    "lyrics": "Let the colors of the sunset fill your heart.",
    "make_instrumental": False,
    "vocal_only": False,
    "key": "C major",
    "bpm": 120,
    "webhook_url": "https://example.com/webhook",
    "voice_id": "voice_123"
}

# Option 1: Using image URL
response = requests.post(url, headers=headers, data=data)
print(response.json())

# Option 2: Uploading a local image file
# with open("image.png", "rb") as f:
#     files = {"image_file": f}
#     response = requests.post(url, headers=headers, data=data, files=files)
#     print(response.json())
{
  "success": true,
  "message": "Message Published To Queue",
  "task_id": "task_12345",
  "conversion_id_1": "conv_12345",
  "conversion_id_2": "conv_54321",
  "eta": 300,
  "credit_estimate": 150.5
}

Authorizations

Authorization
string
header
required

Body

multipart/form-data
image_file
file
required

Image file to upload and analyze. Supported formats: JPEG, PNG, GIF, BMP, WEBP.

image_url
string

URL of the image to analyze. Either this or image_file must be provided.

Example:

"https://mybucket.s3.amazonaws.com/image.png"

prompt
string

Additional prompt to guide the song generation from the image.

Maximum string length: 300
Example:

"Generate a relaxing acoustic track inspired by this scene."

lyrics
string

Custom lyrics to include in the generated audio.

Maximum string length: 3000
Example:

"Let the colors of the sunset fill your heart."

negative_tags
string

Tags or themes to avoid in the song.

Example:

"no heavy metal, avoid loud drums"

make_instrumental
boolean
default:false

Generate instrumental output only. Lyrics will be ignored.

vocal_only
boolean
default:false

Generate vocal-only output.

key
string

Musical key for the song.

Example:

"C major"

bpm
integer
default:0

Beats per minute for the song tempo. Defaults to 0 (auto-selected).

webhook_url
string

Optional callback URL for async processing results.

Example:

"https://example.com/webhook"

voice_id
string

Voice ID for converting the generated audio. Cannot be used with vocal_only mode.

Response

Successfully initiated image-to-song task

success
boolean
message
string
task_id
string
conversion_id_1
string
conversion_id_2
string
eta
integer

Estimated processing time in seconds

credit_estimate
number<float>