Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Bentoml BentoML CLI Entry Point

From Leeroopedia
Knowledge Sources
Domains CLI, Entry Point
Last Updated 2026-02-13 15:00 GMT

Overview

Defines the main BentoML CLI entry point by assembling all subcommands into a Click command group and exposing the cli module-level callable.

Description

The create_bentoml_cli function builds the top-level bentoml Click command group using BentoMLCommandGroup as the group class. It configures the help option names ("-h", "--help") and attaches a version option displaying BENTOML_VERSION. The function registers all built-in subcommands: env, cloud, model, bento (as subcommands), serve (as subcommands), containerize, deploy, codespace, deployment, secret, and api_token. It also discovers and loads extension commands via the bentoml.commands entry point group. On Windows, it reconfigures stdout to use UTF-8 encoding. The server_context.service_type is set to "cli" at startup. The module-level cli variable holds the created Click group, and the __main__ block allows direct script execution.

Usage

This module is the entry point for the bentoml command-line tool. It is invoked when users run bentoml from the terminal, typically configured as a console script entry point in the package's setup configuration.

Code Reference

Source Location

Signature

def create_bentoml_cli() -> click.Command: ...

cli = create_bentoml_cli()

Import

from bentoml_cli.cli import cli, create_bentoml_cli

I/O Contract

Inputs

Name Type Required Description
(none) N/A N/A The function takes no parameters; CLI arguments are parsed by Click from sys.argv

Outputs

Name Type Description
cli click.Command The assembled Click command group ready for invocation

Usage Examples

# From the command line:
# bentoml --version
# bentoml serve my_service:svc
# bentoml env
# bentoml models list

# Programmatic invocation:
from bentoml_cli.cli import cli
cli(["--help"])

Related Pages

Page Connections

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