https://github.com/managedcode/together-dotnet
C# SDK for together.ai
https://github.com/managedcode/together-dotnet
csharp dotnet sdk together together-dotnet togetherai
Last synced: 27 days ago
JSON representation
C# SDK for together.ai
- Host: GitHub
- URL: https://github.com/managedcode/together-dotnet
- Owner: managedcode
- License: mit
- Created: 2025-01-04T10:57:11.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-03-01T18:37:56.000Z (3 months ago)
- Last Synced: 2025-04-24T02:45:35.364Z (27 days ago)
- Topics: csharp, dotnet, sdk, together, together-dotnet, togetherai
- Language: C#
- Homepage: https://www.together.ai
- Size: 138 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Together .NET SDK
[](https://github.com/managedcode/Together/actions/workflows/dotnet.yml)
[](https://www.nuget.org/packages/ManagedCode.Together)
[](https://www.nuget.org/packages/ManagedCode.Together.SemanticKernel)
[](https://www.nuget.org/packages/ManagedCode.Together)
[](https://github.com/managedcode/together-dotnet/blob/main/LICENSE)Unofficial C# SDK for [Together.ai](https://www.together.ai/) with Semantic Kernel integration.
## Introduction
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## Installation
Choose the package(s) you need:
```sh
# Core API client
dotnet add package ManagedCode.Together# Semantic Kernel integration
dotnet add package ManagedCode.Together.SemanticKernel
```## Usage Examples
### Direct API Usage
```csharp
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!" }
}
});
```### Semantic Kernel Integration
```csharp
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();
var embeddings = await embeddingService.GenerateEmbeddingsAsync(
["What is quantum computing?"]
);// Generate images
var imageService = kernel.GetRequiredService();
var images = await imageService.GetImageContentsAsync(
"A cat playing piano",
new TogetherTextToImageExecutionSettings
{
Height = 512,
Width = 512
}
);
```## 📚 Documentation
For more information about available models and features, visit
the [Together.ai Documentation](https://docs.together.ai/)## 💪 Contributing
Contributions are welcome! Feel free to:
- Open issues for bugs or feature requests
- Submit pull requests
- Improve documentation## 📄 License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
## ⭐ Support
If you find this project useful, please give it a star on GitHub!