Skip to content

Embeddings

Tolga Kayhan edited this page Feb 16, 2023 · 1 revision

Create an embedding request

Sample 1

var embeddingResult = await sdk.Embeddings.CreateEmbedding(new EmbeddingCreateRequest()
{
   InputAsList = new List<string> {"The quick brown fox jumped over the lazy dog."},
   Model = Models.TextSearchAdaDocV1
});

Handle Response

if (embeddingResult.Successful)
{
   Console.WriteLine(embeddingResult.Data.FirstOrDefault());
}
else
{
   if (embeddingResult.Error == null)
   {
      throw new Exception("Unknown Error");
   }
   Console.WriteLine($"{embeddingResult.Error.Code}: {embeddingResult.Error.Message}");
}
Clone this wiki locally