Skip to content

Commit 78aa4f8

Browse files
committed
adding csharp to embeddings doc
1 parent 4a2f6d6 commit 78aa4f8

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,29 @@ response = openai.Embedding.create(
4646
embeddings = response['data'][0]['embedding']
4747
print(embeddings)
4848
```
49+
50+
# [C#](#tab/csharp)
51+
```csharp
52+
using Azure;
53+
using Azure.AI.OpenAI;
54+
55+
Uri oaiEndpoint = new ("https://YOUR_RESOURCE_NAME.openai.azure.com"");
56+
string oaiKey = "YOUR_API_KEY";
57+
58+
AzureKeyCredential credentials = new (oaiKey);
59+
60+
OpenAIClient openAIClient = new (oaiEndpoint, credentials);
61+
62+
EmbeddingsOptions embeddingOptions = new ("Your text string goes here");
63+
64+
var returnValue = openAIClient.GetEmbeddings("YOUR_DEPLOYMENT_NAME", embeddingOptions);
65+
66+
foreach (float item in returnValue.Value.Data[0].Embedding)
67+
{
68+
Console.WriteLine(item);
69+
}
70+
```
71+
4972
---
5073

5174
## Best Practices

0 commit comments

Comments
 (0)