Skip to main content
Glama

generate_audio

Convert text prompts into speech or music audio files using the Pollinations API, returning downloadable URLs for generated content.

Instructions

Generate audio (speech or music) using Pollinations API. Returns a URL to the generated audio.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesText for speech or music prompt
modelNoAudio modelelevenlabs
voiceNoVoice (elevenlabs only)nova

Implementation Reference

  • Handler function that executes the audio generation logic using the Pollinations API.
    export async function handleGenerateAudio(
      args: z.infer<typeof generateAudioSchema>
    ) {
      const model = getModel(args.model);
      if (!model || model.type !== "audio") {
        return {
          content: [
            {
              type: "text" as const,
              text: `Unknown audio model: ${args.model}. Use list_models to see available models.`,
            },
          ],
          isError: true,
        };
      }
      if (!API_KEY) {
        return {
          content: [
            {
              type: "text" as const,
              text: `Audio models require a Pollinations API key. Set POLLINATIONS_API_KEY env variable.`,
            },
          ],
          isError: true,
        };
      }
    
      const params = new URLSearchParams({
        model: args.model,
      });
      if (args.model === "elevenlabs") {
        params.set("voice", args.voice);
      }
      if (API_KEY) params.set("token", API_KEY);
    
      const encodedPrompt = encodeURIComponent(args.prompt);
      const url = `https://gen.pollinations.ai/audio/${encodedPrompt}?${params}`;
    
      const info =
        args.model === "elevenlabs"
          ? `Voice: ${args.voice}`
          : "Type: Music generation";
    
      return {
        content: [
          {
            type: "text" as const,
            text: [
              `Audio generated successfully!`,
              `Model: ${model.name}`,
              info,
              `URL: ${url}`,
            ].join("\n"),
          },
        ],
      };
    }
  • Zod schema defining input validation for the generate_audio tool.
    export const generateAudioSchema = z.object({
      prompt: z.string().describe("Text for speech or music prompt"),
      model: z
        .enum(["elevenlabs", "elevenmusic"])
        .default("elevenlabs")
        .describe("Audio model"),
      voice: z
        .enum(["alloy", "echo", "fable", "onyx", "nova", "shimmer"])
        .default("nova")
        .describe("Voice (elevenlabs only)"),
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that the tool returns a URL, which is useful, but lacks critical details such as rate limits, authentication requirements, cost implications, or error handling. For a generative tool with external API calls, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with two sentences that directly state the tool's function and output. Every word earns its place, and it's front-loaded with the core purpose, making it efficient and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of an audio generation tool with no annotations and no output schema, the description is incomplete. It lacks details on output format (e.g., audio file type, duration), error cases, or integration context, which are essential for effective tool use by an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds no additional meaning beyond what's in the schema, such as explaining prompt formatting or model selection criteria. This meets the baseline for high schema coverage but doesn't enhance parameter understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Generate audio'), the resource ('speech or music'), and the method ('using Pollinations API'). It distinguishes from siblings like generate_image and generate_video by specifying audio generation. However, it doesn't explicitly differentiate from generate_batch which might also handle audio, keeping it from a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like generate_batch or other audio-related tools. It mentions the API but doesn't specify use cases, prerequisites, or exclusions, leaving the agent with minimal contextual direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/doctorm333/promptpilot-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server