How to integrate GPT-4 model hosted on Azure with a chattr package?

I am currently looking to integrate the OpenAI GPT-4 model into my application. Here are the details I have:

  • Endpoint: https://xxxxxxxxxxxxxxx.openai.azure.com/
  • Location/Region: yyyyyyyyyyyyyyyyyyyyyyyy
  • Key: *******************
  • Deployment Name: gpt-4o
  • Model Name: gpt-4o
  • Model Version: 2024-05-13

I want to integrate it with chattr. Could someone guide me on how to authenticate and make API requests to this endpoint?

I tried:

library(chattr)
chattr_use(
  "gpt4",   
  path = "https://xxxxxxxxxxxxxxx.openai.azure.com/",
  model = "gpt-4o"
)

I saved the API under the .Renviron file.

#testing
chattr::chattr("1+1")
{{error}}Type:
Message: Resource not found! {error}Type:
Message: Resource not found
Error in `abort()`:
! `message` must be a character vector, not a <httr2_response> object.
Run `rlang::last_trace()` to see where the error occurred.