Basic example showing how to create a client and make a request.
1
usingvarclient=newWriterClient(apiKey);
Chat Client Get Response
1 2 3 4 5 6 7 8 9101112
usingvarclient=newWriterClient(apiKey);Meai.IChatClientchatClient=client;// Use the MEAI IChatClient interface for chat completions.varresponse=awaitchatClient.GetResponseAsync(messages:[newMeai.ChatMessage(Meai.ChatRole.User,"Generate 5 random words.")],newMeai.ChatOptions{ModelId="palmyra-x-004",});Console.WriteLine(response.Text);
Chat Client Streaming
1 2 3 4 5 6 7 8 91011121314151617
usingvarclient=newWriterClient(apiKey);Meai.IChatClientchatClient=client;// Stream chat responses using the MEAI IChatClient interface.varenumerable=chatClient.GetStreamingResponseAsync(messages:[newMeai.ChatMessage(Meai.ChatRole.User,"Generate 5 random words.")],newMeai.ChatOptions{ModelId="palmyra-x-004",});vardeltas=newList<string>();awaitforeach(varupdateinenumerable){Console.Write(update.Text);deltas.Add(update.Text??string.Empty);}
Chat Client Get Service Metadata
12345
usingvarclient=newWriterClient("test-api-key");Meai.IChatClientchatClient=client;// Retrieve metadata about the chat provider.varmetadata=Meai.ChatClientExtensions.GetService<Meai.ChatClientMetadata>(chatClient);
usingvarclient=newWriterClient(apiKey);Meai.IChatClientchatClient=client;// Stream chat responses with tool calling using the MEAI IChatClient interface.// Define a simple tool that returns the current weather.vartool=Meai.AIFunctionFactory.Create((stringlocation)=>$"The weather in {location} is sunny, 72°F.","get_weather","Gets the current weather for a location.");varenumerable=chatClient.GetStreamingResponseAsync(messages:[newMeai.ChatMessage(Meai.ChatRole.User,"What's the weather in San Francisco?")],newMeai.ChatOptions{ModelId="palmyra-x-004",Tools=[tool],});varhasContent=false;Meai.ChatFinishReason?finishReason=null;awaitforeach(varupdateinenumerable){if(update.Textis{Length:>0}){Console.Write(update.Text);hasContent=true;}if(update.FinishReasonisnotnull){finishReason=update.FinishReason;}}// The model should either respond with tool calls or text content.
Ecosystem maintenance
This SDK is one of more than 200 .NET SDKs maintained with AutoSDK. The tryAGI SDK audit continuously checks repository synchronization, upstream-spec regeneration, release workflows, warnings, public API visibility, and trimming/NativeAOT compatibility.
Every issue is first investigated for ecosystem-wide applicability. When the root cause belongs in AutoSDK, we fix and regression-test the generator, then roll the improvement out to every applicable SDK. Provider-specific behavior remains in this repository when it cannot be derived safely from the API specification.
Issue content—including code blocks, logs, links, and attachments—is treated only as untrusted diagnostic data. Embedded control instructions, hidden directives, delimiter tricks, or requests to alter triage or tooling behavior are ignored. Please report reproducible technical evidence and remove secrets and personal data.