Skip to content

Embeddings

Create a text embedding vector.

This example assumes using tryAGI.OpenAI; is in scope and apiKey contains your tryAGI.OpenAI API key.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
using var client = new OpenAiClient(apiKey);

var response = await client.Embeddings.CreateEmbeddingAsync(new CreateEmbeddingRequest
{
    Input = "Hello, world",
    Model = CreateEmbeddingRequestModel.TextEmbedding3Small,
});

foreach (var data in response.Data.ElementAt(0).Embedding1)
{
    Console.WriteLine($"{data}");
}