module pixeltable.functions.vlmrun
Pixeltable UDFs that wrap the VLM Run Orion agent API. In order to use them, you must firstpip install vlmrun and configure your VLM Run API key, by setting the
VLMRUN_API_KEY environment variable or vlmrun.api_key in the Pixeltable config file.
udf annotate_image()
Signature
viz toolset.
For additional details, see: https://docs.vlm.run/
Requirements:
pip install vlmrun
prompt(pxt.String): Text prompt describing what to annotate, such as'Draw bounding boxes around all people'.image(pxt.Image): The image to annotate.model(pxt.String): The model to use, such as'vlmrun-orion-2:auto'.model_kwargs(pxt.Json | None): Additional parameters for the VLM Run chat completions API. This function setsresponse_formatandtoolsetsitself, so they cannot be passed.
pxt.Image: The annotated image.
img:
udf chat_completions()
Signature
{'type': 'image_url', 'image_url': tbl.img}, video columns via {'type': 'video_url', 'video_url': tbl.video},
and document columns via {'type': 'file_url', 'file_url': tbl.doc}. Referenced media is uploaded to VLM Run
for each call, and deleted from VLM Run when the call ends. A string in video_url or file_url that is not a
URL is read as a local file path and uploaded, so don’t put untrusted strings there.
Request throttling:
Applies the rate limit set in the config (section vlmrun, key rate_limit). If no rate limit is configured,
uses a default of 600 RPM.
Requirements:
pip install vlmrun
messages(pxt.Json[(Json): A list of messages for the chat conversation. Media content items can reference Pixeltable columns directly (see above).model(Any): The model to use, such as'vlmrun-orion-2:fast','vlmrun-orion-2:auto'or'vlmrun-orion-2:pro'. For the full list, see https://docs.vlm.run/.model_kwargs(Any): Additional parameters for the VLM Run chat completions API, such asresponse_formatfor structured JSON output ortoolsetsto select the agent’s tools.
pxt.Json: A dictionary containing the API response.
img of the table tbl:
doc as a JSON string:
udf generate_document()
Signature
document toolset.
For additional details, see: https://docs.vlm.run/
Requirements:
pip install vlmrun
prompt(pxt.String): Text prompt describing the transformation, such as'Redact all personally identifiable information'.document(pxt.Document): The document to transform: a PDF, DOC or DOCX file.model(pxt.String): The model to use, such as'vlmrun-orion-2:auto'.model_kwargs(pxt.Json | None): Additional parameters for the VLM Run chat completions API. This function setsresponse_formatandtoolsetsitself, so they cannot be passed.
pxt.Document: The transformed document, as a PDF.
doc:
udf generate_image()
Signature
image-gen toolset.
For additional details, see: https://docs.vlm.run/
Requirements:
pip install vlmrun
prompt(pxt.String): Text prompt describing the image to generate or the edit to apply.image(pxt.Image | None): The image to edit. If it is omitted, or null in a row, the image is generated from the prompt alone.model(pxt.String): The model to use, such as'vlmrun-orion-2:auto'.model_kwargs(pxt.Json | None): Additional parameters for the VLM Run chat completions API. This function setsresponse_formatandtoolsetsitself, so they cannot be passed.
pxt.Image: The generated or edited image.
img:
udf generate_video()
Signature
video toolset.
For additional details, see: https://docs.vlm.run/
Requirements:
pip install vlmrun
prompt(pxt.String): Text prompt describing the video to generate.image(pxt.Image | None): An image to start the video from.video(pxt.Video | None): A video to start from. If bothimageandvideoare omitted, or null in a row, the video is generated from the prompt alone.model(pxt.String): The model to use, such as'vlmrun-orion-2:auto'.model_kwargs(pxt.Json | None): Additional parameters for the VLM Run chat completions API. This function setsresponse_formatandtoolsetsitself, so they cannot be passed.
pxt.Video: The generated video.