diff --git a/README.md b/README.md index 24a2ac65..4867d84d 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,19 @@ To use the [Azure OpenAI Service](https://learn.microsoft.com/en-us/azure/cognit end ``` -where `AZURE_OPENAI_URI` is e.g. `https://custom-domain.openai.azure.com/openai/deployments/gpt-35-turbo` +where `AZURE_OPENAI_URI` is e.g. `https://custom-domain.openai.azure.com` + +Then add the `deployment_id` to the api calls. e.g: + +``` ruby +client.embeddings( + deployment_id: 'gpt-35-turbo', + parameters: { + model: 'text-embedding-ada-002', + input: + } +) +``` ### Models diff --git a/lib/openai/http.rb b/lib/openai/http.rb index 89b1a6db..50c823e0 100644 --- a/lib/openai/http.rb +++ b/lib/openai/http.rb @@ -6,7 +6,9 @@ def get(path:) end&.body) end - def json_post(path:, parameters:) + def json_post(path:, parameters:, deployment_id: nil) + path = "/openai/deployments/#{deployment_id}/#{path}" if deployment_id + to_json(conn.post(uri(path: path)) do |req| if parameters[:stream].respond_to?(:call) req.options.on_data = to_json_stream(user_proc: parameters[:stream])