Skip to main content

Overview

The Grant API provides rapid video generation optimized for speed and real-time applications. This endpoint prioritizes quick turnaround times while maintaining good quality, making it perfect for answering quick questions and handling multiple sequential queries. Ideal for social media content, quick demos, and interactive applications.
Grant videos generate in 20-30 seconds, ideal for applications requiring immediate video output.

WebSocket Endpoint

wss://50fa8sjxo9.execute-api.us-west-2.amazonaws.com/production

Authentication

Include your API key in the WebSocket payload:
{
  "api_key": "YOUR_API_KEY"
}

Request Parameters

action
string
required
Must be set to "finetuned_live_gen"
task
string
required
The content or topic for your video (e.g., “explain integrals”)
api_key
string
required
Your Knowlify API key for authentication

Code Examples

import asyncio
import websockets
import json

task = r'''
explain integrals
'''

async def send_request(task):
    print("Sending request...")
    uri = "wss://50fa8sjxo9.execute-api.us-west-2.amazonaws.com/production"

    async with websockets.connect(uri) as websocket:
        payload = {
            "action": "finetuned_live_gen",
            "task": task,
            "api_key": "YOUR_API_KEY"
        }
        await websocket.send(json.dumps(payload))

        while True:
            try:
                response = await websocket.recv()
                print("Received response:", response)
            except websockets.exceptions.ConnectionClosed:
                print("Connection closed by the server.")
                break

if __name__ == "__main__":
    asyncio.run(send_request(task))

WebSocket Responses

The WebSocket connection will send real-time updates throughout the video generation process:

Progress Updates

{
  "type": "progress",
  "message": "Generating video...",
  "progress": 45
}

Completion Response

{
  "video_link": "https://knowlify-videos1.s3.us-west-2.amazonaws.com/video.mp4",
  "vtt_file": "https://knowlify-videos1.s3.us-west-2.amazonaws.com/subtitles.vtt",
  "status": "completed"
}

Error Response

{
  "type": "error", 
  "message": "Invalid API key",
  "error_code": "AUTH_FAILED"
}

Response Fields

Download URL for the generated video
vtt_file
string
URL for the WebVTT subtitle file with synchronized captions
status
string
Generation status: completed, failed
progress
number
Generation progress as percentage (0-100) - only in progress messages
message
string
Human-readable status message - only in progress and error messages
error_code
string
Error code for debugging - only in error messages