Skip to main content
Glama
xujfcn
by xujfcn

generate_video

Create AI-generated videos from text prompts using models like Sora 2, Kling V2, Veo 3, and Pika through the Crazyrouter MCP server.

Instructions

Generate videos using AI models via Crazyrouter. Supports Sora 2, Kling V2, Veo 3, Seedance, Pika, and more.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesText description of the video to generate
modelNoVideo generation model to use (default: kling-v2-1). Options: sora-2, kling-v2-1, veo3, doubao-seedance-1-5-pro_720p, pika-1.5, runway-vip-video, MiniMax-Hailuo-2.3kling-v2-1

Implementation Reference

  • The handler function for the generate_video tool, which makes a POST request to an API endpoint to initiate video generation.
    async ({ prompt, model }) => {
      try {
        const body: Record<string, unknown> = {
          model,
          messages: [{ role: "user", content: prompt }],
        };
    
        const result = (await apiRequest("/chat/completions", {
          method: "POST",
          body,
        })) as { choices?: Array<{ message?: { content?: string } }>; video_url?: string };
    
        const content = result.choices?.[0]?.message?.content ?? "Video generation initiated.";
        const videoUrl = result.video_url;
    
        let text = `🎬 Video generation with ${model}:\n\n`;
        if (videoUrl) text += `**Video URL:** ${videoUrl}\n\n`;
        text += content;
    
        return { content: [{ type: "text" as const, text }] };
      } catch (error) {
        const message = error instanceof Error ? error.message : "Unknown error occurred";
        return { content: [{ type: "text" as const, text: `Error: ${message}` }], isError: true };
      }
    }
  • src/index.ts:277-312 (registration)
    The MCP tool registration for 'generate_video', defining the tool's name, description, and input schema.
    server.tool(
      "generate_video",
      "Generate videos using AI models via Crazyrouter. Supports Sora 2, Kling V2, Veo 3, Seedance, Pika, and more.",
      {
        prompt: z.string().describe("Text description of the video to generate"),
        model: z
          .string()
          .default(DEFAULT_VIDEO_MODEL)
          .describe(`Video generation model to use (default: ${DEFAULT_VIDEO_MODEL}). Options: sora-2, kling-v2-1, veo3, doubao-seedance-1-5-pro_720p, pika-1.5, runway-vip-video, MiniMax-Hailuo-2.3`),
      },
      async ({ prompt, model }) => {
        try {
          const body: Record<string, unknown> = {
            model,
            messages: [{ role: "user", content: prompt }],
          };
    
          const result = (await apiRequest("/chat/completions", {
            method: "POST",
            body,
          })) as { choices?: Array<{ message?: { content?: string } }>; video_url?: string };
    
          const content = result.choices?.[0]?.message?.content ?? "Video generation initiated.";
          const videoUrl = result.video_url;
    
          let text = `🎬 Video generation with ${model}:\n\n`;
          if (videoUrl) text += `**Video URL:** ${videoUrl}\n\n`;
          text += content;
    
          return { content: [{ type: "text" as const, text }] };
        } catch (error) {
          const message = error instanceof Error ? error.message : "Unknown error occurred";
          return { content: [{ type: "text" as const, text: `Error: ${message}` }], isError: true };
        }
      }
    );
  • The input schema for 'generate_video', defining the 'prompt' and 'model' parameters.
    {
      prompt: z.string().describe("Text description of the video to generate"),
      model: z
        .string()
        .default(DEFAULT_VIDEO_MODEL)
        .describe(`Video generation model to use (default: ${DEFAULT_VIDEO_MODEL}). Options: sora-2, kling-v2-1, veo3, doubao-seedance-1-5-pro_720p, pika-1.5, runway-vip-video, MiniMax-Hailuo-2.3`),
    },
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/xujfcn/crazyrouter-mcp'

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