---
title: "AI Music Generator"
method: POST
path: "/v1/ai-music-generator"
tags: ["Audio Projects"]
---

# AI Music Generator

`POST /v1/ai-music-generator`

## Request

- Base URL: `https://api.magichour.ai`
- URL: `https://api.magichour.ai/v1/ai-music-generator`
- Auth: HTTP bearer

Generate music from a description, with optional custom lyrics or instrumental-only output. Costs 1 credits per requested second. Returns a project ID; poll GET /v1/audio-projects/{id} for status and downloads.

## Request body

- object
  - `name` string: Give your audio a custom name for easy identification.
  - `duration` integer, required: Requested track duration in seconds, from 15 to 300. Determines credits charged.
  - `style` object, required
    - `prompt` string, required: Describe the song, including genre, mood, and instruments.
    - `instrumental` boolean: Generate music without vocals. When true, lyrics is ignored.
    - `lyrics` string: Custom lyrics. Omit or leave blank for AI-generated lyrics when instrumental is false.

## Response `200`

Success

- object: Success
  - `id` string, required: Unique ID of the audio. Use it with the [Get audio Project API](https://docs.magichour.ai/api-reference/audio-projects/get-audio-details) to fetch status and downloads.
  - `credits_charged` integer, required: The amount of credits deducted from your account to generate the audio. We charge credits right when the request is made. If an error occurred while generating the audio, credits will be refunded and this field will be updated to include the refund.

## Other responses

- `400`: Invalid Request
- `401`: Unauthorized
- `402`: Payment Required
- `404`: Not Found
- `422`: 422
- `500`: Internal Server Error

## Changes

- **2026-10-21** `721e633a2ac5`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/magichourhq/apis/magic-hour-api/changes/v1/ai-music-generator/post.md)

---

[API](https://skmtc.dev/magichourhq/apis/magic-hour-api.md) - [All operations](https://skmtc.dev/magichourhq/apis/magic-hour-api/llms.txt) - [OpenAPI document](https://skmtc.dev/magichourhq/apis/magic-hour-api/revisions/2ee5927306a9?raw)
