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
| Name | Required | Description | Default |
|---|---|---|---|
| generation_id | Yes | ||
| prompt | Yes | ||
| negative_prompt | No | ||
| callback_url | No |
Implementation Reference
- src/luma_ai_mcp_server/server.py:401-427 (handler)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
- src/luma_ai_mcp_server/server.py:528-532 (registration)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(), ),
- src/luma_ai_mcp_server/server.py:579-581 (registration)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"