The Vast PyWorker is a Python web server designed to run alongside a machine learning model instance, providing serverless compatibility. It serves as the primary entry point for API requests, forwarding them to the model’s API hosted on the same instance. Additionally, it monitors performance metrics and estimates current workload, reporting these metrics to the serverless system.Documentation Index
Fetch the complete documentation index at: https://docs.vast.ai/llms.txt
Use this file to discover all available pages before exploring further.
All of Vast’s serverless templates use the Vast PyWorker. If you are using a recommended serverless template from Vast, the PyWorker is already integrated with the template and will automatically startup when a Workergroup is created.

- Sends a
/route/POST request to the serverless engine. This asks the system for a GPU instance to send the inference request. - The serverless system selects a ready and available worker instance from the user’s endpoint and replies with a JSON object containing the URL of the selected instance.
- The client then constructs a new POST request with it’s payload, authentication data, and the URL of the worker instance. This is sent to the worker.
- The PyWorker running on that specific instance validates the request and extracts the payload. It then sends the payload to the model inference server, which runs on the same instance as the PyWorker.
- The model generates it’s output and returns the result to the PyWorker.
- The PyWorker formats the model’s response as needed, and sends the response back to the client.
- Independently and concurrently, the PyWorker periodically sends it’s operational metrics to the serverless system, which is used to make scaling decisions.

Integration with Model Instance
The Vast PyWorker wraps the backend code of the model instance you are running. The PyWorker calls the appropriate backend function when the PyWorker’s corresponding API endpoint is invoked. For example, if you are running a text generation inference (TGI) server, your PyWorker might receive the following JSON body from a/generate endpoint:
JSON
JSON