Updated and supported automatically if there are no breaking changes
All modern .NET features - nullability, trimming, NativeAOT, etc.
Support .Net Framework/.Net Standard 2.0
Usage
123
usingExa;usingvarclient=newExaClient(apiKey);
Search
Shows how to search the web using Exa's AI-powered search.
1 2 3 4 5 6 7 8 9101112131415161718192021
usingvarclient=newExaClient(apiKey);// Search the web for relevant results using a natural language query.varresponse=awaitclient.SearchAsync(newAllOf<SearchRequest2,CommonRequest>{Value1=newSearchRequest2{Query="Latest developments in LLM capabilities",},Value2=newCommonRequest{NumResults=5,},});Console.WriteLine($"Found {response.Results!.Count} results");foreach(varresultinresponse.Results){Console.WriteLine($" - {result.Value1?.Title}: {result.Value1?.Url}");}
Get Contents
Shows how to retrieve page contents for specific URLs using Exa.
1 2 3 4 5 6 7 8 910111213141516171819202122
usingvarclient=newExaClient(apiKey);// Retrieve the text content of specific web pages by URL.varresponse=awaitclient.GetContentsAsync(newAllOf<GetContentsRequest2,ContentsRequest>{Value1=newGetContentsRequest2{Urls=["https://exa.ai"],},Value2=newContentsRequest{Text=true,},});Console.WriteLine($"Retrieved contents for {response.Results!.Count} URL(s)");foreach(varresultinresponse.Results){vartext=result.Value2?.Text;Console.WriteLine($" - {result.Value1?.Url}: {text?[..Math.Min(text.Length, 100)]}...");}
Find Similar
Shows how to find pages similar to a given URL using Exa.
1 2 3 4 5 6 7 8 910111213141516171819202122
usingvarclient=newExaClient(apiKey);// Find pages similar to a given URL. This is useful for discovering// related content, competitor analysis, or expanding a research corpus.varresponse=awaitclient.FindSimilarAsync(newAllOf<FindSimilarRequest2,CommonRequest>{Value1=newFindSimilarRequest2{Url="https://arxiv.org/abs/2307.06435",},Value2=newCommonRequest{NumResults=3,},});Console.WriteLine($"Found {response.Results!.Count} similar pages");foreach(varresultinresponse.Results){Console.WriteLine($" - {result.Value1?.Title} (score: {result.Value1?.Score:F4})");}
Search Tool
Shows how to use Exa as an AIFunction tool with any IChatClient.
1234
usingvarclient=newExaClient(apiKey);// Create a search tool from the Exa client for use with any IChatClient.vartool=client.AsSearchTool(numResults:3);
Answer Tool
Shows how to use Exa's answer endpoint as an AIFunction tool with any IChatClient.
1234
usingvarclient=newExaClient(apiKey);// Create an answer tool from the Exa client for RAG-style question answering.vartool=client.AsAnswerTool();