> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tensorlake.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Container Images

> Define per-function container images declaratively with Tensorlake's `Image` API — set the base image, install Python and system packages, and customize per-deploy.

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

<Steps>
  <Step title="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.

    ```python theme={null}
    from tensorlake.applications import Image

    image = (
        Image(
            name="my-pdf-parser-image",
            base_image="ubuntu:24.04",
        )
        .run("apt update")
        .run("pip install langchain")
    )
    ```
  </Step>

  <Step title="Associate the image with the function">
    ```python theme={null}
    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.
        ...
    ```
  </Step>
</Steps>

#### 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.

## See Also

<CardGroup cols={2}>
  <Card title="Structured Extraction from Images" icon="image" href="/examples/cookbooks/structured-extraction-from-images">
    End-to-end example of using custom images for structured extraction from images.
  </Card>
</CardGroup>
