api.tools

voice

tools: { voice: api.tools.voice }, model: { main, voice }

Lets a run read text aloud. A declaration resolved against a session named voice — and the text it speaks is the text it was given, word for word.

declaration onlyneeds a voice sessiondeclared cost 8
Using Python?

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

Nothing to call. The audio comes from a model session handed to the run under the name voice.

Declaring it

const writer = await api.models.create({ model: "gemini-3.5-flash" });
const speaker = await api.models.create({
  model: "gemini-3.5-flash-tts",
  settings: { voice: "Kore" },
});

const agent = api.agents.create({
  model: { main: writer, voice: speaker },
  tools: { voice: api.tools.voice },
});
writer = api.models.create(model="gemini-3.5-flash")
speaker = api.models.create(
    model="gemini-3.5-flash-tts",
    settings={"voice": "Kore"},
)

agent = api.agents.create(
    model={"main": writer, "voice": speaker},
    tools={"voice": api.tools.voice},
)

What the model sends

textstringrequired

The exact words to speak. Not a description of them.

This is the one tool whose argument is the output

Every other media tool takes a description and invents the rest. Here the argument is read out as it is, so « summarise the report and read it » means the model must write the summary into text — and the description says exactly that, because a model given a vague parameter would narrate instead.

Where the audio goes

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

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

The declared cost is 8

The cheapest of the four, and it is still an over-estimate: speech is priced on the characters spoken, and the guard has to decide before the text exists. A long reading costs more than one call's worth of the default — set cost higher when a run is meant to read whole documents.

tools: {
  voice: { run: api.tools.voice, cost: 20, options: { voice: "Puck" } },
}
tools = {
    "voice": {"run": api.tools.voice, "cost": 20, "options": {"voice": "Puck"}},
}

The voice is the session's

Which voice, and anything else the model takes, is in the session's settings — or pinned per call with options. The model chooses the words, never the speaker.

Break a long reading up

One call carries one block of text through the turn. For a long document, have the run read it section by section and join the clips yourself — which also gives you a file per section rather than one you cannot navigate.