Eleven Labs

Generate speech and sound effects from text using the ElevenLabs API.

ElevenLabsTools enable an Agent to perform audio generation tasks using ElevenLabs

Prerequisites

You need to install the elevenlabs library and an API key which can be obtained from Eleven Labs

uv pip install agno elevenlabs google-genai

Set the ELEVEN_LABS_API_KEY environment variable.

export ELEVEN_LABS_API_KEY=****

The agent uses Gemini separately from ElevenLabs. Set its model key in the same terminal:

export GOOGLE_API_KEY="your-google-api-key"

Example

The following agent will use Eleven Labs to generate audio based on a user prompt.

cookbook/91_tools/elevenlabs_tools.py
import base64

from agno.agent import Agent
from agno.models.google import Gemini
from agno.tools.eleven_labs import ElevenLabsTools
from agno.utils.media import save_base64_data

audio_agent = Agent(
    model=Gemini(id="gemini-2.5-pro"),
    tools=[
        ElevenLabsTools(
            voice_id="21m00Tcm4TlvDq8ikWAM",
            model_id="eleven_multilingual_v2",
        )
    ],
    description="You are an AI agent that can generate audio using the ElevenLabs API.",
    instructions=[
        "Use the `text_to_speech` tool to convert text into natural voice audio.",
        "Use the `generate_sound_effect` tool to create sound effects from text descriptions.",
    ],
    markdown=True,
)

response = audio_agent.run("Generate an audio summary of the french revolution")

if response.audio:
    print("Agent response:", response.content)
    base64_audio = base64.b64encode(response.audio[0].content).decode("utf-8")
    save_base64_data(base64_audio, "tmp/french_revolution.mp3")

Toolkit Params

ParameterTypeDefaultDescription
api_keyOptional[str]NoneThe Eleven Labs API key for authentication
voice_idstrJBFqnCBsd6RMkjVDRZzbThe voice ID to use for the audio generation
target_directoryOptional[str]NoneThe directory to save the audio file
model_idstreleven_multilingual_v2The model's id to use for the audio generation
output_formatstrmp3_44100_64The output format to use for the audio generation (see the docs)
enable_text_to_speechboolTrueEnable the text_to_speech functionality.
enable_generate_sound_effectboolTrueEnable the generate_sound_effect functionality.
enable_get_voicesboolTrueEnable the get_voices functionality.
allboolFalseEnable all functionality.

Toolkit Functions

FunctionDescription
text_to_speechConvert text to speech
generate_sound_effectGenerate sound effect audio from a text prompt.
get_voicesGet the list of voices available

Developer Resources