Skip to main content
tools.py
The deploy runs the pod in the cloud and prints the HTTPS URL of its http port. Pods are public by default; authorized=True makes the URL take the same bearer token as an endpoint. A pod fits when you already have a command or image to run, as the LoRA fine-tuning example does for vLLM. For Python you want to call as a function or serve over HTTP, an endpoint needs less setup.

Keep a container up

A deployed pod runs one container while it has connections and stops it after keep_warm seconds idle, 600 by default. keep_warm=-1 keeps one up at all times, which suits a model server that can’t wait for a cold start.

Run more than one container

Pods don’t autoscale, so more containers means a count:
The count holds until the next scale, and web.scale(n) does the same from Python.

Create an instance on demand

A pod can also run once without a deployment. With an access token in LAZYCLOUD_TOKEN, this starts an instance, fetches the directory listing, and stops it:
web.run("python", "--version") starts one with a different command. An instance has a url and terminate(), and lives for keep_warm seconds unless timeout_seconds says otherwise.

Configure the container

env, secrets, volumes, and machine work as on every workload, and web.shell() opens a shell in a pod container.

Expose a raw TCP port

tcp=True exposes a raw TCP port at a tls://hostname:port address. Clients connect with TLS and send that hostname as SNI. TCP pods are always public, so the server authenticates its own clients.

Stop a pod

stop keeps the definition and delete removes it, like web.pause() and web.delete() in Python. A running deployment replaces any container you stop by hand, so stopping the deployment is what keeps a pod down.

Set what every workload shares

Images, resources, and scaling.