Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Bentoml BentoML Models List Get

From Leeroopedia
Implementation Metadata
Implementation Name Models List Get
API bentoml.models.list(), bentoml.models.get()
Source src/bentoml/models.py:L31-49
Workflow Model_Store_Management
Domain ML_Serving, Model_Management
Implements Principle:Bentoml_BentoML_Model_Versioning
Last Updated 2026-02-13 15:00 GMT

Overview

The bentoml.models.list() and bentoml.models.get() functions provide querying and retrieval capabilities for models in the BentoML local store. list() returns all models (optionally filtered by name), while get() retrieves a single model by its exact tag.

Import

import bentoml

Signatures

def list(tag: Tag | str = None) -> list[Model]

def get(tag: Tag | str) -> Model

Parameters

bentoml.models.list()

Parameter Type Default Description
tag str None Optional filter. If a name is provided (e.g., "my_model"), only versions of that model are returned. If None, all models in the store are returned.

bentoml.models.get()

Parameter Type Default Description
tag str required The model tag to retrieve. Supports "name" (resolves to latest), "name:latest", or "name:version".

Inputs and Outputs

list()

Inputs:

  • Optional tag filter (model name or full tag)

Outputs:

  • list[Model] sorted by creation time (newest first)
  • Each Model object contains:
    • .tag — the immutable name:version tag
    • .info — structured model info including labels, metadata, creation_time
    • .path — filesystem path to the model artifacts

get()

Inputs:

  • Exact tag (or name for latest resolution)

Outputs:

  • Single Model instance
  • Raises NotFound if the model does not exist in the store

Usage Examples

import bentoml

# List all models in the store
all_models = bentoml.models.list()
for model in all_models:
    print(f"{model.tag} - created: {model.info.creation_time}")

# List all versions of a specific model
classifier_versions = bentoml.models.list("text_classifier")

# Get a specific model version
model = bentoml.models.get("text_classifier:abc123")
print(f"Path: {model.path}")
print(f"Labels: {model.info.labels}")
print(f"Metadata: {model.info.metadata}")

# Get the latest version of a model
latest = bentoml.models.get("text_classifier:latest")
# Or equivalently:
latest = bentoml.models.get("text_classifier")

Model Info Structure

The Model.info object returned by both functions contains:

Field Type Description
tag Tag The immutable model tag (name:version)
labels dict[str, str] Key-value labels for filtering
metadata dict[str, Any] Arbitrary user metadata
creation_time datetime When the model was saved
context ModelContext Framework and Python version info
module str The module that saved the model

Behavior Details

  • list() returns results sorted by creation time with the newest models first.
  • get() supports the "latest" version specifier, which resolves to the most recently saved version of a given model name.
  • Both functions operate on the local store only. They do not query BentoCloud; use BentoModel.resolve() for automatic cloud fallback.

Source Reference

File: src/bentoml/models.py, lines 31-49.

Knowledge Sources

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment