Skip to content

Commit f288b00

Browse files
Add documentation for usage with Azure endpoints. (#68)
1 parent 3dc4b91 commit f288b00

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,32 @@ completion = openai.Completion.create(engine="ada", prompt="Hello world")
5252
print(completion.choices[0].text)
5353
```
5454

55+
### Microsoft Azure Endpoints
56+
57+
In order to use the library with Microsoft Azure endpoints, you need to set the api_type, api_base and api_version in addition to the api_key. The api_type must be set to 'azure' and the others correspond to the properites of your endpoint.
58+
In addition, the deployment name must be passed as the engine parameter.
59+
60+
```python
61+
import openai
62+
openai.api_type = "azure"
63+
openai.api_key = "..."
64+
openai.api_base = "https://example-endpoint.openai.azure.com"
65+
openai.api_version = "2021-11-01-preview"
66+
67+
# create a completion
68+
completion = openai.Completion.create(engine="deployment-namme", prompt="Hello world")
69+
70+
# print the completion
71+
print(completion.choices[0].text)
72+
73+
# create a search and pass the deployment-name as the engine Id.
74+
search = openai.Engine(id="deployment-namme").search(documents=["White House", "hospital", "school"], query ="the president")
75+
76+
# print the search
77+
print(search)
78+
```
79+
Please note that for the moment, the Microsoft Azure endpoints can only be used for completion and search operations.
80+
5581
### Command-line interface
5682

5783
This library additionally provides an `openai` command-line utility

0 commit comments

Comments
 (0)