File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
articles/cognitive-services/openai/how-to Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -22,13 +22,31 @@ An embedding is a special format of data representation that can be easily utili
22
22
23
23
To obtain an embedding vector for a piece of text, we make a request to the embeddings endpoint as shown in the following code snippets:
24
24
25
+ # [ console] ( #tab/console )
25
26
``` console
26
27
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/embeddings?api-version=2022-12-01\
27
28
-H 'Content-Type: application/json' \
28
29
-H 'api-key: YOUR_API_KEY' \
29
30
-d '{"input": "Sample Document goes here"}'
30
31
```
31
32
33
+ # [ python] ( #tab/python )
34
+ ``` python
35
+ import openai
36
+
37
+ openai.api_type = " azure"
38
+ openai.api_key = YOUR_API_KEY
39
+ openai.api_base = " https://YOUR_RESOURCE_NAME.openai.azure.com"
40
+ openai.api_version = " 2022-12-01"
41
+
42
+ response = openai.Embedding.create(
43
+ input = " Your text string goes here" ,
44
+ engine = " YOUR_DEPLOYMENT_NAME"
45
+ )
46
+ embeddings = response[' data' ][0 ][' embedding' ]
47
+ ```
48
+ ---
49
+
32
50
## Best Practices
33
51
34
52
### Verify inputs don't exceed the maximum length
You can’t perform that action at this time.
0 commit comments