You can use the VLM Run Python SDK to interact with the VLM Run API.

Installation

Basic Installation

You can install the basic Python SDK using pip:

pip install vlmrun --upgrade

Installation with Optional Features

The package provides optional features that can be installed based on your needs:

  • Video processing features (numpy, opencv-python):
pip install "vlmrun[video]"
  • Document processing features (pypdfium2):
pip install "vlmrun[doc]"
  • All optional features:
pip install 'vlmrun[all]'

Authentication

There are two ways to authenticate with the VLM Run API:

Using Environment Variable

The SDK will automatically use the VLMRUN_API_KEY environment variable to authenticate. You can get your API key from the VLM Run dashboard.

from vlmrun.client import VLMRun

client = VLMRun()

Direct API Key

You can also pass the API key directly to the client:

from vlmrun.client import VLMRun

client = VLMRun(api_key="your-api-key")

Basic Usage

Here’s a simple example of how to use the SDK:

from PIL import Image
from vlmrun.client import VLMRun
from vlmrun.common.utils import remote_image

# Initialize the client
client = VLMRun(api_key="<your-api-key>")

# Process an image using local file or remote URL
image: Image.Image = remote_image("https://storage.googleapis.com/vlm-data-public-prod/hub/examples/document.invoice/invoice_1.jpg")
response = client.image.generate(
    images=[image],
    domain="document.invoice"
)
print(response)

# Or process an image directly from URL
response = client.image.generate(
    urls=["https://storage.googleapis.com/vlm-data-public-prod/hub/examples/document.invoice/invoice_1.jpg"],
    domain="document.invoice"
)
print(response)

Resources