Together.AI
1.1.0
See the version list below for details.
dotnet add package Together.AI --version 1.1.0
NuGet\Install-Package Together.AI -Version 1.1.0
<PackageReference Include="Together.AI" Version="1.1.0" />
paket add Together.AI --version 1.1.0
#r "nuget: Together.AI, 1.1.0"
// Install Together.AI as a Cake Addin #addin nuget:?package=Together.AI&version=1.1.0 // Install Together.AI as a Cake Tool #tool nuget:?package=Together.AI&version=1.1.0
A unofficial .NET client for Together's API platform.
Getting started:
Prerequisites
If you'd like to use the Together.AI .NET client library you'll need an API key from a developer account at Together's API.
Install the package
Install the client library for .NET with NuGet:
dotnet add package Together.AI
Authenticate the client
In order to interact with Together's API, you'll need to create an instance of the IHttpClient
class that points to Together's api endpoint URI using a valid Authorization
API key.
The easiest way to do this is by using the SetupClient
extension method.
using Together.AI;
var client = new HttpClient();
client.SetupClient(apiKey: "your-api-key-from-together");
Then creates a instance of TogetherAIClient
using the configured HttpClient
.
var togetherAI = new TogetherAIClient(client);
Start Querying
Getting completion results
To simply get text completion results, you can use the GetCompletionAsync
method.
using Together.AI;
// ...
// Setup Request Arguments
var togetherAIArgs = new TogetherAIRequestArgs()
{
Model = "togethercomputer/RedPajama-INCITE-7B-Instruct",
MaxTokens = 128,
Prompt = "Alan Turing was "
};
var result = await togetherAI.GetCompletionAsync(togetherAIArgs);
// Print generated text
Console.WriteLine(result.Output.Choices[0].Text);
Streaming tokens
To get tokens as the model generates, you can use the GetCompletionStreamAsync
method.
using Together.AI;
// ...
var togetherAIArgs = new TogetherAIRequestArgs()
{
Model = MODEL_ID,
MaxTokens = 128,
Prompt = "Alan Turing was "
};
await foreach (var streamResult in togetherAI.GetCompletionStreamAsync(togetherAIArgs))
{
var token = streamResult.Choices[0].Text;
// Print generated token
Console.Write(token);
}
Examples
Looking for Grammar errors
using Together.AI;
const string API_KEY = "your-api-key-from-together";
const string MODEL_ID = "Open-Orca/Mistral-7B-OpenOrca";
const string PROMPT_TEMPLATE =
"<|im_start|> system\nDoes the text contain grammar errors? Answer with (Y/N)\n\n'{{$input}}'\n<|im_end|>\n<|im_start|> assistant\n";
var client = new HttpClient();
client.SetupClient(apiKey: API_KEY);
var togetherAI = new TogetherAIClient(client);
var promptInput = PROMPT_TEMPLATE.Replace(
oldValue: "{{$input}}",
newValue: "I mised the training session this morning"
);
var togetherAIArgs = new TogetherAIRequestArgs()
{
Model = MODEL_ID,
MaxTokens = 8,
Prompt = promptInput
};
var result = await togetherAI.GetCompletionAsync(togetherAIArgs);
Console.WriteLine(result.Output.Choices[0].Text);
// Result: 'Y'
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- Microsoft.Bcl.AsyncInterfaces (>= 8.0.0)
- System.Net.Http (>= 4.3.4)
- System.Net.Http.Json (>= 8.0.0)
- System.Text.Json (>= 8.0.0)
-
.NETStandard 2.0
- Microsoft.Bcl.AsyncInterfaces (>= 8.0.0)
- System.Net.Http.Json (>= 8.0.0)
- System.Text.Json (>= 8.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Together.AI:
Package | Downloads |
---|---|
Together.AI.SemanticKernel
A unofficial .NET Semantic Kernel integration for Together's API platform, providing a convenient way for interacting with the Together APIs and enables easy integration of the inference API with your applications. |
GitHub repositories
This package is not used by any popular GitHub repositories.