openai icon indicating copy to clipboard operation
openai copied to clipboard

Is there any plan to support Azure OpenAI Service?

Open swsoyee opened this issue 2 years ago • 9 comments

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 avatar Mar 23 '23 12:03 swsoyee

@swsoyee, what I am thinking right now is to create a new package with much higher flexibility.

irudnyts avatar Mar 24 '23 12:03 irudnyts

Hi @irudnyts any updates on the new package? 📦 🙏🏽

trangdata avatar Jun 20 '23 18:06 trangdata

Hi @trangdata! Not yet 😔 Is there any particular feature you are looking forward to? Or is it just base_url for Azure?

irudnyts avatar Jun 20 '23 20:06 irudnyts

@irudnyts Really just the base_url for Azure.

trangdata avatar Jun 21 '23 12:06 trangdata

@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

irudnyts avatar Nov 19 '23 22:11 irudnyts

@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 avatar Apr 12 '24 10:04 JB0207

@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 avatar Apr 12 '24 11:04 irudnyts

@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}.

JB0207 avatar Apr 12 '24 11:04 JB0207

@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.

trangdata avatar Jul 03 '24 18:07 trangdata