vetiver_api | R Documentation |
vetiver_model()
objectUse vetiver_api()
to add a POST endpoint for predictions from a
trained vetiver_model()
to a Plumber router.
vetiver_api( pr, vetiver_model, path = "/predict", debug = is_interactive(), ... ) vetiver_pr_post( pr, vetiver_model, path = "/predict", debug = is_interactive(), ..., check_ptype = TRUE ) vetiver_pr_docs(pr, vetiver_model, path = "/predict", all_docs = TRUE)
pr |
A Plumber router, such as from |
vetiver_model |
A deployable |
path |
The endpoint path |
debug |
|
... |
Other arguments passed to |
check_ptype |
Should the |
all_docs |
Should the interactive visual API documentation be created
for all POST endpoints in the router |
You can first store and version your vetiver_model()
with
vetiver_pin_write()
, and then create an API endpoint with vetiver_api()
.
Setting debug = TRUE
may expose any sensitive data from your model in
API errors.
Two GET endpoints will also be added to the router pr
, depending on the
characteristics of the model object: a /pin-url
endpoint to return the
URL of the pinned model and a /ping
endpoint for the API health.
The function vetiver_api()
uses:
vetiver_pr_post()
for endpoint definition and
vetiver_pr_docs()
to create visual API documentation
These modular functions are available for more advanced use cases.
A Plumber router with the prediction endpoint added.
cars_lm <- lm(mpg ~ ., data = mtcars) v <- vetiver_model(cars_lm, "cars_linear") library(plumber) pr() %>% vetiver_api(v) ## is the same as: pr() %>% vetiver_pr_post(v) %>% vetiver_pr_docs(v) ## for either, next, pipe to `pr_run()`
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.