The Together SDK implements IChatClient and IEmbeddingGenerator<string, Embedding<float>> and provides AIFunction tool wrappers, all compatible with Microsoft.Extensions.AI.
Namespace Conflict
This SDK has a generated IChatClient interface that conflicts with Microsoft.Extensions.AI.IChatClient. Use the Meai alias pattern shown below.
Supported Interfaces
Interface
Support Level
IChatClient
Full (text, streaming, tool calling, reasoning)
IEmbeddingGenerator<string, Embedding<float>>
Full
IChatClient
Installation
1
dotnetaddpackagetryAGI.Together
Basic Usage
Because the SDK generates its own IChatClient interface, you must use a namespace alias:
1 2 3 4 5 6 7 8 91011121314
usingTogether;usingMeai=Microsoft.Extensions.AI;usingvarclient=newTogetherClient(apiKey);Meai.IChatClientchatClient=client;varresponse=awaitchatClient.GetResponseAsync("What is the capital of France?",newMeai.ChatOptions{ModelId="meta-llama/Llama-3.3-70B-Instruct-Turbo",});Console.WriteLine(response.Text);
Streaming
1 2 3 4 5 6 7 8 910111213
usingMeai=Microsoft.Extensions.AI;Meai.IChatClientchatClient=client;awaitforeach(varupdateinchatClient.GetStreamingResponseAsync("Write a short poem about coding.",newMeai.ChatOptions{ModelId="meta-llama/Llama-3.3-70B-Instruct-Turbo",})){Console.Write(update.Text);}
Tool Calling
1 2 3 4 5 6 7 8 9101112131415161718192021
usingCSharpToJsonSchema;usingMeai=Microsoft.Extensions.AI;[GenerateJsonSchema]publicinterfaceIWeatherTools{[Description("Gets the current weather for a location.")]stringGetWeather([Description("The city name")]stringcity);}Meai.IChatClientchatClient=client;varservice=newWeatherToolsService();varresponse=awaitchatClient.GetResponseAsync("What's the weather in Paris?",newMeai.ChatOptions{ModelId="meta-llama/Llama-3.3-70B-Instruct-Turbo",Tools=service.AsTools().AsAITools(),});
Accessing Client Metadata
When using the Meai alias, call extension methods explicitly: