Skip to content

Commit 4592a04

Browse files
authored
Add python code sample
1 parent 66ddfb7 commit 4592a04

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

articles/cognitive-services/openai/how-to/embeddings.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,22 @@ An embedding is a special format of data representation that can be easily utili
2222

2323
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:
2424

25+
# [console](#tab/console)
2526
```console
2627
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/embeddings?api-version=2022-12-01\
2728
-H 'Content-Type: application/json' \
2829
-H 'api-key: YOUR_API_KEY' \
2930
-d '{"input": "Sample Document goes here"}'
3031
```
32+
# [python](#tab/python)
33+
```python
34+
response = openai.Embedding.create(
35+
input="Your text string goes here",
36+
model="YOUR_DEPLOYMENT_NAME"
37+
)
38+
embeddings = response['data'][0]['embedding']
39+
```
40+
---
3141

3242
## Best Practices
3343

0 commit comments

Comments
 (0)