### Setup environment for video understanding Source: https://docs.parasail.io/parasail-docs/guides/multi-modal Install required libraries and import modules for video processing tasks. ```python !pip install torch torchvision opencv-python &> /dev/null from IPython.display import Video import os import cv2 import gc import math import openai import textwrap import torch import torchvision ``` -------------------------------- ### Install llmcompressor and import modules Source: https://docs.parasail.io/parasail-docs/products/overview-1/fp8-quantization Install the necessary library and import the required functions for model quantization. ```bash # pip install llmcompressor ``` ```python from llmcompressor import oneshot from llmcompressor.modifiers import ``` -------------------------------- ### Install Dependencies and Convert PDF to Images Source: https://docs.parasail.io/parasail-docs/guides/multi-modal Installs necessary system utilities and Python packages, then demonstrates how to iterate through PDF pages to convert them into images. ```python !apt-get install -qq -y poppler-utils > /dev/null !pip install pdf2image > /dev/null import pdf2image !wget https://arxiv.org/pdf/1706.03762 -O transformer.pdf > /dev/null # Use multiple images as input messages = [] for i, page in enumerate(pdf2image.convert_from_path("transformer.pdf", ``` -------------------------------- ### Install and run batch processing script Source: https://docs.parasail.io/parasail-docs/llms-full.txt Commands to install the required library and execute a batch processing script with an API key. ```sh pip3 install openai-batch PARASAIL_API_KEY= python3 test_omnigen_batch.py ``` -------------------------------- ### Install Dependencies and Import Libraries Source: https://docs.parasail.io/parasail-docs/guides/multi-modal Installs necessary packages for computer vision and video processing, followed by standard library imports. ```python !pip install torch torchvision opencv-python > /dev/null from IPython.display import Video import os import cv2 import gc import ``` -------------------------------- ### Install Batch Helper Library Source: https://docs.parasail.io/parasail-docs/api-reference/batch-api Install the required Python package to facilitate batch processing. ```bash pip install openai-batch ``` -------------------------------- ### Install OpenAI SDK Source: https://docs.parasail.io/parasail-docs/llms-full.txt Install the required OpenAI Python library via pip. ```bash pip install openai ``` -------------------------------- ### Install dependencies and process PDF for VQA Source: https://docs.parasail.io/parasail-docs/guides/multi-modal Install necessary system and Python packages, then convert PDF pages to images for multi-modal input. ```python !apt-get install -qq -y poppler-utils &> /dev/null !pip install pdf2image &> /dev/null import pdf2image !wget https://arxiv.org/pdf/1706.03762 -O transformer.pdf &> /dev/null # Use multiple images as input messages = [] for i, page in enumerate(pdf2image.convert_from_path("transformer.pdf", last_page=4)): page.save(f"page_{i}.jpg", 'JPEG') messages.append({"type": "image_url", "image_url": { "url": data_url(f"page_{i}.jpg")}}) messages = [{ "role": "user", "content": messages + [{ "type": "text", "text": "How many of encoder layers were used and where in the paper it's mentioned?" }] }] chat_completion = oai_client.chat.completions.create( model="parasail-qwen25-vl-72b-instruct", messages=messages) display(Image("page_0.jpg", width=500)) print(chat_completion.choices[0].message.content) ``` -------------------------------- ### Batch Processing Example Source: https://docs.parasail.io/parasail-docs/products/quickstart Demonstrates the syntax for defining a batch operation. ```text Batch as batch: ``` -------------------------------- ### Configure Model and Print Output Source: https://docs.parasail.io/parasail-docs/operate-in-production/retries-and-idempotency Example of setting a model configuration and printing the result. ```python model = "", ) print( ``` -------------------------------- ### Configure Model and Batch Source: https://docs.parasail.io/parasail-docs/products/quickstart Examples for setting the model identifier and initializing a batch request. ```python model = "NousResearch/DeepHermes-3-Mistral-24B-Preview", ``` ```python messages = [{ ``` ```python batch.add_to_batch( ``` -------------------------------- ### Models API Request Examples Source: https://docs.parasail.io/parasail-docs/api-reference/models-endpoint Examples for interacting with the models endpoint using cURL and the Python OpenAI SDK. ```bash curl https://api.parasail.io/v1/models \ -H "Authorization: Bearer $PARASAIL_API_KEY" ``` ```python from openai import OpenAI client = OpenAI( base_url="https://api.parasail.io/v1", api_key="YOUR_PARASAIL_API_KEY" ) models = client.models.list() print(models) ``` -------------------------------- ### API Key Configuration Source: https://docs.parasail.io/parasail-docs/guides/multi-modal Example of setting the API key for authentication. ```text api_key = API_KEY ``` -------------------------------- ### Importing Required Libraries Source: https://docs.parasail.io/parasail-docs/guides/structured-output Initial setup for using the OpenAI client with Parasail. ```python import json import os from openai import ``` -------------------------------- ### Importing Parasail Client Source: https://docs.parasail.io/parasail-docs/guides/tool-function-calling Initial setup for using the Parasail Python client. ```python import ``` -------------------------------- ### Deployment configuration JSON Source: https://docs.parasail.io/parasail-docs/products/overview-1/management-api Example JSON structure for defining a deployment configuration. ```json { "id": 12345, "deploymentName": "myqwen", "modelName": ``` -------------------------------- ### Object Definition Example Source: https://docs.parasail.io/parasail-docs/products/quickstart Shows how to define a list of objects for processing. ```text objects = ["cat", "robot", ``` -------------------------------- ### Example JSON Output Source: https://docs.parasail.io/parasail-docs/guides/structured-output Sample output format for the weather query. ```json { "location": "Manhattan Beach", "date": "2025-06-03" } ``` -------------------------------- ### Configure Model and Prompt Parameters Source: https://docs.parasail.io/parasail-docs/products/overview-2 Examples showing how to define the model name, input prompt, and size configuration. ```text model = "Shitao/OmniGen-v1", ``` ```text prompt = "A man in a black shirt is reading a book. The man is the right man in <|image_1|>", ``` ```text size = ``` -------------------------------- ### Guided Constraints Examples Source: https://docs.parasail.io/parasail-docs/guides/structured-output Examples of using guided_regex for pattern matching and guided_choice for restricted selection. ```python # Constrain to an ISO date extra_body = {"guided_regex": r"\d{4}-\d{2}-\d{2}"} # Constrain to one of a fixed set of values extra_body = {"guided_choice": ["red", "green", "blue"]} ``` -------------------------------- ### Retrieve and Select Hardware Configuration Source: https://docs.parasail.io/parasail-docs/products/overview-1/management-api This example demonstrates how to fetch supported hardware configurations, identify a specific one, and update the selected flag to true. ```javascript Here is example code to retrieve supported hardware, look for a desired configuration, and flip the selected flag to true when it is found: ``` -------------------------------- ### Initialize Device Configuration Source: https://docs.parasail.io/parasail-docs/products/overview-1/management-api Example of calling the device configuration selection function with specific model parameters. ```python devices = get_and_select_device_config( client, model_name="Qwen/Qwen2.5-72B-Instruct", ``` -------------------------------- ### Billing API JSON Response Structure Source: https://docs.parasail.io/parasail-docs/api-reference/billing-api Example of the JSON response format returned by the billing API, showing total usage and start timestamps. ```json { "total": 52.89, "start_timestamp": "2026-04-01T00:00:00+00:00" } ``` -------------------------------- ### Initialize Client Source: https://docs.parasail.io/parasail-docs/products/overview/model-specific-notes Basic client initialization syntax. ```text client = ``` -------------------------------- ### GET /api/v1/dedicated/performance Source: https://docs.parasail.io/parasail-docs/security-and-account-management/account-api-keys Get model and hardware performance estimates. ```APIDOC ## GET /api/v1/dedicated/performance ### Description Get model and hardware performance estimates. ### Method GET ### Endpoint /api/v1/dedicated/performance ``` -------------------------------- ### Get Deployment Source: https://docs.parasail.io/parasail-docs/products/overview-1/management-api Sends a GET request to retrieve details for a specific deployment by its ID. ```python def get_deployment(parasail_client: httpx.Client, id: int) -> dict: response = parasail_client.get(f"/dedicated/deployments/{id}") assert ( 200 <= response.status_code < 300 ), f"Failed to get deployment: {response.status_code} {response.text}" return ``` -------------------------------- ### Batch Processing and Model Configuration Source: https://docs.parasail.io/parasail-docs/products/overview-2 Examples showing how to add items to a batch and configure a specific model. ```python batch.add_to_batch() ``` ```python model = "Shitao/OmniGen-v1", ``` -------------------------------- ### Install OpenAI dependency Source: https://docs.parasail.io/parasail-docs/guides/multi-modal Install the required OpenAI Python package to enable multi-modal functionality. ```bash !pip install openai > /dev/null ``` -------------------------------- ### Batch API Usage Source: https://docs.parasail.io/parasail-docs/api-reference/batch-api Demonstrates how to install the library, initialize a batch, add requests, and submit them with metadata. ```APIDOC ## Installation ```bash pip install openai-batch ``` ## Usage ### Description Use the `Batch` class to queue multiple requests and submit them for processing. The `add_to_batch` method is used to define the model and message content for each request, and `submit` is used to finalize the batch with optional metadata. ### Example ```python from openai_batch import Batch with Batch() as batch: for i in range(100): batch.add_to_batch( model="NousResearch/DeepHermes-3-Mistral-24B-Preview", messages=[{"role": "user", "content": f"Prompt #{i}"}] ) batch.submit(metadata={"PARASAIL_PRIORITY": ...}) ``` ``` -------------------------------- ### Initialize Clients and Configure Devices Source: https://docs.parasail.io/parasail-docs/products/overview-1/management-api Initializes the Parasail and OpenAI clients and selects a device configuration for a specific model. ```python parasail_client = httpx.Client( base_url=control_base_url, headers={ "Authorization": "Bearer " + api_key, "Content-Type": "application/json", }, ) openai_client = openai.Client(api_key=api_key, base_url=chat_base_url) check_compatibility(parasail_client, model_name) devices = get_and_select_device_config( parasail_client, model_name=model_name, desired_device="H100SXM", ``` -------------------------------- ### Perform GET Request with Read-Only Key Source: https://docs.parasail.io/parasail-docs/llms-full.txt Read-only keys are permitted to perform GET requests on specific management endpoints. ```http GET /api/v1/dedicated/deployments HTTP/1.1 Host: api.parasail.io Authorization: Bearer ``` -------------------------------- ### Initialize OpenAI Client for Model Usage Source: https://docs.parasail.io/parasail-docs/products/overview/model-specific-notes Basic setup for importing necessary libraries and initializing the OpenAI client for model interaction. ```python import json import os from openai import OpenAI MODEL = ``` -------------------------------- ### Configure GPT-OSS reasoning parameters Source: https://docs.parasail.io/parasail-docs/llms-full.txt Examples showing how to set thinking_budget and reasoning_effort using the OpenAI Python client and cURL. ```python from openai import OpenAI import os client = OpenAI( base_url="https://api.parasail.io/v1", api_key=os.environ["PARASAIL_API_KEY"], ) resp = client.chat.completions.create( model="parasail-gpt-oss-20b-fast", messages=[{"role": "user", "content": "Explain why the sky is blue."}], extra_body={ "custom_params": {"thinking_budget": 40}, "chat_template_kwargs": {"reasoning_effort": "high"}, }, ) print(resp.choices[0].message.content) ``` ```bash curl https://api.parasail.io/v1/chat/completions \ -H "Authorization: Bearer $PARASAIL_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "parasail-gpt-oss-20b-fast", "messages": [{"role": "user", "content": "Explain why the sky is blue."}], "custom_params": {"thinking_budget": 40}, "chat_template_kwargs": {"reasoning_effort": "high"} }' ``` -------------------------------- ### GET /api/v1/openrouter/models Source: https://docs.parasail.io/parasail-docs/security-and-account-management/account-api-keys List models available through OpenRouter. ```APIDOC ## GET /api/v1/openrouter/models ### Description List models available through OpenRouter. ### Method GET ### Endpoint /api/v1/openrouter/models ``` -------------------------------- ### Initialize OpenAI Client Source: https://docs.parasail.io/parasail-docs/guides/chat-completions Instantiate the OpenAI client for use in your application. ```python client = OpenAI() ``` -------------------------------- ### GET /v1/billing/invoices Source: https://docs.parasail.io/parasail-docs/llms-full.txt List all billing invoices for the organization. ```APIDOC ## GET /v1/billing/invoices ### Description List invoices. ### Method GET ### Endpoint /v1/billing/invoices ``` -------------------------------- ### Initiate Tool-Enabled Request and Agentic Loop Source: https://docs.parasail.io/parasail-docs/guides/tool-function-calling Demonstrates how to create an initial request with tool support and process subsequent function calls in a loop. ```python return json.dumps({"error": "unknown function"}) # Initial request (store must be false on the Parasail gateway) response = client.responses.create( model="parasail-kimi-k25-elicit", store=False, tools=tools, input=[{"role": "user", "content": "What's the weather in Tokyo?"}], ) # Agentic loop—continue until the model stops calling tools while response.output: tool_calls = [item for item in response.output if item.type == "function_call"] if not tool_calls: ``` -------------------------------- ### GET /api/v1/dedicated/devices Source: https://docs.parasail.io/parasail-docs/security-and-account-management/account-api-keys List supported GPU and hardware types. ```APIDOC ## GET /api/v1/dedicated/devices ### Description List supported GPU and hardware types. ### Method GET ### Endpoint /api/v1/dedicated/devices ``` -------------------------------- ### GET /api/v1/dedicated/deployments Source: https://docs.parasail.io/parasail-docs/llms-full.txt List all dedicated deployments associated with the organization. ```APIDOC ## GET /api/v1/dedicated/deployments ### Description List your dedicated deployments. ### Method GET ### Endpoint /api/v1/dedicated/deployments ``` -------------------------------- ### Manage and Test Deployment Lifecycle Source: https://docs.parasail.io/parasail-docs/products/overview-1/management-api Demonstrates how to verify deployment status, run tests, and toggle deployment states between online and offline. ```python wait_for_status(parasail_client, deployment["id"], status="ONLINE") print("\nTesting deployment with 1 replica...") test_deployment(parasail_client, openai_client, deployment["id"]) print("Initial deployment tests passed successfully") pause_deployment(parasail_client, deployment["id"]) wait_for_status(parasail_client, deployment["id"], status="OFFLINE") resume_deployment(parasail_client, deployment["id"]) wait_for_status(parasail_client, deployment["id"], status="ONLINE") print("\nTesting deployment with 1 replica...") test_deployment(parasail_client, openai_client, deployment["id"]) print("Initial deployment tests passed ``` -------------------------------- ### GET /dedicated/deployments/{id} Source: https://docs.parasail.io/parasail-docs/llms-full.txt Retrieves details of a specific deployment. ```APIDOC ## GET /dedicated/deployments/{id} ### Description Fetches the current status and configuration of a deployment. ### Method GET ### Endpoint /dedicated/deployments/{id} ### Parameters #### Path Parameters - **id** (integer) - Required - The deployment ID. ``` -------------------------------- ### GET /dedicated/devices Source: https://docs.parasail.io/parasail-docs/llms-full.txt Retrieves available device configurations for a model. ```APIDOC ## GET /dedicated/devices ### Description Retrieves a list of available device configurations for a given model and engine. ### Method GET ### Endpoint /dedicated/devices ### Parameters #### Query Parameters - **modelName** (string) - Required - The name of the model. - **engine** (string) - Required - The engine type. - **modelAccessKey** (string) - Optional - Access key for privately hosted models. ``` -------------------------------- ### GET /dedicated/support Source: https://docs.parasail.io/parasail-docs/llms-full.txt Checks if a specific model is supported for deployment. ```APIDOC ## GET /dedicated/support ### Description Checks if a model is supported for deployment on the platform. ### Method GET ### Endpoint /dedicated/support ### Parameters #### Query Parameters - **modelName** (string) - Required - The name of the model to check. - **engine** (string) - Required - The engine type (e.g., VLLM). - **modelAccessKey** (string) - Optional - Access key for privately hosted models. ``` -------------------------------- ### GET /v1/models Source: https://docs.parasail.io/parasail-docs/api-reference/chat-completions Lists the available models that can be used with the API. ```APIDOC ## GET /v1/models ### Description Retrieves a list of models available for use. ### Method GET ### Endpoint https://api.parasail.io/v1/models ``` -------------------------------- ### Batch Job Output Example Source: https://docs.parasail.io/parasail-docs/guides/rag Sample console output indicating successful batch job completion and database creation. ```text Batch job batch-aqjf7etmdt completed successfully Vector DB is created Number of embedding vectors in DB: 232 Number of embeddings tokens: 217826 ``` -------------------------------- ### Create a model deployment with Python Source: https://docs.parasail.io/parasail-docs/llms-full.txt Uses the client to send a POST request to the /dedicated/deployments endpoint. Requires a pre-defined devices configuration. ```python # Example: Creating a deployment deployment_config = { "deploymentName": "myqwen", "modelName": "Qwen/Qwen2.5-72B-Instruct", "engine": "VLLM", # Optional (defaults to VLLM) "deviceConfigs": devices, "replicas": 1, # Optional parameters: # "scaleDownPolicy": "TIMER", # "scaleDownThreshold": 3600000, } response = client.post("/dedicated/deployments", json=deployment_config) if response.status_code == 200: deployment_data = response.json() deployment_id = deployment_data["id"] print(f"Created deployment with ID: {deployment_id}") else: print(f"Failed to create deployment: {response.status_code}, {response.text}") ``` -------------------------------- ### Python Loop Example Source: https://docs.parasail.io/parasail-docs/products/quickstart A simple Python loop structure. ```python for i in range(100): ``` -------------------------------- ### GET /api/v1/dedicated/support Source: https://docs.parasail.io/parasail-docs/security-and-account-management/account-api-keys Check whether a model supports dedicated hardware. ```APIDOC ## GET /api/v1/dedicated/support ### Description Check whether a model supports dedicated hardware. ### Method GET ### Endpoint /api/v1/dedicated/support ``` -------------------------------- ### Create a deployment Source: https://docs.parasail.io/parasail-docs/products/overview-1/management-api Sends a POST request to initialize a new model deployment with specific configuration parameters. ```python deployment_config = { "deploymentName": "myqwen", "modelName": "Qwen/Qwen2.5-72B-Instruct", "engine": "VLLM", # Optional (defaults to VLLM) "deviceConfigs": devices, "replicas": 1, # Optional parameters: # "scaleDownPolicy": "TIMER", # "scaleDownThreshold": 3600000, } response = client.post("/dedicated/deployments", json=deployment_config) if response.status_code == 200: deployment_data = response.json() deployment_id = deployment_data["id"] print(f"Created deployment with ID: {deployment_id}") else: print(f"Failed to create deployment: {response.status_code}, {response.text}") ``` -------------------------------- ### GET /v1/billing/invoices/current Source: https://docs.parasail.io/parasail-docs/api-reference/billing-api Retrieves the current billing invoice for the authenticated account. ```APIDOC ## GET /v1/billing/invoices/current ### Description Retrieves the current billing invoice for the authenticated account. ### Method GET ### Endpoint /v1/billing/invoices/current ``` -------------------------------- ### GET /invoices/{id} Source: https://docs.parasail.io/parasail-docs/api-reference/billing-api Retrieves a specific invoice by its unique identifier. ```APIDOC ## GET /invoices/{id} ### Description Returns a specific invoice by its unique identifier. ### Method GET ### Endpoint /invoices/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the invoice. ``` -------------------------------- ### Environment and model configuration setup Source: https://docs.parasail.io/parasail-docs/products/overview-1/management-api Initializes environment variables and defines Pydantic models for device configuration and model creation. ```python import httpx import openai from pydantic import BaseModel from typing import Optional import os import time from dotenv import load_dotenv # Load environment variables env_path = os.path.expanduser("~/dev/parasail/.env") if os.path.exists(env_path): load_dotenv(env_path) api_key = os.environ["PARASAIL_API_KEY"] control_base_url = "https://api.parasail.io/api/v1" chat_base_url = "https://api.parasail.io/v1" class deviceConfig(BaseModel): device: str count: int displayName: Optional[str] = None cost: Optional[float] = None estimatedSingleUserTps: Optional[float] = None estimatedSystemTps: Optional[float] = None recommended: Optional[bool] = None limitedContext: Optional[bool] = None available: Optional[bool] = None selected: bool class CreateModelStruct(BaseModel): ``` -------------------------------- ### GET /v1/billing/invoices/breakdowns Source: https://docs.parasail.io/parasail-docs/api-reference/billing-api Retrieves usage breakdowns for a specified time range. ```APIDOC ## GET /v1/billing/invoices/breakdowns ### Description Retrieves usage breakdowns for a specified time range. ### Method GET ### Endpoint /v1/billing/invoices/breakdowns ### Parameters #### Query Parameters - **starting_on** (string) - Required - Start timestamp for the range. - **ending_before** (string) - Required - End timestamp for the range. - **window_size** (string) - Optional - The granularity of the breakdown (e.g., day). - **limit** (integer) - Optional - Maximum number of results to return. - **next_page** (string) - Optional - Token for pagination. ### Request Example curl -H "Authorization: Bearer psk--" \ "https://api.parasail.io/v1/billing/invoices/breakdowns?starting_on=2026-05-01T00:00:00Z&ending_before=2026-06-01T00:00:00Z&window_size=day&limit=35&next_page=..." ``` -------------------------------- ### GET /api/v1/dedicated/deployments/{id} Source: https://docs.parasail.io/parasail-docs/llms-full.txt Fetch details for a specific dedicated deployment. ```APIDOC ## GET /api/v1/dedicated/deployments/{id} ### Description Fetch one dedicated deployment. ### Method GET ### Endpoint /api/v1/dedicated/deployments/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the deployment. ``` -------------------------------- ### GET /models Source: https://docs.parasail.io/parasail-docs/api-reference/models-endpoint Retrieves a list of available models that can be used for inference. ```APIDOC ## GET /models ### Description Retrieves a list of available models, including serverless models, dedicated deployments, and HuggingFace models. ### Method GET ### Endpoint /models ### Response #### Success Response (200) - **object** (string) - The type of the object, which is 'list'. - **data** (array) - A list of model objects. #### Response Example { "object": "list", "data": [ { "id": "parasail-deepseek-r1", "object": "model", "created": 1727900000, "owned_by": "parasail" } ] } ``` -------------------------------- ### Client Setup Source: https://docs.parasail.io/parasail-docs/api-reference/batch-api How to configure the OpenAI Python client to communicate with the Parasail Batch API. ```APIDOC ## Client Setup ### Description To use the Parasail Batch API, configure the OpenAI client with the Parasail base URL and your Parasail API key. ### Code Example ```python from openai import OpenAI client = OpenAI( base_url="https://api.parasail.io/v1", api_key="", ) ``` ``` -------------------------------- ### Create JSONL Batch Input File in Python Source: https://docs.parasail.io/parasail-docs/products/quickstart/file-format Example demonstrating how to write a list of prompts into a JSONL file format suitable for batch processing. ```python import json prompts = ["What is the capital of New York?", "Write two very funny dad jokes.", "Say pong."] with open("example_batch_input.jsonl", "w") as file: for i, prompt in enumerate(prompts): file.write( json.dumps( ``` -------------------------------- ### Batch Processing Syntax Source: https://docs.parasail.io/parasail-docs/quickstart/batch Example of defining a batch operation in Python. ```python with Batch() as batch: objects = ["cat"] ``` -------------------------------- ### Update Deployment Configuration Source: https://docs.parasail.io/parasail-docs/products/overview-1/management-api Demonstrates how to fetch an existing deployment, modify its replica count, and push the update back to the server. ```python # 1. Fetch the current deployment deployment_id = 12345 response = client.get(f"/dedicated/deployments/{deployment_id}") current_deployment = response.json() # 2. Modify the "replicas" field (for example, from 1 to 2) current_deployment["replicas"] = 2 # 3. Send the updated deployment object update_response = client.put( f"/dedicated/deployments/{deployment_id}", ``` -------------------------------- ### Define Tool Function Source: https://docs.parasail.io/parasail-docs/guides/tool-function-calling Example of defining a tool function in Python. ```python def get_weather(location, ``` -------------------------------- ### Initialize Parasail API Client Source: https://docs.parasail.io/parasail-docs/products/overview-1/management-api Basic setup for the API client using the httpx library and your API key. ```python import httpx api_key = "" ``` -------------------------------- ### Execute Video Chat Completion Source: https://docs.parasail.io/parasail-docs/llms-full.txt Example workflow for downloading a video, processing it, and sending it to a multimodal model for description. ```python !wget https://upload.wikimedia.org/wikipedia/commons/2/2f/Making_snowman_in_K%C3%B5rvemaa%2C_Estonia_%28January_2022%29.webm -O snowman.webm &> /dev/null print(f"Processing snowman.webm...") Video("snowman.webm", embed=True) video_url, frames = process_video("snowman.webm") # Generate chat completions for each model/prompt pair. chat_response = oai_client.chat.completions.create( model="parasail-qwen25-vl-72b-instruct", messages=[ { "role": "user", "content": [ {"type": "video_url", "video_url": {"url": video_url}}, {"type": "text", "text": "Describe the video in detail"}, ], } ], temperature=1, top_p=0.001, max_tokens=4096, extra_body={"repetition_penalty": 1.05}, ) print("---------------------------") print(textwrap.fill(f"output={chat_response.choices[0].message.content}")) print("=============================") ``` -------------------------------- ### Initialize OpenAI Client for Chat Completions Source: https://docs.parasail.io/parasail-docs/guides/chat-completions Basic import statements required to begin using the OpenAI client with Parasail. ```python import os from openai import OpenAI ``` -------------------------------- ### Import and File Handling in Python Source: https://docs.parasail.io/parasail-docs/products/overview-2 Demonstrates the basic import of base64 and the use of the with open statement for file operations. ```python import base64 with open ``` -------------------------------- ### GET /dedicated/support Source: https://docs.parasail.io/parasail-docs/products/overview-1/management-api Queries whether a specific model is supported by the Parasail platform. ```APIDOC ## GET /dedicated/support ### Description Checks if a model is supported for dedicated deployment. The model can be identified by a Hugging Face ID or URL. ### Method GET ### Endpoint /dedicated/support ### Parameters #### Query Parameters - **modelName** (string) - Required - The Hugging Face ID or URL of the model. - **engine** (string) - Optional - The engine to use (e.g., VLLM). ``` -------------------------------- ### GET /api/v1/dedicated/deployments/{id}/models Source: https://docs.parasail.io/parasail-docs/security-and-account-management/account-api-keys List models on one dedicated deployment. ```APIDOC ## GET /api/v1/dedicated/deployments/{id}/models ### Description List models on one dedicated deployment. ### Method GET ### Endpoint /api/v1/dedicated/deployments/{id}/models ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the deployment. ``` -------------------------------- ### Importing OpenAI Client Source: https://docs.parasail.io/parasail-docs/api-reference/embeddings Initial setup for using the OpenAI client library within a Python environment. ```python import os from openai ``` -------------------------------- ### Retrieve Billing Record Source: https://docs.parasail.io/parasail-docs/api-reference/billing-api Standard GET request to fetch billing information. ```http GET ``` -------------------------------- ### Retrieve and Select Device Configuration Source: https://docs.parasail.io/parasail-docs/products/overview-1/management-api Fetches available device configurations and marks the desired one as selected. ```python def get_and_select_device_config( parasail_client: httpx.Client, model_name: str, desired_device: str, desired_count: int, ) -> list[dict]: params = {"engine": "VLLM", "modelName": model_name, "modelAccessKey": ""} response = parasail_client.get("/dedicated/devices", params=params) if response.status_code != 200: raise RuntimeError(f"Request failed: {response.status_code} - {response.text}") devices = response.json() matched = False for d in devices: d["selected"] = ( d.get("device") == desired_device and d.get("count") == desired_count ) matched = matched or d["selected"] if not matched: raise ValueError( f"No matching device config for {desired_device} x{desired_count}" ) return devices ```