Search

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
var apiKey =
    Environment.GetEnvironmentVariable("TAVILY_API_KEY") ??
    throw new AssertInconclusiveException("TAVILY_API_KEY environment variable is not found.");

using var client = new TavilyClient();

SearchResponse searchResponse = await client.SearchAsync(
    apiKey: apiKey,
    query: "Who is Leo Messi?");

foreach (var result in searchResponse.Results)
{
    Console.WriteLine($"Title: {result.Title}");
    Console.WriteLine($"Content: {result.Content}");
    Console.WriteLine($"Score: {result.Score}");
    Console.WriteLine($"Url: {result.Url}");
    Console.WriteLine();
}