# Text to Music

**Action ID:** `text_to_music`

## Description

Generate original music from text descriptions using AI. This node creates custom songs with or without lyrics based on your prompts, style preferences, and song title.

## Input Parameters

| Name         | Type    | Required | Default | Description                               |
| ------------ | ------- | :------: | ------- | ----------------------------------------- |
| prompt       | string  |     ✓    | -       | Prompt describing the music to generate   |
| title        | string  |     ✓    | -       | Title of the song                         |
| instrumental | boolean |     -    | -       | Create a song without lyrics              |
| style        | string  |     -    | pop     | Music style (e.g., pop, rock, jazz, etc.) |

<details>

<summary>View JSON Schema</summary>

**Input Schema**

```json
{
  "description": "Text To Music node input.",
  "properties": {
    "prompt": {
      "description": "Prompt for the music generation.",
      "title": "prompt",
      "type": "string"
    },
    "instrumental": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Create a song without lyrics.",
      "title": "Create a song without lyrics."
    },
    "style": {
      "default": "pop",
      "description": "Music style. For example: pop, rock, jazz, etc.",
      "title": "Style",
      "type": "string"
    },
    "title": {
      "description": "Title of the song.",
      "title": "Title",
      "type": "string"
    }
  },
  "required": [
    "prompt",
    "title"
  ],
  "title": "TextToMusicNodeInput",
  "type": "object"
}
```

</details>

## Output Parameters

| Name     | Type   | Description                             |
| -------- | ------ | --------------------------------------- |
| audio\_1 | string | URL of the first generated audio track  |
| lyric\_1 | string | Lyrics for the first audio track        |
| audio\_2 | string | URL of the second generated audio track |
| lyric\_2 | string | Lyrics for the second audio track       |

<details>

<summary>View JSON Schema</summary>

**Output Schema**

```json
{
  "description": "Text to music node output.",
  "properties": {
    "audio_1": {
      "title": "First audio.",
      "type": "string"
    },
    "lyric_1": {
      "title": "First audio lyrics.",
      "type": "string"
    },
    "audio_2": {
      "title": "Second audio.",
      "type": "string"
    },
    "lyric_2": {
      "title": "Second audio lyrics.",
      "type": "string"
    }
  },
  "required": [
    "audio_1",
    "lyric_1",
    "audio_2",
    "lyric_2"
  ],
  "title": "TextToMusicNodeOutput",
  "type": "object"
}
```

</details>

## How It Works

This node uses AI music generation to create original songs based on your text description. You provide a prompt describing the mood, theme, or characteristics of the music, along with a style and title. The AI generates two variations of the song, each with its own audio track and lyrics (unless instrumental mode is enabled). The system composes melodies, harmonies, and arrangements that match your specifications.

## Usage Examples

### Example 1: Pop Song with Lyrics

**Input:**

```
prompt: "An upbeat summer love song about beach memories and sunsets"
title: "Golden Waves"
style: "pop"
instrumental: false
```

**Output:**

```
audio_1: "https://example.com/golden_waves_v1.mp3"
lyric_1: "Walking on the shoreline, hand in hand / Golden waves crashing on the sand..."
audio_2: "https://example.com/golden_waves_v2.mp3"
lyric_2: "Sunset paints the sky in colors bright / Your smile shining in the fading light..."
```

### Example 2: Instrumental Jazz

**Input:**

```
prompt: "Smooth jazz for a late-night cafe atmosphere, saxophone-led with piano accompaniment"
title: "Midnight Brew"
style: "jazz"
instrumental: true
```

**Output:**

```
audio_1: "https://example.com/midnight_brew_v1.mp3"
lyric_1: ""
audio_2: "https://example.com/midnight_brew_v2.mp3"
lyric_2: ""
```

### Example 3: Rock Anthem

**Input:**

```
prompt: "Powerful rock anthem about overcoming challenges and never giving up"
title: "Rise Again"
style: "rock"
instrumental: false
```

**Output:**

```
audio_1: "https://example.com/rise_again_v1.mp3"
lyric_1: "When the world says you can't, prove them wrong / Rise up higher, sing your song..."
audio_2: "https://example.com/rise_again_v2.mp3"
lyric_2: "Through the fire and the pain, we stand tall / Breaking chains, answering the call..."
```

## Common Use Cases

* **Background Music**: Generate custom background tracks for videos, podcasts, or presentations
* **Marketing Jingles**: Create catchy tunes for advertising campaigns and brand promotions
* **Game Soundtracks**: Produce atmospheric music for video games and interactive experiences
* **Social Media Content**: Generate trending music for TikTok, Instagram Reels, and YouTube videos
* **Meditation and Wellness**: Create calming instrumental music for relaxation and mindfulness apps
* **Educational Content**: Produce songs that help teach concepts or remember information
* **Personalized Gifts**: Generate custom songs for special occasions, gifts, or celebrations

## Error Handling

| Error Type           | Cause                                      | Solution                                                            |
| -------------------- | ------------------------------------------ | ------------------------------------------------------------------- |
| Invalid Style        | Music style not recognized                 | Use common styles like pop, rock, jazz, classical, electronic, etc. |
| Prompt Too Short     | Prompt lacks sufficient detail             | Provide more descriptive details about mood, tempo, and theme       |
| Generation Failed    | AI couldn't generate music from prompt     | Revise prompt to be clearer and try again                           |
| Title Required       | Song title is missing                      | Provide a title for the song                                        |
| Timeout Error        | Generation taking too long                 | Try again or simplify the prompt                                    |
| Invalid Parameters   | Instrumental value is malformed            | Ensure instrumental is true, false, or null                         |
| API Connection Error | Cannot connect to music generation service | Check connection settings and try again                             |

## Notes

* **Multiple Variations**: The node always generates two variations, giving you options to choose from or use both
* **Instrumental Mode**: Set instrumental to true for music without lyrics, ideal for background music or instrumentals
* **Style Selection**: Common styles include pop, rock, jazz, classical, electronic, hip-hop, country, R\&B, and more
* **Prompt Quality**: More detailed prompts yield better results. Include mood, tempo, instruments, and theme
* **Generation Time**: Music generation typically takes 1-3 minutes per song. Be patient during processing
* **Lyrics**: When instrumental is false, AI generates lyrics that match the prompt and style. Review for appropriateness
* **Copyright**: Generated music is typically royalty-free, but verify the terms of service for commercial use
* **Audio Format**: Output audio is typically in MP3 format, suitable for most applications


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.agenticflow.ai/reference/nodes/text_to_music.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
