Smallest AI

Generate natural speech using Smallest AI's Lightning text-to-speech models.

SmallestTools enable an Agent to generate natural speech and list available voices using Smallest AI Lightning text-to-speech.

Prerequisites

Get a Smallest AI key from the Smallest AI dashboard under Developer > API Keys. SmallestTools uses Agno's built-in HTTP client. The example uses Gemini as its agent model.

uv pip install -U "agno[google]"

Set both API keys:

export SMALLEST_API_KEY="your_smallest_api_key_here"
export GOOGLE_API_KEY="your_google_api_key_here"

Example

The following agent will use Smallest AI to generate audio based on a user prompt.

cookbook/91_tools/smallest_tools.py
import base64

from agno.agent import Agent
from agno.models.google import Gemini
from agno.tools.smallest import SmallestTools
from agno.utils.media import save_base64_data

audio_agent = Agent(
    model=Gemini(id="gemini-pro-latest"),
    tools=[
        SmallestTools(
            voice_id="magnus",
            model="lightning_v3.1",
        )
    ],
    description="You are an AI agent that can generate audio using the Smallest AI API.",
    instructions=[
        "Use the `text_to_speech` tool to convert text into natural voice audio.",
        "Use the `get_voices` tool to list the available voices.",
    ],
    markdown=True,
)

response = audio_agent.run(
    "Generate a short audio welcoming listeners to a podcast about the history of aviation."
)

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/podcast_welcome.wav")

Advanced Example: Premium Voices with Lightning v3.1 Pro

For broadcast-quality voices across American, British, and Indian accents, switch to the Pro voice pool:

from agno.agent import Agent
from agno.models.google import Gemini
from agno.tools.smallest import SmallestTools

pro_audio_agent = Agent(
    model=Gemini(id="gemini-pro-latest"),
    tools=[
        SmallestTools(
            voice_id="meher",
            model="lightning_v3.1_pro",
        )
    ],
    description="You are an AI agent that can generate premium audio using the Smallest AI API.",
    markdown=True,
)

response = pro_audio_agent.run("Generate a short audio narrating a movie trailer.")

Pair voices with the right model: Pro voices (e.g. meher) require model="lightning_v3.1_pro"; standard voices (e.g. magnus) use the default lightning_v3.1. Cloned voices are only available on lightning_v3.1.

Toolkit Params

ParameterTypeDefaultDescription
voice_idstrmagnusDefault voice to use for synthesis.
api_keyOptional[str]NoneThe Smallest AI API key for authentication. If not provided, uses the SMALLEST_API_KEY env variable.
modelstrlightning_v3.1TTS model. One of lightning_v3.1, lightning_v3.1_pro. An invalid value raises a ValueError up front.
languagestrenISO 639-1 language code for synthesis.
sample_rateint24000Output sample rate in Hz.
speedfloat1.0Speech speed multiplier.
output_formatstrwavAudio output format. One of wav, mp3, pcm, ulaw, alaw.
target_directoryOptional[str]NoneIf set, generated audio is also saved to this directory.
base_urlstrSmallest AI TTS endpointOverride the TTS endpoint — useful for self-hosted or region-pinned deployments.
enable_get_voicesboolTrueEnable the get_voices functionality.
enable_text_to_speechboolTrueEnable the text_to_speech functionality.
allboolFalseEnable all functionality.
timeoutfloat30HTTP request timeout in seconds.

Toolkit Functions

FunctionDescription
text_to_speechConvert text to speech. Detects non-audio responses (e.g. a JSON error body on an HTTP 200) and surfaces them as a tool error instead of saving corrupt audio.
get_voicesGet the list of voices available for the configured model. Normalizes the response to {id, name, gender, accent, languages} regardless of the API's raw shape.

Models

ModelLanguagesNotes
lightning_v3.1model cardDefault. Supports cloned voices.
lightning_v3.1_promodel cardPremium voice pool. No voice cloning.

Developer Resources