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.

Environment:Bentoml BentoML BentoCloud Credentials

From Leeroopedia
Knowledge Sources
Domains Infrastructure, Cloud_Deployment
Last Updated 2026-02-13 16:00 GMT

Overview

BentoCloud authentication environment requiring API token and endpoint configuration for deploying, pushing, pulling, and managing bentos and models on BentoCloud.

Description

BentoCloud credentials are managed through a `CloudClientConfig` stored in `~/.bentoml/.yatai.yaml`. The config supports multiple named contexts, each with an endpoint URL and API token. Authentication can also be provided via environment variables (`BENTO_CLOUD_API_KEY` and `BENTO_CLOUD_API_ENDPOINT`), which take precedence over the config file. The default endpoint is `https://cloud.bentoml.com`. The `bentoml cloud login` CLI command handles interactive authentication setup.

Usage

Use this environment for any BentoCloud operations: deploying services, pushing/pulling bentos and models, creating/managing deployments, and invoking cloud-deployed endpoints. This is the mandatory prerequisite for all `bentoml.deployment.*` and `bentoml.bentos.push/pull` operations.

System Requirements

Category Requirement Notes
Network Internet access to BentoCloud endpoint Default: https://cloud.bentoml.com
Disk Minimal Config file stored at ~/bentoml/.yatai.yaml

Dependencies

Python Packages

  • `bentoml` (core, includes REST client)
  • `httpx` (for HTTP communication)

Credentials

The following credentials must be configured:

  • `BENTO_CLOUD_API_KEY`: BentoCloud API token. Takes priority over config file contexts when set as an environment variable.
  • `BENTO_CLOUD_API_ENDPOINT`: BentoCloud API endpoint URL (default: `https://cloud.bentoml.com`). Optional env var override.

Config file alternative: Run `bentoml cloud login` to store credentials in `~/.bentoml/.yatai.yaml` with named contexts.

Quick Install

# Login via CLI (interactive)
bentoml cloud login

# Or set environment variables
export BENTO_CLOUD_API_KEY="your-api-token"
export BENTO_CLOUD_API_ENDPOINT="https://cloud.bentoml.com"  # optional

Code Evidence

Environment variable priority from `cloud/config.py:70-86`:

class CloudClientConfig:
    def get_context(self, context: t.Optional[str] = None) -> CloudClientContext:
        from os import environ
        if "BENTO_CLOUD_API_KEY" in environ:
            return CloudClientContext(
                name="__env__",
                endpoint=environ.get("BENTO_CLOUD_API_ENDPOINT", DEFAULT_ENDPOINT),
                api_token=environ["BENTO_CLOUD_API_KEY"],
            )
        if context is None:
            context = self.current_context_name
        for ctx in self.contexts:
            if ctx.name == context:
                return ctx
        raise CloudRESTApiClientError(
            f"No cloud context {context} found", error_code=HTTPStatus.UNAUTHORIZED
        )

Default endpoint from `cloud/config.py:62`:

DEFAULT_ENDPOINT = "https://cloud.bentoml.com"

Config file location from `containers.py:221-222`:

def cloud_config(bentoml_home: str = Provide[bentoml_home]) -> Path:
    return Path(bentoml_home) / ".yatai.yaml"

Common Errors

Error Message Cause Solution
`CloudRESTApiClientError: No cloud context X found` (401) No matching context in config and no env var set Run `bentoml cloud login` or set `BENTO_CLOUD_API_KEY`
`Unable to get current user from yatai server` Invalid or expired API token Re-authenticate with `bentoml cloud login`
Context override warning Saving a context that already exists Expected behavior; the existing context is overwritten

Compatibility Notes

  • Environment variable priority: When `BENTO_CLOUD_API_KEY` is set, it always takes precedence over config file contexts, regardless of which context is selected.
  • Multiple contexts: The config file supports multiple named contexts for different BentoCloud deployments. Use `bentoml cloud login` to switch between them.
  • Container detection: Inside containers, `BENTOCLOUD_DEPLOYMENT_URL` is set automatically. The `running_inside_container()` check uses this to adjust behavior (e.g., disabling process respawning).

Related Pages

Page Connections

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