Skip to main content

Turn your Python code into an explanatory video by calling knowlify.create('fast'|'detailed').

Project description

Knowlify Python SDK

Turn your Python code into explanatory videos with a simple function call.

Installation

pip install knowlify-ai

Quick Start

import knowlify

# Initialize with your API key
knowlify.init(api_key="your-api-key-here")

# Create a video from code above this call
def fibonacci(n):
    if n <= 1:
        return n
    return fibonacci(n-1) + fibonacci(n-2)

# Generate video
knowlify.create()  # defaults to "fast" mode

API Reference

knowlify.init(api_key: str)

Initialize Knowlify with your API key.

Parameters:

  • api_key (str): Your Knowlify API key

Example:

knowlify.init(api_key="your-secret-key")

knowlify.create(mode="fast", wait=False, *, function=None, task=None)

Create a video from your code.

Parameters:

  • mode (str): Video generation mode - "fast" or "detailed" (default: "fast")
  • wait (bool): Whether to wait for completion (default: False)
  • function (str, optional): Specific function name to capture (e.g., "my_func" or "MyClass.method")
  • task (str, optional): Custom task description (overrides code capture)

Returns:

  • str: Video URL if wait=True, empty string if wait=False

Examples:

# Capture code above the call
knowlify.create()

# Capture specific function
knowlify.create(function="fibonacci")

# Capture class method
knowlify.create(function="MyClass.calculate")

# Custom task
knowlify.create(task="explain this sorting algorithm")

# Detailed mode with wait
url = knowlify.create(mode="detailed", wait=True)
print(f"Video URL: {url}")

knowlify.start() and knowlify.end(mode="fast", wait=False)

Capture code between start and end markers.

Example:

knowlify.start()

# Your code here
def complex_algorithm():
    # ... complex logic ...
    return result

knowlify.end()  # Generates video of code between start() and end()

Modes

  • "fast": Quick generation, good for simple explanations
  • "detailed": More comprehensive, better for complex topics

Error Handling

import knowlify

try:
    knowlify.create()
except knowlify.InvalidAPIKeyError:
    print("Invalid API key")
except knowlify.OutOfMinutesError:
    print("Out of minutes")
except knowlify.KnowlifyAPIError as e:
    print(f"API error: {e}")

Output

  • Non-blocking mode (wait=False): Videos save to ./knowlify_videos/ in background
  • Blocking mode (wait=True): Returns video URL and saves locally

Requirements

  • Python 3.8+
  • Valid Knowlify API key

License

MIT License - see LICENSE file for details.

Support

Visit knowlify.com for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

knowlify_ai-0.1.0.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

knowlify_ai-0.1.0-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file knowlify_ai-0.1.0.tar.gz.

File metadata

  • Download URL: knowlify_ai-0.1.0.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for knowlify_ai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7897395608bebab67706875300db2543c764342440e16fdd8637a3f8c7265103
MD5 55bb3f075ee87ecfc13c7350fdfafcdb
BLAKE2b-256 9bc384167fcb344076a78f08a17f06cdb44426e44c74c4f83eb58f2a0408c347

See more details on using hashes here.

File details

Details for the file knowlify_ai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: knowlify_ai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for knowlify_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b7a82db511478d05c48933dc336c6a2729e8edc5d1ee8d0989c25bfff66bdeb3
MD5 6f818ee2ece10ae5e453fb290d3b95a4
BLAKE2b-256 1f6b6bb0e2531a37241e8b5cd2f25bd778b42832fbaabb0619d220212ca7a690

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page