Skip to main content
Tensorlake functions run in function containers. To install dependencies in the containers, we use container images that are built when you deploy an application. Functions can use any Python or system packages installed into their container images. Tensorlake provides a declarative API to define function container images with their dependencies.

Defining Images

1

Define your image

An image is defined using an Image object. You can modify the base image, run commands to install dependencies at build time, and modify other image attributes, like its name.
from tensorlake.applications import Image

image = (
    Image(
        name="my-pdf-parser-image",
        base_image="ubuntu:24.04",
    )
    .run("apt update")
    .run("pip install langchain")
)
2

Associate the image with the function

from tensorlake.applications import function

@function(image=image)
def parse_pdf(pdf_path: str) -> str:
    import langchain
    # All the packages installed in the image are available inside the function.
    # They need to be imported here because they might not be available
    # in the Python environment used to deploy the application.
    ...

Default Base Image

We use a Debian based image python:{LOCAL_PYTHON_VERSION}-slim-bookworm as the default. LOCAL_PYTHON_VERSION represents the Python version in your current Python environment.

Private Base Images

If your base_image lives in a private container registry, Tensorlake authenticates the pull using your local Docker config ($DOCKER_CONFIG/config.json, default ~/.docker/config.json) — for example after docker login. Function images build through the same path as sandbox images, so the setup is identical. See Private Registries for supported auth types, CI setup, and the DOCKER_CONFIG scoping pattern.

See Also

Structured Extraction from Images

End-to-end example of using custom images for structured extraction from images.