MCPcopy Create free account
hub / github.com/pollinations/pollinations / generateVideo

Function generateVideo

packages/mcp/src/services/imageService.js:333–380  ·  view source on GitHub ↗
(params)

Source from the content-addressed store, hash-verified

331}
332
333async function generateVideo(params) {
334 requireApiKey();
335
336 const {
337 prompt,
338 model = "veo",
339 duration,
340 aspectRatio,
341 audio,
342 image,
343 seed,
344 } = params;
345 const { encodedPrompt, queryParams } = await prepareVideoRequest(params);
346
347 const url = buildUrl(`/image/${encodedPrompt}`, queryParams);
348
349 try {
350 const { buffer, contentType } = await fetchBinaryWithAuth(url);
351 const base64Data = arrayBufferToBase64(buffer);
352
353 const metadata = {
354 prompt,
355 model,
356 duration,
357 aspectRatio,
358 audio: model === "veo" ? audio || false : undefined,
359 hasReferenceImage: !!image,
360 seed,
361 };
362
363 return createMCPResponse([
364 {
365 type: "resource",
366 resource: {
367 uri: `pollinations://video/${Date.now()}`,
368 mimeType: contentType || "video/mp4",
369 blob: base64Data,
370 },
371 },
372 createTextContent(
373 `Generated video from prompt: "${prompt}"\n\nMetadata: ${JSON.stringify(metadata, null, 2)}\n\nVideo returned as base64-encoded resource (decode and save as .mp4)`,
374 ),
375 ]);
376 } catch (error) {
377 console.error("Error generating video:", error);
378 throw error;
379 }
380}
381
382async function generateVideoUrl(params) {
383 requireApiKey();

Callers

nothing calls this directly

Calls 9

requireApiKeyFunction · 0.90
buildUrlFunction · 0.90
fetchBinaryWithAuthFunction · 0.90
arrayBufferToBase64Function · 0.90
createMCPResponseFunction · 0.90
createTextContentFunction · 0.90
prepareVideoRequestFunction · 0.85
stringifyMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected