AbpAi.Contracts 0.9.0

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

AbpAi

The model gateway for ABP applications on .NET 10 and PostgreSQL. Every host gets aliases, limits, usage and providers from one package, and rules for which data may go to which provider. It is also the default model behind AbpAgent.

Preview. 0.x versions may change their API in any minor version (SemVer). Pin an exact version.

Not a Volosoft project. ABP Framework is made and owned by Volosoft. AbpAi is an independent enhancement that works on ABP: this repository and its packages don't belong to Volosoft, and aren't affiliated with or endorsed by them.

What it does

  • One call: IAi.CompleteAsync (one whole reply), StreamAsync (the reply as it's written), ResolveAsync (which model an alias leads to). Messages, tools, replies and stream events are in the Messages API's shape; providers translate to and from it. A call may give its system prompt as blocks (with cache_control) and more of the provider's request as ProviderOptions (thinking, temperature).
  • Aliases: fast, smart, local. The call's scope's first, then each scope above it, then the site's, else a model by its name. An alias has targets in order; the ones after the first are its fallbacks. Its name is lowercase letters, digits and dashes, and each target is set to a model that's on.
  • Models with what they can do: each of a connection's models has a name to call it by, is on or off, and says whether it takes tools and images and follows a schema; a call goes to the first target that can do what it needs. A provider lists the models it offers, and an admin adds what it finds, each off until it's turned on.
  • Providers: Anthropic, OpenAI-compatible (OpenAI, Azure OpenAI, Ollama, vLLM, most gateways) and a demo model. Others plug in through IAiProvider, under a kind of the host's own (acme:bedrock).
  • Connections for the site, and for each scope when the site lets it. Keys are encrypted and never shown. A host that keeps connections of its own gives them through IAiConnectionSource: the gateway's aliases, limits, usage and data rules apply to them by id, and their keys are asked only as a call goes out.
  • Scopes the host defines (IAiScopes): projects, model sets, org units. Scopes nest. A call counts against its scope and every scope above it, and an alias or connection set on a scope applies to the scopes under it. The site may list which of its models each scope may use, and which scopes may connect their own.
  • Limits on cost, tokens or calls, over a minute, a day, a week or a month: a scope's total (the site's too), what each person may spend (with overrides for named accounts and groups, no row per person), and a named account's own (an agent's); and the most tokens one reply may have. Each call's estimate is reserved on a usage ledger under one lock, so calls at the same time can't go over. A refusal names the limit, what it counts and when it frees. Admins hear when a limit reaches 80%.
  • Which data may go where: the site's data classes (public, internal, aggregates, rows, sensitive), each connection's list of what it may receive and labels for where it runs, and each call's highest class. A call that doesn't fit is refused with data_not_allowed before it leaves, or falls back to a target that may receive it. A call that states no class counts as the highest. Prompts aren't kept unless the site turns that on, for a period.
  • Usage people can read: by scope, person, account, purpose, model, connection, day and data class, and export as CSV. Scopes and people are named as the host names them (IAiScopes, IAiAccounts.NamesOfAsync). A scope's admins see their scope and those under it, nothing else; each person sees their own.
  • The demo model as a test tool: AiScript answers for it with scripted replies (from code or a JSON file), so features that use AI, and evals, run in CI with no provider.

Packages

Package Holds Depends on
AbpAi.Contracts IAi and its records, refusals, IAiProvider, IAiDemoResponder, the host's seams Plain .NET
AbpAi The service, the ledger, limits, notices, connections, the admin and usage services, the built-in providers; tables in schema ai ABP, EF Core (PostgreSQL)
AbpAi.Agents AbpAgent's IAgentModels on top of IAi, so neither package needs the other Both (not on nuget.org until AbpAgent's contracts are)
AbpAi.HttpApi The admin API over HTTP: site settings, connections, aliases, limits, scopes' access, a scope's own view, a call to try, usage, exports, under a prefix the host sets AbpAi, ABP's MVC

Coming from ABP's module template? Where ABP's layers are in this repository.

Getting started

[DependsOn(typeof(AbpAiModule))]
public class MyHostModule : AbpModule
{
    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        context.Services.AddAbpDbContext<MyDbContext>(o => o.ReplaceDbContext<IAiDbContext>());
        context.Services.Replace(ServiceDescriptor.Transient<IAiScopes, MyScopes>());   // who a scope's parent is
        context.Services.Replace(ServiceDescriptor.Transient<IAiRights, MyRights>());   // who administers what
    }
}

// In MyDbContext.OnModelCreating:
modelBuilder.ConfigureAi();

Then call a model:

AiReply reply = await ai.CompleteAsync(new AiRequest("smart", AiMessages.User("Describe the orders table."))
{
    ScopeId = modelSetId,             // the host's scope
    AccountId = currentUserId,        // whose limits
    DataClass = AiDataClasses.Internal,
    Purpose = "describe-model",       // what asked, for usage
    MaxTokens = 800,
});

The admin API, for a settings screen of your own or @abpjs/ai, is one more module:

[DependsOn(typeof(AbpAiModule), typeof(AbpAiHttpApiModule))]
// ...
Configure<AiHttpOptions>(o =>
{
    o.RoutePrefix = "api/ai";                                           // the default
    o.Sensitive = action => action.Filters.Add(new StepUpAttribute());  // the password again, AbpGuard's step-up say
});

See hosting, data rules, limits, usage, embeddings, testing with the demo model, AbpAgent, and moving a product onto AbpAi. Why it is shaped this way, and the answers to the open questions, are in ADR 0001.

Building

dotnet build AbpAi.slnx

The host tests need PostgreSQL on localhost:5432 (postgres/postgres), or the server ABP_AI_TEST_POSTGRES names.

dotnet test AbpAi.slnx
bash scripts/check-names.sh   # no product's name but AbpAi's

Releasing

Set VersionPrefix and VersionSuffix in Directory.Build.props, move CHANGELOG.md's Unreleased to the version, and push a tag v<version> (v0.2.0). CI runs the checks, then pushes AbpAi, AbpAi.Contracts, AbpAi.Agents and AbpAi.HttpApi to nuget.org through Trusted Publishing (the policy names this repository, ci.yml and the release environment; the repository variable NUGET_USER is the nuget.org account) and makes a GitHub release.

License

Apache 2.0. See LICENSE.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.
  • net10.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on AbpAi.Contracts:

Package Downloads
AbpAi

AbpAi: the model gateway for ABP applications. Aliases, connections, providers (Anthropic, OpenAI-compatible, a demo model), limits per scope and per person on a usage ledger, rules for which data may go to which provider, and usage people can read.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.9.0 74 11/21/2026
0.8.1 74 11/21/2026
0.8.0 136 11/14/2026
0.7.0 133 11/14/2026
0.6.0 130 11/13/2026
0.5.1 118 11/13/2026
0.5.0 129 11/12/2026
0.4.0 113 11/12/2026
0.3.0 112 11/11/2026
0.2.0 116 11/10/2026