Skip to main content
Glama

image_to_video

Convert static images into animated videos with Ghibli-style aesthetics using AI video generation. Transform photos into motion by providing an image and optional prompts.

Instructions

Convert image to animated video

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageYesBase64 encoded source image or image URL
promptNoOptional prompt for video generation
aspect_ratioNoAspect ratio of the output video (e.g. '9:16')9:16
negative_promptNoNegative prompt to guide generationbad prompt
api_keyYesAPI key for authentication

Implementation Reference

  • Core handler function in GhibliClient that performs the image-to-video conversion by making a POST request to the external API (/api/video) and returns the task ID.
    async imageToVideo( sourceImage: string, prompt: string = "in the style of ghibli", aspectRatio: string = "9:16", negativePrompt: string = "bad prompt", apiKey: string ): Promise<string> { const payload = { prompt, task_type: "img2video-14b", negative_prompt: negativePrompt, aspect_ratio: aspectRatio, image: sourceImage }; // 打印请求信息 process.stderr.write(`\n[Request] POST ${this.baseUrl}/api/video\n`); process.stderr.write(`[Headers] ${JSON.stringify(this.getHeaders(apiKey), null, 2)}\n`); process.stderr.write(`[Payload] Image length: ${sourceImage.length}, Prompt: ${prompt}\n`); const response = await fetch(`${this.baseUrl}/api/video`, { method: 'POST', headers: this.getHeaders(apiKey), body: JSON.stringify(payload) }); // 打印响应状态 process.stderr.write(`[Response] Status: ${response.status} ${response.statusText}\n`); if (!response.ok) { const error = `API request failed: ${response.statusText}`; process.stderr.write(`[Error] ${error}\n`); throw new Error(error); } const result = await response.json(); process.stderr.write(`[Response Data] ${JSON.stringify(result, null, 2)}\n`); return result.data?.task_id; }
  • src/index.ts:48-79 (registration)
    Registers the 'image_to_video' tool in the MCP server's list of available tools, defining its name, description, and input schema.
    { name: "image_to_video", description: "Convert image to animated video", inputSchema: { type: "object", properties: { image: { type: "string", description: "Base64 encoded source image or image URL" }, prompt: { type: "string", description: "Optional prompt for video generation" }, aspect_ratio: { type: "string", description: "Aspect ratio of the output video (e.g. '9:16')", default: "9:16" }, negative_prompt: { type: "string", description: "Negative prompt to guide generation", default: "bad prompt" }, api_key: { type: "string", description: "API key for authentication" } }, required: ["image", "api_key"] } },
  • MCP CallToolRequest handler case for 'image_to_video' that extracts arguments, validates inputs, delegates to GhibliClient.imageToVideo, and formats the response.
    case "image_to_video": { const image = String(request.params.arguments?.image); const prompt = String(request.params.arguments?.prompt || "in the style of ghibli"); const aspectRatio = String(request.params.arguments?.aspect_ratio || "9:16"); const negativePrompt = String(request.params.arguments?.negative_prompt || "bad prompt"); const apiKey = String(request.params.arguments?.api_key); if (!image) { throw new Error("Source image cannot be empty"); } if (!apiKey) { throw new Error("API key cannot be empty"); } try { const result = await ghibliClient.imageToVideo( image, prompt, aspectRatio, negativePrompt, apiKey ); return { content: [{ type: "text", text: `Video generation taskid: ${result}` }] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; throw new Error(`Video generation failed: ${errorMessage}`); } }
  • Input schema defining the parameters for the 'image_to_video' tool, including types, descriptions, defaults, and required fields.
    inputSchema: { type: "object", properties: { image: { type: "string", description: "Base64 encoded source image or image URL" }, prompt: { type: "string", description: "Optional prompt for video generation" }, aspect_ratio: { type: "string", description: "Aspect ratio of the output video (e.g. '9:16')", default: "9:16" }, negative_prompt: { type: "string", description: "Negative prompt to guide generation", default: "bad prompt" }, api_key: { type: "string", description: "API key for authentication" } }, required: ["image", "api_key"]

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/MichaelYangjson/mcp-ghibli-video'

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