# Music generator API

A song or an instrumental from a description, as an MP3 of 3 seconds to 10 minutes, cleared for commercial use. Priced per minute started (30 s unless seconds says otherwise). Search the free library first (search_assets, type audio, category music).

Tool id `music-generator` on the REST API (`POST https://3dvalley.com/api/v1/jobs`); MCP tool `generate_music` on https://3dvalley.com/mcp. Paid in credits (1 credit = $0.01), taken when the job starts and given back if it fails. The general rules (keys, idempotency, waiting, webhooks) are in [the API docs](https://3dvalley.com/docs/api).

The free CC0 library holds music already: `GET /api/v1/assets?type=audio&category=music` (MCP: `search_assets`) before paying for a track.

## Models and prices

| Model | Name | Price | Time | What it is |
|---|---|---|---|---|
| `elevenlabs-music` (default) | ElevenLabs Music | 150 credits per minute | about 60 s | A song or an instrumental from a description, 3 seconds to 10 minutes, cleared for commercial use. |

## Input

| Field | Required | |
|---|---|---|
| `prompt` | yes | The music: "calm lo-fi piano for a cozy farming game, 80 BPM". Lyrics may be part of it. Up to 4,100 characters. |

## Options

| Option | Type | Values | |
|---|---|---|---|
| `seconds` | integer | from 3 to 600 | The length in seconds. Default `30`. |
| `instrumental` | boolean | `true` or `false` | No singing, whatever the description says. Default `false`. |

## Output

Files: `audio`. `audio` is the MP3 (128 kbit/s, 44.1 kHz). `stats.seconds` is its length. ElevenLabs Music is cleared for commercial use: a game or a video that uses it can be sold.

## Example

```
curl -X POST https://3dvalley.com/api/v1/jobs \
  -H "Authorization: Bearer $THREEDVALLEY_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Prefer: wait=50" \
  -H "Content-Type: application/json" \
  -d '{"tool":"music-generator","input":{"prompt":"calm lo-fi piano for a cozy farming game, 80 BPM"},"options":{"seconds":60,"instrumental":true}}'
```

From an MCP client:

```
generate_music({"prompt":"calm lo-fi piano for a cozy farming game, 80 BPM","seconds":60,"instrumental":true})
```

## Limits

- `max_prompt`: 4,100
- `min_seconds`: 3
- `max_seconds`: 600
