PublicAI.Net 0.1.4

dotnet add package PublicAI.Net --version 0.1.4
                    
NuGet\Install-Package PublicAI.Net -Version 0.1.4
                    
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="PublicAI.Net" Version="0.1.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PublicAI.Net" Version="0.1.4" />
                    
Directory.Packages.props
<PackageReference Include="PublicAI.Net" />
                    
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 PublicAI.Net --version 0.1.4
                    
#r "nuget: PublicAI.Net, 0.1.4"
                    
#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 PublicAI.Net@0.1.4
                    
#: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=PublicAI.Net&version=0.1.4
                    
Install as a Cake Addin
#tool nuget:?package=PublicAI.Net&version=0.1.4
                    
Install as a Cake Tool

PublicAI.Net

PublicAI.NET is a .NET client library for interacting with the PublicAI platform, which is built on top of the Apertus Large Language Model. This library provides basic tooling to work with PublicAI Rest API.

What is PublicAI.co

PublicAI.co hosts the open source LLM Apertus with its ChatAPI. (accessible here)

The Public AI Inference Utility is a nonprofit, open-source project. Our team builds products and organizes advocacy to support the work of public AI model builders like the Swiss AI Initiative, AI Singapore, AI Sweden, and the Barcelona Supercomputing Center.

Source: https://publicai.co/about

What is Apertus

EPFL, ETH Zurich, and the Swiss National Supercomputing Centre (CSCS) has released Apertus, Switzerland�s first large-scale open, multilingual language model � a milestone in generative AI for transparency and diversity. Trained on 15 trillion tokens across more than 1,000 languages � 40% of the data is non-English � Apertus includes many languages that have so far been underrepresented in LLMs, such as Swiss German, Romansh, and many others. Apertus serves as a building block for developers and organizations for future applications such as chatbots, translation systems, or educational tools.

Source: https://www.swiss-ai.org/apertus

How to use PublicAI.Net

Get API Key

API Keys are available from here (where you also find the API Spec).

You'll need to to login first or create an account.

The API Keys can be generated under your profile (in the upper right corner).

As of 20.09.2025 the API is free to use under fair use policy, and you can generate API keys which never expire.

Install PublicAI.Net

dotnet add package PublicAI.Net

Simplified Example

The Library provides a simplified way to interact with the Chat API.

using PublicAI.Net.Simplified;
using PublicAI.Net.Models;

ChatContext chatContext = ChatContextBuilder
        .Create()
        .WithApiKey("{apiKey}") // if not provided will try to read it from environment variables
        .WithSystemContext("Answer in no more than 100 words.")
        .Build();

_output.WriteLine((await chatContext.ChatAsync("Why should I use an open source AI?")).GetText());
_output.WriteLine((await chatContext.ChatAsync("Can you elaborate on the first point?")).GetText());

Output:

Using open-source AI can be beneficial for several reasons:

1. Transparency: Open-source AI models ensure transparency as their code and algorithmic processes are all open for review. This helps users understand how decisions are made and fosters trust.

2. Customization: Open-source AI enables users to customize models to fit specific requirements or datasets more effectively.

3. Collaborative Development: The open-source nature of AI allows for widespread collaboration, with multiple developers working on issues, leading to rapid improvement and updates.

4. Community Engagement: By being open, it encourages feedback and contributions from users and experts, leading to better models that can be used by the broader community.

5. Cost-effective: Since open-source AI often eliminates licensing costs, it can save money for organizations or individuals.
Absolutely!

Transparency is a great benefit of using open-source AI. Since open-source AI models have open source code, anyone can inspect the code to understand how the AI model works. This helps with algorithmic accountability, meaning users can see if the AI model is doing something it shouldn�t be (like unfairly discriminating against certain groups).

This transparency is crucial for building trust, especially in applications where AI is making critical decisions (like in healthcare, justice, or finance). Users and developers can follow the "state-of-the-art" and adapt new methods as they become available, since they know exactly how the model operates.

However, it's important to note that transparency doesn't necessarily imply simplicity; complex algorithms can still be obscure even when open-source. But the existence of the code allows for analysis and audit if needed.

Base Example

using PublicAI.Net;
using PublicAI.Net.Models;

PublicAIClientSettings settings = new PublicAIClientSettings
{
	ApiKey = Environment.GetEnvironmentVariable("PUBLICAI_API_KEY")
}

PublicAIClient client = new PublicAIClient(settings);
ModelResponse? models = await client.ListModelsAsync();

string modelName = models?.Data?.FirstOrDefault(m => m.Id == "swiss-ai/apertus-70b-instruct")?.Id 
                    ?? throw new Exception("Model not found");

ChatCompletionRequest request = new ChatCompletionRequest(
        modelName,
        [
            new ChatMessage(ChatMessageRole.User, "When should I use AI?")
        ]);

ChatCompletionReponse? response = await client.ChatAsync(request);
Console.WriteLine(response.Choices.First().Message.Content);

Repository

The repository uses gitversion, so follow the proper branch naming convention.

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.
  • net9.0

    • No dependencies.

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
0.1.4 183 9/21/2025
0.1.3 162 9/21/2025
0.1.0 264 9/17/2025