Search uploaded document collections using hybrid search.
This example assumes using Xai; is in scope and apiKey contains your Xai API key.
1 2 3 4 5 6 7 8 910111213141516171819
varclient=newXaiClient(apiKey);varcollectionId=Environment.GetEnvironmentVariable("XAI_COLLECTION_ID")is{Length:>0}value?value:thrownewAssertInconclusiveException("XAI_COLLECTION_ID environment variable is not found.");// Search across document collections using hybrid (semantic + keyword) mode.varresponse=awaitclient.Collections.SearchDocumentsAsync(query:"What is xAI?",collectionIds:[collectionId],mode:SearchDocumentsRequestMode.Hybrid,maxNumResults:5);foreach(varresultinresponse.Results!){Console.WriteLine($"Score: {result.Score:F3} — {result.Content?[..Math.Min(80, result.Content?.Length ?? 0)]}...");}