# music

Canonical URL: https://developers.iagenify.com/sdk/ref/tools/music/
Language: en

`tools: { music: api.tools.music }, model: { main, music }`

Lets a run generate a short music clip from a style and a mood. A declaration resolved against a session named music.

Status: declaration only · needs a music session · declared cost 15

Nothing to call. The clip comes from a [model session](/sdk/ref/models/create) handed to the run under the name `music`.

## Declaring it {#declaring}

```javascript
const writer = await api.models.create({ model: "gemini-3.5-flash" });
const composer = await api.models.create({
  model: "lyria-2",
  settings: { duration: 15, tempoBpm: 96 },
});

const agent = api.agents.create({
  model: { main: writer, music: composer },
  tools: { music: api.tools.music },
});
```

## What the model sends {#arguments}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `prompt` | string | required | The style and the mood. Not a score, and not lyrics. |

Length and tempo belong to the session, where you can see them and where they stay the same from one call to the next.

## Where the clip goes {#result}

```javascript
const [track] = run.artifacts.filter((a) => a.type === "audio");
await pc.files.write("Audio/bed.wav", Buffer.from(track.content, "base64"));
```

## Music and speech are both audio artifacts {#audio-kind}

> **Declaring voice and music together needs a way to tell them apart**
>
> Both arrive as type: "audio". The order of the run's artifacts is the order they were produced, so match on the step that made each one rather than on the kind — or declare one of the two per run.

## The declared cost is 15 {#cost}

Priced on the seconds produced, and the guard decides before the call — so the default stands above a typical clip. A session set to a long duration wants a higher `cost`.

```javascript
tools: {
  music: { run: api.tools.music, cost: 40, options: { duration: 45 } },
}
```

## What it is for {#use}

A bed under a narration, a short sting, an ambience behind a generated clip. For anything longer or more precise than that, the clip is a starting point and not the deliverable.

- [voice](/sdk/ref/tools/voice): Words, read aloud.
- [create_music](/sdk/agent/tools/create-music): The local engine's version.
- [api.tools](/sdk/ref/tools): The fifteen, and the two ways to use them.

```python
writer = api.models.create(model="gemini-3.5-flash")
composer = api.models.create(
    model="lyria-2",
    settings={"duration": 15, "tempoBpm": 96},
)

agent = api.agents.create(
    model={"main": writer, "music": composer},
    tools={"music": api.tools.music},
)
```

```python
import base64

track = next(a for a in run["artifacts"] if a["type"] == "audio")
pc.files.write("Audio/bed.wav", base64.b64decode(track["content"]))
```

```python
tools = {
    "music": {"run": api.tools.music, "cost": 40, "options": {"duration": 45}},
}
```
