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.1.tar.gz (11.9 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.1-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: knowlify_ai-0.1.1.tar.gz
  • Upload date:
  • Size: 11.9 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.1.tar.gz
Algorithm Hash digest
SHA256 e819b6a94dc5e944d8780a9ddfca35b11e635510746d05ed77fc1d5f83c9e841
MD5 dbe08181f21f46a92f8278221aa784d8
BLAKE2b-256 efcd535cf72c1bbaa98219cfc49cf4b4b9dcabee7d7fbe90ab0cd0d87f6ffbf3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: knowlify_ai-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.7 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 92e8bf78acbab4f12e652f7d5753e529ed4ed243249aa9038ced3f79022b074a
MD5 474527abc8f6243d7fd30c6b4f086aa5
BLAKE2b-256 2077771033320be3c35003aa57a29c4c3a3897b521c37e812308ccfb88ed73a0

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