Skip to main content
Glama

add_audio

Add audio to generated videos by providing a prompt and generation ID, enabling synchronized sound creation for visual content.

Instructions

Adds audio to a video generation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
generation_idYes
promptYes
negative_promptNo
callback_urlNo

Implementation Reference

  • The main handler function for the 'add_audio' tool. It validates parameters, constructs the request to the Luma API to add audio to a video generation, and returns the status.
    async def add_audio(parameters: dict) -> str: """Add audio to a video generation.""" try: generation_id = parameters.get("generation_id") if not generation_id: raise ValueError("generation_id parameter is required") prompt = parameters.get("prompt") if not prompt: raise ValueError("prompt parameter is required") request_data = {"generation_type": "add_audio", "prompt": prompt} if "negative_prompt" in parameters: request_data["negative_prompt"] = parameters["negative_prompt"] result = await _make_luma_request( "POST", f"/generations/{generation_id}/audio", request_data ) return ( f"Audio generation initiated for generation {generation_id}\n" f"Status: {result['state']}\n" f"Prompt: {prompt}" ) except Exception as e: logger.error(f"Error in add_audio: {str(e)}", exc_info=True) return f"Error adding audio to generation {generation_id}: {str(e)}"
  • Pydantic input schema for the 'add_audio' tool, defining required generation_id and prompt, with optional negative_prompt and callback_url.
    class AddAudioInput(BaseModel): generation_id: str prompt: str negative_prompt: Optional[str] = None callback_url: Optional[str] = None
  • Tool registration in the MCP server's list_tools() function, specifying name, description, and input schema for 'add_audio'.
    Tool( name=LumaTools.ADD_AUDIO, description="Adds audio to a video generation", inputSchema=AddAudioInput.model_json_schema(), ),
  • Dispatcher in call_tool() that routes calls to the 'add_audio' handler function.
    case LumaTools.ADD_AUDIO: result = await add_audio(arguments) return [TextContent(type="text", text=result)]
  • Enum value in LumaTools defining the tool name 'add_audio'.
    ADD_AUDIO = "add_audio"

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/bobtista/luma-ai-mcp-server'

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