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
using var client = new OpenAiClient(apiKey);

var response = await client.Embeddings.CreateEmbeddingsAsync(
    input: "Hello, world",
    model: CreateEmbeddingRequestModel.TextEmbedding3Small);

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