{"id":9403,"library":"vonage-video","title":"Vonage Video (API Client)","description":"The `vonage-video` package provides programmatic access to the Vonage Video API, enabling server-side applications to manage video sessions, tokens, archives, and broadcasts. While it exists as a standalone PyPI package, it is primarily designed to be installed as a dependency of the main `vonage` Python SDK (currently v4.x.x). The `vonage` SDK is the recommended entry point for interacting with all Vonage APIs, including Video. Vonage maintains an active release cadence for its SDKs, with frequent updates and improvements.","status":"active","version":"1.5.1","language":"en","source_language":"en","source_url":"https://github.com/Vonage/vonage-python-sdk/tree/main/src/vonage_video","tags":["video","communication","api","vonage","webrtc","tokbox"],"install":[{"cmd":"pip install vonage","lang":"bash","label":"Recommended: Install via main Vonage SDK"},{"cmd":"pip install vonage-video","lang":"bash","label":"Direct installation (not recommended for most use cases)"}],"dependencies":[{"reason":"Used extensively for data models and type enforcement within the Vonage Python SDK, including video API components.","package":"pydantic","optional":false}],"imports":[{"note":"The recommended way to access Video API functionality is through the main `vonage` client.","symbol":"Vonage","correct":"from vonage import Vonage, Auth"},{"note":"Data models for Video API methods are imported directly from `vonage_video`, not nested under `vonage.video`.","wrong":"from vonage.video import SessionOptions","symbol":"SessionOptions","correct":"from vonage_video import SessionOptions"},{"note":"Constants like MediaMode are found within the `vonage_video.constants` submodule.","symbol":"MediaMode","correct":"from vonage_video.constants import MediaMode"}],"quickstart":{"code":"import os\nfrom vonage import Vonage, Auth\nfrom vonage_video.constants import MediaMode\nfrom vonage_video import SessionOptions\n\n# Replace with your actual Vonage Application ID and Private Key path\n# Obtain these from your Vonage Dashboard after creating a Video-enabled application.\nVONAGE_APPLICATION_ID = os.environ.get('VONAGE_APPLICATION_ID', 'YOUR_APPLICATION_ID')\nVONAGE_PRIVATE_KEY_PATH = os.environ.get('VONAGE_PRIVATE_KEY_PATH', 'path/to/your/private.key')\n\nif VONAGE_APPLICATION_ID == 'YOUR_APPLICATION_ID' or not os.path.exists(VONAGE_PRIVATE_KEY_PATH):\n    print(\"Please set VONAGE_APPLICATION_ID environment variable and VONAGE_PRIVATE_KEY_PATH, and ensure the private key file exists.\")\n    print(\"Refer to https://developer.vonage.com/en/messages/application/create for creating an application.\")\nelse:\n    try:\n        auth = Auth(\n            application_id=VONAGE_APPLICATION_ID,\n            private_key=VONAGE_PRIVATE_KEY_PATH,\n        )\n        client = Vonage(auth=auth)\n\n        # Create a session\n        session_options = SessionOptions(media_mode=MediaMode.ROUTED)\n        session = client.video.create_session(session_options)\n        session_id = session.session_id\n        print(f\"Created Session ID: {session_id}\")\n\n        # Generate a token for a client to connect to the session\n        token = client.video.generate_client_token(session_id)\n        print(f\"Generated Client Token: {token}\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to initialize the Vonage client, create a video session, and generate a client token. It uses environment variables for authentication credentials, which is recommended for security. Ensure you have a Vonage Application with Video capabilities enabled and the corresponding Application ID and Private Key file."},"warnings":[{"fix":"Refer to the official 'OpenTok to Vonage Video Server SDK Transition Guide (Python)' for detailed migration steps. Update method calls, parameter structures, and authentication mechanisms.","message":"Migration from OpenTok Python SDK to Vonage Python SDK requires significant changes. Positional parameters are replaced with data models, methods return Pydantic data models, and some method names have changed. Authentication now primarily uses Application ID and Private Key (for JWTs) instead of API Key and Secret for Video API operations.","severity":"breaking","affected_versions":"All versions when migrating from 'opentok' SDK"},{"fix":"Always install `pip install vonage` to get the full Vonage Python SDK. Access Video API functionality via `client = Vonage(auth=...); client.video.create_session(...)`.","message":"While `vonage-video` exists on PyPI, it's typically installed as a dependency of the main `vonage` SDK. Directly installing `vonage-video` and trying to use its classes might lead to missing broader SDK context or unexpected behavior, especially for API client instantiation.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure you have created a Vonage Application with the 'Video' capability enabled in your Vonage Dashboard. Download the private key file and use its path along with the Application ID for `Auth` initialization.","message":"Authentication for the Vonage Video API uses an Application ID and a Private Key (for JWT generation). The traditional API Key and Secret are generally used for other Vonage APIs (like SMS, Voice) but not directly for Video API calls through the `vonage` client.","severity":"gotcha","affected_versions":"All versions of `vonage` SDK accessing Video API"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure you have the latest `vonage` SDK installed: `pip install --upgrade vonage`. If the issue persists, check Python environment and dependencies.","cause":"The installed `vonage` SDK version might be too old or `vonage-video` (as a dependency) might not be correctly installed/available, preventing the `video` module from being attached to the client.","error":"AttributeError: 'Vonage' object has no attribute 'video'"},{"fix":"If migrating, update your code to use the `vonage` SDK and its `client.video` methods and `vonage_video` data models. If it's a new project, ensure you are not importing `opentok` and are using `vonage` instead.","cause":"This error occurs when trying to run code written for the legacy `opentok` SDK after migrating to the `vonage` SDK or when `opentok` was never installed.","error":"ModuleNotFoundError: No module named 'opentok'"},{"fix":"Change the import statement to `from vonage_video import SessionOptions` (and similar for other models).","cause":"While `client.video` provides access to methods, data models like `SessionOptions` are imported directly from the top-level `vonage_video` package, not a nested submodule of `vonage`.","error":"from vonage.video import SessionOptions # ModuleNotFoundError: No module named 'vonage.video'"}]}