Skip to main content

Thin Python SDK for the VMX external API

Project description

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

This is the complete public configuration. Client.from_env() and SyncClient.from_env() select the production gateway and call /api/v1/auth/me to derive and cache user_id, tenant_id, and email from 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; the encrypted identity cache is token-scoped and stored in the operating system's user-cache directory.

The old VMODAL_API_TOKEN and TEST_CLIENT_* names remain private test-only compatibility aliases. They are not public configuration inputs.

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

These examples are taken from examples/auth_check.py and examples/app_full_usage.py.

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)

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.

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

vmodal-0.1.1.tar.gz (74.5 kB view details)

Uploaded Source

Built Distribution

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

vmodal-0.1.1-py3-none-any.whl (26.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vmodal-0.1.1.tar.gz
  • Upload date:
  • Size: 74.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for vmodal-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2babefef4cec8796dede53dd46599df41891fce82f29b43328e7761d40126323
MD5 22774cf59dd41632203f26aa905b4b5e
BLAKE2b-256 cec7a0c83374bf00b06a20cfb455b1b6bcaa6b956b95119cc62c148415ea2474

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vmodal-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 26.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for vmodal-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 92d6905a4b0a09973cb666e85ad1537d5845907ab77f87b7a09bf03fcd483d51
MD5 4b1f6e02a10ea2aa1dd31ecd7c07b9de
BLAKE2b-256 e7516e47902e7e69164a9271ed6fb0463e650bacc7f8358cf350f1f1ff04f40d

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