api.tools

music

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.

declaration onlyneeds a music sessiondeclared cost 15
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

Nothing to call. The clip comes from a model session handed to the run under the name music.

Declaring it

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 },
});
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},
)

What the model sends

promptstringrequired

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

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

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

Music and speech are both audio artifacts

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

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.

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

What it is for

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.