Implementation:Bentoml BentoML Client Module
| Knowledge Sources | |
|---|---|
| Domains | Client, API, gRPC, HTTP |
| Last Updated | 2026-02-13 15:00 GMT |
Overview
Public module that re-exports all BentoML client classes for connecting to BentoML services via HTTP or gRPC protocols, in both synchronous and asynchronous modes.
Description
The bentoml.client module serves as a convenience re-export layer that aggregates all client implementations from BentoML's internal client packages. It exposes nine client classes: the abstract Client, SyncClient, and AsyncClient base classes; HTTP-specific HTTPClient, SyncHTTPClient, and AsyncHTTPClient classes; and gRPC-specific GrpcClient, SyncGrpcClient, and AsyncGrpcClient classes. This module does not contain any logic itself -- it purely imports and re-exports from bentoml._internal.client, bentoml._internal.client.http, and bentoml._internal.client.grpc.
Usage
Use this module to create client instances for communicating with remote BentoML services. Choose the appropriate client class based on your protocol (HTTP/gRPC) and execution model (sync/async).
Code Reference
Source Location
- Repository: Bentoml_BentoML
- File: src/bentoml/client.py
- Lines: 1-39
Signature
# Re-exported classes
from bentoml._internal.client import AsyncClient
from bentoml._internal.client import Client
from bentoml._internal.client import SyncClient
from bentoml._internal.client.grpc import AsyncGrpcClient
from bentoml._internal.client.grpc import GrpcClient
from bentoml._internal.client.grpc import SyncGrpcClient
from bentoml._internal.client.http import AsyncHTTPClient
from bentoml._internal.client.http import HTTPClient
from bentoml._internal.client.http import SyncHTTPClient
Import
from bentoml.client import Client, HTTPClient, SyncHTTPClient, AsyncHTTPClient
from bentoml.client import GrpcClient, SyncGrpcClient, AsyncGrpcClient
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| (module-level) | N/A | N/A | This module takes no inputs; it re-exports client classes |
Outputs
| Name | Type | Description |
|---|---|---|
| Client | class | Abstract base client class |
| SyncClient | class | Synchronous base client |
| AsyncClient | class | Asynchronous base client |
| HTTPClient | class | HTTP client (alias for SyncHTTPClient) |
| SyncHTTPClient | class | Synchronous HTTP client |
| AsyncHTTPClient | class | Asynchronous HTTP client |
| GrpcClient | class | gRPC client (alias for SyncGrpcClient) |
| SyncGrpcClient | class | Synchronous gRPC client |
| AsyncGrpcClient | class | Asynchronous gRPC client |
Usage Examples
import bentoml
import numpy as np
# Create an HTTP client from a URL
client = bentoml.client.Client.from_url("localhost:3000")
# Call an API endpoint
result = client.predict(np.array([[5.9, 3, 5.1, 1.8]]))
# Async usage
import asyncio
async def main():
async_client = bentoml.client.AsyncHTTPClient.from_url("localhost:3000")
result = await async_client.predict(np.array([[5.9, 3, 5.1, 1.8]]))
asyncio.run(main())