.NET SDK
C# SDK with System.Net.Http, async/await, cancellation tokens, and streaming support
Installation
dotnet add package Beep.AI.SDKBasic Usage
using Beep.AI.SDK;
var client = new BeepClient(
baseUrl: "http://localhost:5000",
apiKey: "YOUR_API_TOKEN"
);
// Chat completions
var response = await client.Chat.Completions.CreateAsync(
model: "phi-2",
messages: new[] {
new Message { Role = "user", Content = "Hello!" }
}
);
Console.WriteLine(response.Choices[0].Message.Content);
// Streaming
await foreach (var chunk in client.Chat.Completions.CreateStreamAsync(
model: "phi-2",
messages: new[] {
new Message { Role = "user", Content = "Tell me a story" }
}
)) {
Console.Write(chunk.Choices[0].Delta.Content);
}
// Embeddings
var embedding = await client.Embeddings.CreateAsync(
model: "all-MiniLM-L6-v2",
input: "Hello world"
);
// RAG
var results = await client.Rag.QueryAsync(
collectionId: "my-docs",
query: "What is RAG?",
topK: 5
);
// With cancellation
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
var result = await client.Chat.Completions.CreateAsync(..., cts.Token);