@antseed/provider-free-model-router
v0.1.0
Published
IRP routing provider for Antseed that ranks the best free models among a buyer's candidates by live Artificial Analysis scores
Readme
@antseed/provider-free-model-router
An irp-suggest routing provider: one of the routing plugins a seller can run, with no special status. A seller runs it to offer buyers a router that sends each request to the best free model among the buyer's candidates. It answers the routing endpoints itself; it has no upstream, needs no API key, and forwards nothing.
GET /v1/routing/modelslists*(it scores any model the buyer sends) plus anyFREE_ROUTER_MODELS, each with a zeromax_pricingso buyers only send free candidates (no limit withFREE_ROUTER_INCLUDE_PAID=true). The buyer builds candidates from its own model catalog, so the router depends on no central model list.POST /v1/routing/rankranks the buyer's free candidates, best model first. Paid candidates are dropped unlessFREE_ROUTER_INCLUDE_PAID=true, which ranks them after the free ones, cheapest first. If nothing is free and paid ranking is off, it answers422 no-scorable-candidate, which is not billed.- Rankings are free by default: the service announces zero token prices and a
completed_requestsprice of0, so buyer and seller both take the free-service path and no payment channel is opened. SetFREE_ROUTER_PRICE_USDto charge per ranking.
Run it
antseed config seller add-provider router --plugin free-model-router
antseed config seller add-service router free-model-router --input 0 --output 0
antseed seller startIRP paths name no service, so a seller offers at most one irp-suggest service; run the router on its own seller node. To limit abuse, set the seller free tier, which applies to free rankings like any other free service:
antseed config seller set freeTier.maxRequestsPerAddress 1000Buyers pick it like any routing service:
curl http://127.0.0.1:8377/_antseed/routing-services
curl -X POST http://127.0.0.1:8377/_antseed/route \
-H 'content-type: application/json' \
-d '{"router":{"service":{"peerId":"<routerPeerId>","provider":"free-model-router","serviceId":"free-model-router"}}}'How it ranks
- Candidates. Only what the buyer sends in
routing.candidatesis ranked; a candidate is free when its input, cached-input and output prices are all0. - Scores. Each model is scored by its live Artificial Analysis Intelligence Index, or Coding Index with
FREE_ROUTER_METRIC=coding, read from the free, keyless modelgrep API. Names are matched by canonical model key; deployment variants such as-fast,-preview,-exl3or a date take their base model's score, but the parameter size is never dropped. - Unscored models are still offered, after every scored model, in the buyer's order.
- Same model, several sellers: the buyer's order is kept, which already reflects trust, recent failures and cooldowns.
- Seller override: models in
FREE_ROUTER_MODELSoutrank every scored model, in the order given.
Scores refresh every 6 hours. A failed refresh keeps the last good scores; if scores were never loaded, free candidates keep the buyer's order.
Use it in code
The plugin wraps the FreeModelRouter class, which is also exported for embedding:
import { FreeModelRouter } from '@antseed/provider-free-model-router';
const router = new FreeModelRouter({ metric: 'coding', preferredModels: ['glm-5.3-flash'] });
const response = await router.handleRequest(request); // IRP GET /v1/routing/models or POST /v1/routing/rankConfiguration
| Key | Default | Description |
|-----|---------|-------------|
| ANTSEED_ALLOWED_SERVICES | free-model-router | Routing service id; exactly one |
| FREE_ROUTER_PRICE_USD | 0 | USD per ranking |
| FREE_ROUTER_METRIC | intelligence | intelligence or coding |
| FREE_ROUTER_MODELS | -- | Comma-separated preferred models, best first |
| FREE_ROUTER_INCLUDE_PAID | false | Also rank paid candidates after free ones |
| FREE_ROUTER_SCORES_URL | https://modelgrep.com/api/v1/models | Model scores; empty ranks by buyer order only |
| FREE_ROUTER_REFRESH_SECONDS | 21600 | Refresh interval |
| ANTSEED_MAX_CONCURRENCY | 50 | Max concurrent rankings |
The router receives each buyer's conversation, like every routing service. It reads only the candidates and never stores or forwards the request.
