Unofficial C# SDK for Together.ai with Semantic Kernel integration.
Together.ai provides access to the latest open-source AI models through a simple API. This SDK offers:
- 🚀 Easy access to Together.ai's API from .NET applications
- 🧠 Seamless integration with Microsoft Semantic Kernel
- 🔧 Chat Completions, Text Generation, Embeddings and Image Generation
- 🌊 Both synchronous and streaming responses
- 🛠 Built-in function calling support
Choose the package(s) you need:
# Core API client
dotnet add package ManagedCode.Together
# Semantic Kernel integration
dotnet add package ManagedCode.Together.SemanticKernel
using Together;
var client = new TogetherClient("YOUR_API_KEY");
var response = await client.ChatCompletions.CreateAsync(new ChatCompletionRequest
{
Model = "mistralai/Mistral-7B-Instruct-v0.1",
Messages = new[]
{
new ChatCompletionMessage { Role = "user", Content = "Hello!" }
}
});
using Microsoft.SemanticKernel;
using Together.SemanticKernel;
// Initialize kernel with multiple Together.ai capabilities
var kernel = Kernel.CreateBuilder()
.AddTogetherChatCompletion(
"mistralai/Mistral-7B-Instruct-v0.1",
"YOUR_API_KEY"
)
.AddTogetherTextEmbeddingGeneration(
"togethercomputer/m2-bert-80M-2k-retrieval",
"YOUR_API_KEY"
)
.AddTogetherTextToImage(
"stabilityai/stable-diffusion-xl-base-1.0",
"YOUR_API_KEY"
)
.Build();
// Chat completion
var chatResult = await kernel.InvokePromptAsync("What is quantum computing?");
// Generate embeddings
var embeddingService = kernel.GetRequiredService<ITextEmbeddingGenerationService>();
var embeddings = await embeddingService.GenerateEmbeddingsAsync(
["What is quantum computing?"]
);
// Generate images
var imageService = kernel.GetRequiredService<ITextToImageService>();
var images = await imageService.GetImageContentsAsync(
"A cat playing piano",
new TogetherTextToImageExecutionSettings
{
Height = 512,
Width = 512
}
);
For more information about available models and features, visit the Together.ai Documentation
Contributions are welcome! Feel free to:
- Open issues for bugs or feature requests
- Submit pull requests
- Improve documentation
This project is licensed under the MIT License. See the LICENSE file for details.
If you find this project useful, please give it a star on GitHub!