context to be initialized
(for authentication).
The following Chainlet wraps a deployed model with a Stub:
my_chainlet.py
- Input as JSON dict (like above) or pydantic model.
- Automatic parsing of the response into a pydantic model using the
output_modelargument. predict_async(recommended) orpredict_sync.- Streaming responses using
predict_async_streamwhich returns an async bytes iterator. - Customized with
RPCOptions.
TrussChainlet and TrussHandle
You can integrate existing Truss models directly into a chain without rewriting them asChainletBase subclasses. Use TrussChainlet to wrap a Truss directory and TrussHandle to manage connections to it.
TrussChainlet wraps an existing Truss directory as a non-entry leaf chainlet. This is useful for including models that use custom servers (like vLLM) or existing model.py implementations.
my_chainlet.py
TrussChainlet from another chainlet, use chains.depends() as a default argument in __init__. At runtime this provides a TrussHandle, which supplies the arguments for raw HTTP or WebSocket calls. TrussChainlet cannot be used as an entrypoint and cannot declare its own dependencies.
my_chainlet.py
TrussHandle supports Bring Your Own Client (BYOC) scenarios by exposing raw connection details:
http_call_args(): Returns the URL and headers for HTTP requests. Useprefer_internal=Trueto use the workload-plane URL with the correctHostheader, orsync_pathto rewrite the URL for platform passthrough endpoints.ws_call_args(): Returns the URL and headers for WebSocket connections.