bentoml
An unofficial async Rust client for BentoML services.
BentoML services expose their @bentoml.api methods as HTTP POST endpoints whose
route is derived from the method name. Because endpoints are defined dynamically
per-service, this crate doesn't generate typed bindings: instead it offers a generic
call over [serde] types, plus extension traits for the rest of the HTTP surface.
Features
- Generic calls: invoke any endpoint with
call(route, payload)over your ownserderequest and response types, with no codegen or per-service bindings. - Async task queues: submit
@bentoml.taskjobs and poll status, fetch results, retry, or cancel through aTaskHandle. - File and streaming I/O:
multipart/form-datafile inputs, raw-binary root inputs, binary responses, and chunked streaming endpoints (featurestream). - Resilient transport: per-request timeouts and exponential-backoff retries via
reqwest-middleware, bearer-token auth, and a cheap-to-cloneArc-backed client.
Usage
Add the dependency:
[]
= "0.1"
= { = "1", = ["macros", "rt-multi-thread"] }
= { = "1", = ["derive"] }
The minimum supported Rust version (MSRV) is 1.91.
use *;
use ;
async
A Client::endpoint(route) handle names the route once; calls are made on it. See
examples/ for runnable examples.
Capabilities
A Client::endpoint(route) handle implements a set of extension traits (all in the
prelude) covering the BentoML HTTP surface:
Tasks: async task queues (@bentoml.task);submitreturns aTaskHandleforstatus/get/retry/cancel.Files:multipart/form-datafile inputs, raw-binary root inputs, and binary responses.Streaming:streamreturns aStreamof response chunks (featurestream).
The Client itself provides Readiness: is_ready / is_live health checks and
wait_until_ready.
These are gated by feature flags:
rustls-tls(default): HTTPS via Rustls.native-tls: HTTPS via the platform-native TLS stack.stream: streaming response endpoints (Streaming).tracing:#[tracing::instrument]on request methods.
Changelog
See CHANGELOG.md for release notes and version history.
License
Licensed under the MIT License.