openai
openai copied to clipboard
Is there any plan to support Azure OpenAI Service?
It seems that just need to change the base_url to a function parameter that can be passed in.
https://github.com/search?q=repo%3Airudnyts%2Fopenai%20https%3A%2F%2Fapi.openai.com%2Fv1&type=code
Reference: https://learn.microsoft.com/en-us/azure/cognitive-services/openai/chatgpt-quickstart?tabs=powershell&pivots=rest-api
@swsoyee, what I am thinking right now is to create a new package with much higher flexibility.
Hi @irudnyts any updates on the new package? 📦 🙏🏽
Hi @trangdata! Not yet 😔 Is there any particular feature you are looking forward to? Or is it just base_url for Azure?
@irudnyts Really just the base_url for Azure.
@trangdata @swsoyee I'm very sorry for the long wait. Here is a new dev version, and you can do it here:
remotes::install_github("irudnyts/openai", ref = "r6")
library(openai)
client <- OpenAI(base_url = "your_azure_url")
completion <- client$chat$completions$create(
model = "gpt-4-1106-preview",
messages = list(list("role" = "user", "content" = "What's up?"))
)
completion$choices[[1]]$message$content
@trangdata Did you get it to work? I am always getting a 404 error using the following base_url:
"https://[...]/openai.azure.com/openai/deployments/gpt-35-turbo/chat/completions?api-version=2024-02-01"
@JB0207 Can you please specify how exactly your URL should look like? When you specify base_url in OpenAI() and then use, for example, client$chat$completions$create(), the endpoint URL will look like your_azure_url/chat/completions.
@irudnyts Thank you for your fast response! Ah, I understand... According to the documentation of Azure OpenAI Service the endpoint url should look like this: https://{your-resource-name}.openai.azure.com/openai/deployments/{deployment-id}/chat/completions?api-version={api-version}.
@trangdata Did you get it to work? I am always getting a 404 error using the following base_url:
No... I couldn't get the example code snippet to work.
Error in httr2::req_perform():
! HTTP 401 Unauthorized.