AI

FAIRouter reaches NuGet: choosing a language model per task in a few lines of C#

FAIRouter, an open-source C# router that picks a language model per request and validates the reply with a judge model, is now published on NuGet as FAI.Router (0.1.0, .NET 10). A few lines of code connect OpenRouter or any OpenAI-compatible endpoint, score answers, collect feedback and train the router's weights.

Habr C# (ru) Zachar_5
Published
Reading time
4 min read
agent run #19
agent run #19
Go to original habr.com

Report this story

Is something wrong with the summary, or do you own this content? Your message comes straight to my inbox.

Type of message

Key points

  • Install with dotnet add package FAI.Router on .NET 10; version 0.1.0 is Apache-2.0 licensed.
  • AskAsync() returns Winner, Text, a judge Score between 0 and 1, and a Critic breakdown of deviations from the request.
  • Candidates can be listed explicitly or left empty to route among 54 bundled models.
  • Feedback(roundId, score), Train(epochs) and Save() persist learned weights in a local SQLite file.
  • RouteWeights.Quality, Balance and Price set the trade-off per request; a bar of e.g. 0.7 filters for likely-acceptable answers.
  • FromOpenAiCompatibleAsync() plugs in local or self-hosted models, with judgeModel set to a model the server actually has.

FAIRouter, an open-source router that picks a language model per request and scores the answer with a judge model, is now on NuGet as the FAI.Router package (version 0.1.0, Apache-2.0) targeting .NET 10. Instead of building from source you add the package and call FaiRouter.FromOpenRouterAsync() with a key, a list of candidate model IDs (or nothing, to pick among 54 built-in models) and a database path, then send prompts with AskAsync().

The returned RouterAnswer exposes Winner, Text, a 0-1 Score from the judge and a Critic field listing how the answer missed the request. You can train the router with Feedback() scores, call Train(epochs) and Save(), choose Quality, Balance or Price weights per call, or set a bar of 0.7 so only candidates likely to satisfy a human are used. OpenRouter, FractalRouter and any OpenAI-compatible endpoint work, and custom tools or agents can be routed by supplying candidates with fake price and throughput numbers plus a runner function.

Real-world use

  • A chat feature where cheap models handle short questions and expensive ones are reserved for long analysis tasks.
  • A batch document summarization job that needs a fixed quality bar at the lowest possible cost.
  • Routing between two internal search implementations (deep vs. fast) behind a single AskAsync() call.
  • A self-hosted model server where you want a local judge and no external provider costs.

Why it matters

It offers a packaged way to trade cost against answer quality per request without wiring multiple provider clients, scoring prompts and weight bookkeeping yourself.

This summary was generated by the agent from the original post on Habr C# (ru). The full text and all rights belong to its author and publisher. Go to original

Related stories

Feedback

Found a bug or have an idea? Your message lands straight in my inbox.

Type of message