# music generator

> CassetteAI’s model generates a 30-second sample in under 2 seconds and a full 3-minute track in under 10 seconds. At 44.1 kHz stereo audio, expect a level of professional consistency with no breaks, no squeaks, and no random interruptions in your creations.




## Overview

- **Endpoint**: `https://fal.run/CassetteAI/music-generator`
- **Model ID**: `cassetteai/music-generator`
- **Category**: text-to-audio
- **Kind**: inference
**Tags**: music, cassetteai



## Pricing

Your request will cost $0.02 per output minute.

For more details, see [fal.ai pricing](https://fal.ai/pricing).

## API Information

This model can be used via our HTTP API or more conveniently via our client libraries.
See the input and output schema below, as well as the usage examples.


### Input Schema

The API accepts the following input parameters:


- **`prompt`** (`string`, _required_):
  The prompt to generate music from.
  - Examples: "Smooth chill hip-hop beat with mellow piano melodies, deep bass, and soft drums, perfect for a night drive. Key: D Minor, Tempo: 90 BPM."

- **`duration`** (`integer`, _required_):
  The duration of the generated music in seconds.
  - Range: `10` to `180`
  - Examples: 50



**Required Parameters Example**:

```json
{
  "prompt": "Smooth chill hip-hop beat with mellow piano melodies, deep bass, and soft drums, perfect for a night drive. Key: D Minor, Tempo: 90 BPM.",
  "duration": 50
}
```


### Output Schema

The API returns the following output format:

- **`audio_file`** (`File`, _required_):
  The generated music
  - Examples: {"url":"https://v3.fal.media/files/panda/T-GP6cbpo1lgL8ll4oKGj_generated.wav"}



**Example Response**:

```json
{
  "audio_file": {
    "url": "https://v3.fal.media/files/panda/T-GP6cbpo1lgL8ll4oKGj_generated.wav"
  }
}
```


## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://fal.run/CassetteAI/music-generator \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "prompt": "Smooth chill hip-hop beat with mellow piano melodies, deep bass, and soft drums, perfect for a night drive. Key: D Minor, Tempo: 90 BPM.",
     "duration": 50
   }'
```

### Python

Ensure you have the Python client installed:

```bash
pip install fal-client
```

Then use the API client to make requests:

```python
import fal_client

def on_queue_update(update):
    if isinstance(update, fal_client.InProgress):
        for log in update.logs:
           print(log["message"])

result = fal_client.subscribe(
    "CassetteAI/music-generator",
    arguments={
        "prompt": "Smooth chill hip-hop beat with mellow piano melodies, deep bass, and soft drums, perfect for a night drive. Key: D Minor, Tempo: 90 BPM.",
        "duration": 50
    },
    with_logs=True,
    on_queue_update=on_queue_update,
)
print(result)
```

### JavaScript

Ensure you have the JavaScript client installed:

```bash
npm install --save @fal-ai/client
```

Then use the API client to make requests:

```javascript
import { fal } from "@fal-ai/client";

const result = await fal.subscribe("CassetteAI/music-generator", {
  input: {
    prompt: "Smooth chill hip-hop beat with mellow piano melodies, deep bass, and soft drums, perfect for a night drive. Key: D Minor, Tempo: 90 BPM.",
    duration: 50
  },
  logs: true,
  onQueueUpdate: (update) => {
    if (update.status === "IN_PROGRESS") {
      update.logs.map((log) => log.message).forEach(console.log);
    }
  },
});
console.log(result.data);
console.log(result.requestId);
```


## Additional Resources

### Documentation

- [Model Playground](https://fal.ai/models/cassetteai/music-generator)
- [API Documentation](https://fal.ai/models/cassetteai/music-generator/api)
- [OpenAPI Schema](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=cassetteai/music-generator)

### fal.ai Platform

- [Platform Documentation](https://docs.fal.ai)
- [Python Client](https://docs.fal.ai/clients/python)
- [JavaScript Client](https://docs.fal.ai/clients/javascript)
