An open API service indexing awesome lists of open source software.

https://github.com/vlm-run/vlmrun-python-sdk

Official Python SDK for VLM Run
https://github.com/vlm-run/vlmrun-python-sdk

computer-vision genai llm ocr python vlm

Last synced: 5 months ago
JSON representation

Official Python SDK for VLM Run

Awesome Lists containing this project

README

          



VLM Run Logo


VLM Run Python SDK


Website | Platform | Docs | Blog | Discord



PyPI Version
PyPI Version
PyPI Downloads

License
Discord
Twitter Follow


The [VLM Run Python SDK](https://pypi.org/project/vlmrun/) is the official Python SDK for [VLM Run API platform](https://docs.vlm.run), providing a convenient way to interact with our REST APIs.

## 🚀 Getting Started

### Installation

```bash
pip install vlmrun
```

### Installation with Optional Features

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

- Chat with Orion via the CLI (see `vlmrun chat`)
```bash
pip install "vlmrun[cli]"
```

- Video processing features (numpy, opencv-python):
```bash
pip install "vlmrun[video]"
```

- Document processing features (pypdfium2):
```bash
pip install "vlmrun[doc]"
```

- OpenAI SDK integration (for chat completions API):
```bash
pip install "vlmrun[openai]"
```

- All optional features:
```bash
pip install "vlmrun[all]"
```

### Basic Usage

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

# Initialize the client
client = VLMRun(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)
```

### OpenAI-Compatible Chat Completions

The VLM Run SDK provides OpenAI-compatible chat completions through the agent endpoint. This allows you to use the familiar OpenAI API with VLM Run's powerful vision-language models.

```python
from vlmrun.client import VLMRun

client = VLMRun(
api_key="your-key",
base_url="https://agent.vlm.run/v1"
)

response = client.agent.completions.create(
model="vlmrun-orion-1",
messages=[
{"role": "user", "content": "Hello!"}
]
)
print(response.choices[0].message.content)
```

For async support:

```python
import asyncio
from vlmrun.client import VLMRun

client = VLMRun(api_key="your-key", base_url="https://agent.vlm.run/v1")

async def main():
response = await client.agent.async_completions.create(
model="vlmrun-orion-1",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)

asyncio.run(main())
```

**Installation**: Install with OpenAI support using `pip install vlmrun[openai]`

## 🔗 Quick Links

* 💬 Need help? Email us at [support@vlm.run](mailto:support@vlm.run) or join our [Discord](https://discord.gg/AMApC2UzVY)
* 📚 Check out our [Documentation](https://docs.vlm.run/)
* 📣 Follow us on [Twitter](https://x.com/vlmrun) and [LinkedIn](https://www.linkedin.com/company/vlm-run)