Skip to main content

vmodal Python SDK

Async-first Python SDK for the VMX external API. The SDK is published on PyPI under the MIT License.

Install

pip install vmodal

Upgrade or uninstall:

pip install --upgrade vmodal
pip uninstall vmodal

Configure authentication

Obtain an API key through your v-modal account administrator. API keys are Bearer credentials: keep them out of source control, rotate them in the account administration surface, and replace VMODAL_API_KEY after a rotation.

export VMODAL_API_KEY=ak_xxx

Client.from_env() and SyncClient.from_env() select the hosted public service and resolve the account identity associated with the key.

An invalid or expired token raises AuthError with status 401. A valid token without the required permission raises ApiError with status 403. Rotate a token by replacing the environment value. Cached identity information is encrypted and stored in the operating system's user-cache directory.

Verify authentication

from vmodal import SyncClient

client = SyncClient.from_env()
print(client.auth())

Successful output:

VMODAL_API_KEY is valid, authenticated correctly (user_id=user_abc)

Simple usage examples

Check authentication and API health:

from vmodal import SyncClient

client = SyncClient.from_env()
print(client.auth())
print(client.health())

Search videos:

from vmodal import SyncClient

client = SyncClient.from_env()
result = client.searches.search_video(
    query_text="alien",
    mode="vid_file",
    group_name="newsalien2",
    stream_name="astream",
    search_sources=["image"],
    search_combine_mode="union",
    limit=10,
    image_emb_score_min=1.5,
    tracking_id="readme_search",
)
print(result)

Upload a video:

from vmodal import SyncClient

client = SyncClient.from_env()
result = client.collections.video_upload(
    filepath_local="/path/to/video.mp4",
    collection_name="newsalien2",
    sub_collection_name="astream",
    mode="vid_file",
    modality="vid_raw",
)
print(result)

Files of 100 MiB or more automatically use resumable multipart upload (64 MiB parts, four concurrent part uploads). To force it for a smaller file or tune the part size:

result = client.collections.video_upload(
    "/path/to/video.mp4",
    "newsalien2",
    "astream",
    multipart=True,
    part_size_bytes=64 * 1024 * 1024,
)

More examples

Async usage

import asyncio
from vmodal import Client

async def main():
    async with Client.from_env() as client:
        return await client.searches.search_video(
            query_text="example",
            mode="vid_file",
            group_name="agroup",
        )

asyncio.run(main())

CLI

vmodal health
vmodal search_video --query_text=example --group_name=agroup --mode=vid_file
python -m vmodal.cli video_upload --filepath_local=/path/to/video.mp4 --collection_name=agroup --sub_collection_name=astream

See the endpoint map, configuration reference, and support policy.

Metadata

Release files for vmodal 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vmodal 1.0.0
File Size Uploaded
vmodal-1.0.0.tar.gz 39.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vmodal 1.0.0
File Interpreter ABI Platform
vmodal-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 71.7 kB

Release files / vmodal-1.0.0.tar.gz

Download URL vmodal-1.0.0.tar.gz
Size 39.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c2fc62be3175c463c834ab742163a6b3a4c0f86f5cf4e6c5b0010c3ebd6ddd00
BLAKE2b-256 checksum
How to use checksums
c0522296f1d991b229a5188ec38e4677ebe681c605b5554d477ac5e9c48cde9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / vmodal-1.0.0-py3-none-any.whl

Download URL vmodal-1.0.0-py3-none-any.whl
Size 32.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
344b3d7842dde87c2ea7efc5b2580c479f5c81af4c397a06efc46396d4c8b71b
BLAKE2b-256 checksum
How to use checksums
67a15393849c12298d755de30ad5aaa34d5b2867a301e8e490a3b4a1b4c2b680
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page