Alephbasys.Mana.Gateway.Client 2.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Alephbasys.Mana.Gateway.Client --version 2.0.1
                    
NuGet\Install-Package Alephbasys.Mana.Gateway.Client -Version 2.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Alephbasys.Mana.Gateway.Client" Version="2.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Alephbasys.Mana.Gateway.Client" Version="2.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Alephbasys.Mana.Gateway.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Alephbasys.Mana.Gateway.Client --version 2.0.1
                    
#r "nuget: Alephbasys.Mana.Gateway.Client, 2.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Alephbasys.Mana.Gateway.Client@2.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Alephbasys.Mana.Gateway.Client&version=2.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Alephbasys.Mana.Gateway.Client&version=2.0.1
                    
Install as a Cake Tool

Mana Gateway SDK

A multi-language SDK (C# implemented, TypeScript & Python planned) for the Mana Gateway API.

Evaluation key: free (3 req/min). Replace with your own X-Key for production.

Table of Contents

  1. Quickstart (5 minutes)
  2. Installation
  3. Sending a Prompt (Chat Completion)
  4. Streaming (preview)
  5. Handling Rate Limits & Retries
  6. Listing Models with Pagination
  7. Error Handling
  8. Migration (1.x → 2.0)
  9. FAQ
  10. Contributing / License

1. Quickstart (5 minutes)

C#

using Alephbasys.Mana.Gateway.Client;
using Alephbasys.Mana.Gateway.Client.Models; // legacy (will move to domain soon)

var http = new HttpClient();
var client = new ManaGatewayClient(http, apiKey: Environment.GetEnvironmentVariable("MANA_KEY") ?? "free");

// List models
var models = await client.GetModelsAsync();
Console.WriteLine($"Models: {models.Data.Length}");

// Simple chat completion
var chat = await client.CreateChatCompletionAsync(
    new ChatCompletionRequest(
        Model: "gpt-3.5-turbo", // example
        Messages: new [] { new ChatMessage(ChatRole.User, "Say hello in Persian") }
    )
);
Console.WriteLine(chat.Choices.Length > 0 ? chat.Choices[0].Message.Content : "<no output>");

TypeScript (planned)

import { ManaClient } from '@mana-gateway/sdk';
const client = new ManaClient({ apiKey: process.env.MANA_KEY || 'free' });
const catalog = await client.models.list();
console.log('Models', catalog.models.length);
const result = await client.chat.complete({
  modelId: 'gpt-3.5-turbo',
  messages: [{ role: 'user', content: 'Say hello in Persian' }]
});
console.log(result.choices[0].message.content);

Python (planned)

from mana_gateway import ManaClient
client = ManaClient(api_key=os.getenv("MANA_KEY", "free"))
cat = client.models.list()
print("Models", len(cat.models))
resp = client.chat.complete(model_id="gpt-3.5-turbo", messages=[{"role":"user","content":"Say hello in Persian"}])
print(resp.choices[0].message.content)

2. Installation

C#

dotnet add package Alephbasys.Mana.Gateway.Client

TypeScript & Python packages will be published after domain API stabilization.


3. Sending a Prompt (Chat Completion)

Current C# surface (will migrate to domain names):

var completion = await client.CreateChatCompletionAsync(
    new ChatCompletionRequest(
        Model: "gpt-3.5-turbo",
        Messages: new [] { new ChatMessage(ChatRole.User, "Explain embeddings in one sentence") },
        Temperature: 0.7
    ));
Console.WriteLine(completion.Choices[0].Message.Content);

Future domain API (preview intent):

// var completion = await mana.Chat.CreateAsync(new ChatCompletionRequest { ... });

4. Streaming (preview)

Streaming helpers (StreamingExtensions) provide an adapter pattern. A full streaming chat endpoint will surface as an IAsyncEnumerable<ChatStreamEvent> when the API supports SSE / chunked responses.

Conceptual usage:

await foreach (var delta in stream.ToAsyncEnumerable(ct))
{
    Console.Write(delta.Token);
}

5. Handling Rate Limits & Retries

The builder adds retry with exponential backoff + jitter for transient 5xx/408.

using Alephbasys.Mana.Gateway.Client.Domain.Client;
var mana = new ManaClientBuilder()
    .UseApiKey("free")
    .WithRetryPolicy(maxRetries: 3)
    .Build();

Explicit handling (typed errors):

try { await client.GetModelsAsync(ct); }
catch (ManaGatewayException ex) when (ex.Code == ManaErrorCode.RateLimited)
{
    await Task.Delay(ex.RetryAfter ?? TimeSpan.FromSeconds(2), ct);
}

6. Listing Models with Pagination

Pagination helper is generic; once list endpoints accept page params you can do:

await foreach (var page in fetchPageFunc.PaginateAsync(pageSize: 50, ct))
{
    foreach (var item in page) Console.WriteLine(item.ModelId);
}

Where fetchPageFunc matches (pageIndex, pageSize, ct) => Task<IReadOnlyList<T>>.


7. Error Handling

All failures throw ManaGatewayException with Code, StatusCode, RequestId, Hint and optional RetryAfter. See: docs/errors.md.


8. Migration (1.x → 2.0)

Legacy wire types (ModelsResponse, ChatCompletionResponse, etc.) are marked [Obsolete]. Use domain models (e.g. ModelCatalog, ChatCompletionResult) as they land. Full rename map: docs/model-rename-map.md. Guide: docs/migration-1.x-to-2.0.md.


9. FAQ

Why new names? Improve clarity & future-proofing.

Is the free key production safe? No—only for light evaluation.

When will streaming be available? After server exposes SSE/chunk streaming; client scaffolding is ready.

How do I report issues? Open a GitHub issue with repro + RequestId.


10. Contributing / License

PRs welcome for mappings, mappers, analyzers, and language ports. See LICENSE.


Roadmap Snapshot

  • Builder & retry
  • Typed errors
  • Domain model spec & initial models
  • Full mappers (chat, embeddings, health)
  • Streaming chat events
  • TypeScript & Python ports
  • Analyzer & codemod
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.2 19 9/23/2025
2.0.1 30 9/23/2025
1.0.6 253 9/15/2025
1.0.5 217 9/1/2025
1.0.4 127 9/1/2025
1.0.3 128 9/1/2025
1.0.2 125 9/1/2025
1.0.1 184 8/28/2025
1.0.0 298 8/25/2025

2.0.0: Domain model layer (initial), typed error system, retry handler, builder, pagination/streaming scaffolds, deprecation shims for legacy wire models. See CHANGELOG.md.