bentoml
An unofficial async Rust client for BentoML services (GitHub).
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 you name a route
with client.endpoint(route) and call it over your own serde types.
Features
- Typed calls:
endpoint(route).call(&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: exponential-backoff retries via
reqwest-middleware, bearer-token auth, an optional per-request timeout, and a cheap-to-cloneArc-backed client.
Usage
Add the dependency:
[]
= "0.4"
= { = "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 covers the BentoML HTTP surface:
call: the common JSON-in, JSON-out request.call_json/call_bytes/call_multipart: send a JSON, raw-binary, ormultipart/form-databody (built withmultipart::Multipart), returning anEndpointResponseyou read as.json::<R>(),.bytes(), or.text()— so input and output encodings are chosen independently.submit: async task queues (@bentoml.task); returns aTaskHandleforstatus/get/retry/cancel.stream(featurestream): returns aByteStreamof response chunks; decode it with.text(),.lines(), or.json::<T>().
The Client itself provides health checks: is_ready / is_live 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 (Endpoint::stream).tracing:#[tracing::instrument]spans on request methods, including anyx-request-idas arequest_idfield.
Changelog
See CHANGELOG.md for release notes and version history.
License
Licensed under the MIT License.