Lunos

Documentation

🎬 Video Generation

The Video Generation API allows you to create videos from text prompts using advanced models like Google Veo 3.0. Generate cinematic-quality videos with customizable aspect ratios, negative prompts, and output formats for your creative or business needs.

Note: You need an API key to use this endpoint. See the Quickstart Guide to get started.

How to Generate Videos (Step-by-Step)

  1. Choose your preferred client library or use cURL for direct API calls.
  2. Set your API key and endpoint URL.
  3. Configure the request parameters (prompt, model, aspectRatio, negativePrompt, etc.).
  4. Send the request and receive an operation ID for tracking.
  5. Poll the status endpoint until the video generation is complete.

Endpoint

POST /v1/video/generations

Authentication

All requests must include an Authorization header with a Bearer token:

Authorization: Bearer YOUR_API_KEY

Request Body

1{
2   "model": "google/veo-3.0-generate-preview",
3   "prompt": "A cinematic shot of a majestic lion in the savannah.",
4   "parameters": {
5      "aspectRatio": "16:9",
6      "negativePrompt": "cartoon, drawing, low quality"
7   },
8   "response_format": "mp4"
9}

Parameters

ParameterTypeRequiredDescription
modelstringYesThe model to use for video generation. Currently supports google/veo-3.0-generate-preview.
promptstringYesThe prompt to generate videos for.
parametersobjectNoAdditional parameters for video generation.
parameters.aspectRatiostringNoAspect ratio of the video, currently only supports 16:9.
parameters.negativePromptstringNoNegative prompt to avoid certain elements in the video.
response_formatstringNoThe format of the generated video. Currently only supports mp4. Defaults to mp4 if not specified.

Response

The initial response contains an operation ID for tracking the video generation progress:

1{
2   "id": "video-op:user123:1703123456789",
3   "operation_name": "operations/veo-3.0-generate-preview/123456789",
4   "status": "pending"
5}

Status Check Endpoint

GET /v1/video/generations/{id}

Status Responses

Pending Status

1{
2   "id": "video-op:user123:1703123456789",
3   "status": "pending"
4}

Completed Status

1{
2   "id": "video-op:user123:1703123456789",
3   "status": "completed",
4   "video_url": "https://your-r2-domain.com/user123/1703123456789-video.mp4"
5}

Example: Using cURL

Direct API call for video generation:

1# Start video generation
2curl -X POST http://localhost:8787/v1/video/generations \
3  -H "Authorization: Bearer YOUR_API_KEY" \
4  -H "Content-Type: application/json" \
5  -H "X-App-ID: your-app-id" \
6  -d '{
7    "model": "google/veo-3.0-generate-preview",
8    "prompt": "A cinematic shot of a majestic lion in the savannah.",
9    "parameters": {
10      "aspectRatio": "16:9",
11      "negativePrompt": "cartoon, drawing, low quality"
12    }
13  }'
14
15# Check status (replace with actual operation ID)
16curl -X GET http://localhost:8787/v1/video/generations/video-op:user123:1703123456789 \
17  -H "Authorization: Bearer YOUR_API_KEY" \
18  -H "X-App-ID: your-app-id"

Example: Using JavaScript

Video generation with JavaScript:

1// Start video generation
2const response = await fetch("http://localhost:8787/v1/video/generations", {
3   method: "POST",
4   headers: {
5      Authorization: "Bearer YOUR_API_KEY",
6      "Content-Type": "application/json",
7      "X-App-ID": "your-app-id",
8   },
9   body: JSON.stringify({
10      model: "google/veo-3.0-generate-preview",
11      prompt: "A cinematic shot of a majestic lion in the savannah.",
12      parameters: {
13         aspectRatio: "16:9",
14         negativePrompt: "cartoon, drawing, low quality",
15      },
16      response_format: "mp4",
17   }),
18});
19
20const result = await response.json();
21console.log("Operation ID:", result.id);
22
23// Poll for completion
24const checkStatus = async (operationId) => {
25   const statusResponse = await fetch(
26      `http://localhost:8787/v1/video/generations/${operationId}`,
27      {
28         headers: {
29            Authorization: "Bearer YOUR_API_KEY",
30            "X-App-ID": "your-app-id",
31         },
32      }
33   );
34
35   const status = await statusResponse.json();
36
37   if (status.status === "completed") {
38      console.log("Video URL:", status.video_url);
39      return status.video_url;
40   } else {
41      console.log("Still processing...");
42      // Wait 10 seconds before checking again
43      setTimeout(() => checkStatus(operationId), 10000);
44   }
45};
46
47checkStatus(result.id);

Example: Using Official Lunos Library (JavaScript/TypeScript)

For the best developer experience, use the official Lunos library with built-in TypeScript support:

1import { LunosClient } from '@lunos/client';
2
3// Initialize the client
4const client = new LunosClient({
5   apiKey: 'YOUR_API_KEY',
6   appId: "your-app-id",
7});
8
9// Basic video generation
10const response = await client.video.generateVideo({
11   model: "google/veo-3.0-generate-preview",
12   prompt: "A cinematic shot of a majestic lion in the savannah.",
13   parameters: {
14      aspectRatio: "16:9",
15      negativePrompt: "cartoon, drawing, low quality",
16   },
17   response_format: "mp4",
18   appId: "my-video-app",
19});
20
21console.log("Operation ID:", response.id);
22console.log("Status:", response.status);
23
24// Check video generation status
25const status = await client.video.getVideoStatus(response.id, "my-video-app");
26
27if (status.status === "completed") {
28   console.log("Video URL:", status.video_url);
29}
30
31// Generate and wait for completion
32const result = await client.video.generateAndWait(
33   {
34      prompt: "A beautiful sunset over mountains with birds flying",
35      aspectRatio: "16:9",
36      negativePrompt: "cartoon, animation, low quality",
37   },
38   10000,
39   300000
40); // Poll every 10 seconds, max wait 5 minutes
41
42console.log("Video URL:", result.video_url);
43
44// Convenience methods
45const response = await client.video.generate({
46   prompt: "A futuristic city skyline at night",
47   model: "google/veo-3.0-generate-preview",
48   aspectRatio: "16:9",
49   negativePrompt: "cartoon, low quality, blurry",
50});
51
52const widescreenVideo = await client.video.generateWidescreen({
53   prompt: "A cinematic car chase scene through a busy city",
54   negativePrompt: "cartoon, animation, low quality",
55});
56
57const mp4Video = await client.video.generateMP4({
58   prompt: "A peaceful forest scene with birds chirping",
59   aspectRatio: "16:9",
60});

Video Generation Features

  • Google Veo 3.0 Support: Generate high-quality cinematic videos
  • Aspect Ratio Control: Currently supports 16:9 widescreen format
  • Negative Prompts: Specify what to avoid in the generated video
  • Async Operations: Long-running video generation with status polling
  • Multiple Formats: Support for MP4 output format
  • Convenience Methods: Simplified interfaces for common use cases

Installation: Install the official Lunos library with npm install @lunos/client or yarn add @lunos/client

Example: Using Python

Video generation with Python:

1import requests
2import time
3
4# Start video generation
5response = requests.post(
6    'http://localhost:8787/v1/video/generations',
7    headers={
8        'Authorization': 'Bearer YOUR_API_KEY',
9        'Content-Type': 'application/json',
10        'X-App-ID': 'your-app-id'
11    },
12    json={
13        'model': 'google/veo-3.0-generate-preview',
14        'prompt': 'A cinematic shot of a majestic lion in the savannah.',
15        'parameters': {
16            'aspectRatio': '16:9',
17            'negativePrompt': 'cartoon, drawing, low quality'
18        },
19        'response_format': 'mp4'
20    }
21)
22
23result = response.json()
24operation_id = result['id']
25print(f"Operation ID: {operation_id}")
26
27# Poll for completion
28def check_status(operation_id):
29    while True:
30        status_response = requests.get(
31            f'http://localhost:8787/v1/video/generations/{operation_id}',
32            headers={
33                'Authorization': 'Bearer YOUR_API_KEY',
34                'X-App-ID': 'your-app-id'
35            }
36        )
37
38        status = status_response.json()
39
40        if status['status'] == 'completed':
41            print(f"Video URL: {status['video_url']}")
42            return status['video_url']
43        else:
44            print("Still processing...")
45            time.sleep(10)  # Wait 10 seconds
46
47video_url = check_status(operation_id)

App Tracking: The X-App-ID header allows you to track video generation usage per application. This helps with analytics, billing, and performance monitoring across different apps.

Error Responses

400 Bad Request

1{
2   "error": "Missing required fields: model and prompt"
3}

402 Payment Required

1{
2   "error": "Insufficient balance"
3}

404 Not Found

1{
2   "error": "Model not found"
3}

500 Internal Server Error

1{
2   "error": "Failed to start video generation"
3}

Available Models

Currently, the API supports the following video generation model:

  • google/veo-3.0-generate-preview: Google's Veo 3.0 model for video generation

Important: Your API key is sensitive. Never share it publicly or commit it to version control.

Best Practices & Tips

  • Write detailed, descriptive prompts for better video quality.
  • Match the aspect ratio parameter with your intended output format.
  • Use negative prompts to avoid unwanted elements in your videos.
  • Implement proper error handling for both the initial request and status polling.
  • Use exponential backoff for status polling to avoid overwhelming the API.
  • Consider implementing cleanup logic for old videos to manage storage costs.

Rate Limits

Video generation requests are subject to rate limiting based on your account tier and current usage. Check your account limits before making requests.

Troubleshooting

  • Authentication error: Verify your API key and permissions.
  • Model not found: Check that you're using the correct model ID.
  • Insufficient balance: Ensure your account has sufficient credits for video generation.
  • Status polling issues: Implement proper retry logic with exponential backoff.
  • Video generation failures: Check your prompt quality and parameters.