asa-api / Tests /example_API_call.R
cjerzak's picture
up
a59174a
raw
history blame contribute delete
487 Bytes
library(httr2)
library(jsonlite)
base_url <- "http://localhost:7860"
resp <- request(paste0(base_url, "/v1/run")) |>
req_headers(`Content-Type` = "application/json") |>
# If you enabled ASA_API_KEY, add:
# req_headers(Authorization = paste("Bearer", Sys.getenv("ASA_API_KEY"))) |>
req_body_json(list(prompt = "Return the single word OK."), auto_unbox = TRUE) |>
req_perform()
result <- resp_body_json(resp, simplifyVector = TRUE)
print(result$status)
print(result$message)