{"_id":"@577-industries/model-router","name":"@577-industries/model-router","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@577-industries/model-router","version":"1.0.0","description":"Multi-provider AI model router with 6 strategies, sovereign profile, and composite scoring across 9+ providers","type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"engines":{"node":">=18"},"scripts":{"build":"tsup src/index.ts --format esm,cjs --dts","test":"vitest run","test:watch":"vitest","lint":"tsc --noEmit"},"keywords":["model-router","ai","llm","routing","multi-provider","cost-optimization","sovereign","open-source"],"author":{"name":"577 Industries"},"license":"Apache-2.0","repository":{"type":"git","url":"git+https://github.com/577-industries/model-router.git"},"homepage":"https://www.577industries.com/forge","devDependencies":{"tsup":"^8.4.0","typescript":"^5.7.0","vitest":"^3.0.0"},"_id":"@577-industries/model-router@1.0.0","gitHead":"ec32879b9982915242e46c24501865cab8932774","bugs":{"url":"https://github.com/577-industries/model-router/issues"},"_nodeVersion":"22.22.0","_npmVersion":"10.9.4","dist":{"integrity":"sha512-vmLZ7SZVTYTZEFWJ1yj5KCkFRZM0vUaZzlEiycxlRq/KoD9e/OVcOu+B1uiHYa4yGEEg3NwMKTgymky9Shd7Zw==","shasum":"e8bbe1dcd4297bb119cd651a6b53119f44ad762a","tarball":"https://registry.npmjs.org/@577-industries/model-router/-/model-router-1.0.0.tgz","fileCount":7,"unpackedSize":54224,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIE3EIQtyEoC+a9hYcK3xBMX1u7fvWrpjW5phZDZx+gXQAiEA1+/s9AoDjowdHXcVqZSwVwSDNcWU+OD7u5rcOacaa3g="}]},"_npmUser":{"name":"577industries","email":"t.waweru@577industries.com"},"directories":{},"maintainers":[{"name":"577industries","email":"t.waweru@577industries.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/model-router_1.0.0_1773252955672_0.6646967407841704"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-11T18:15:55.575Z","1.0.0":"2026-03-11T18:15:55.834Z","modified":"2026-03-11T18:15:56.066Z"},"maintainers":[{"name":"577industries","email":"t.waweru@577industries.com"}],"description":"Multi-provider AI model router with 6 strategies, sovereign profile, and composite scoring across 9+ providers","homepage":"https://www.577industries.com/forge","keywords":["model-router","ai","llm","routing","multi-provider","cost-optimization","sovereign","open-source"],"repository":{"type":"git","url":"git+https://github.com/577-industries/model-router.git"},"author":{"name":"577 Industries"},"bugs":{"url":"https://github.com/577-industries/model-router/issues"},"license":"Apache-2.0","readme":"# @577-industries/model-router\n\n[![npm version](https://img.shields.io/npm/v/@577-industries/model-router)](https://www.npmjs.com/package/@577-industries/model-router)\n[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)\n\nMulti-provider AI model router with 6 strategies, sovereign profile filtering, and composite scoring across 9+ providers. Zero runtime dependencies.\n\n**Patent** \"Adaptive Model Routing\" (Feb 2026)\n\n## What is this?\n\nA standalone TypeScript library that routes AI requests to the optimal model based on cost, capability, speed, or a composite score. Supports 14 models across 9 providers out of the box, with full support for bring-your-own registry.\n\n## How it works\n\n```\n  Strategy       Optimizes for\n  -------------- ---------------------------------------------------\n  cost           Lowest input cost per 1M tokens\n  capability     Most capabilities (chat, tools, vision, etc.)\n  speed          Fastest latency (fast > medium > slow)\n  balanced       40% cost + 35% capability + 25% speed\n  efficiency     Capability-to-cost ratio + open-source bonus (1.15x)\n  custom         Category-to-model rules, falls back to balanced\n```\n\n## Quick start\n\n```bash\nnpm install @577-industries/model-router\n```\n\n```typescript\nimport { createRouter } from \"@577-industries/model-router\";\n\n// Default: balanced strategy, all 14 models\nconst router = createRouter();\nconst result = router.route();\nconsole.log(result.model.displayName); // e.g. \"Gemini 2.0 Flash\"\nconsole.log(result.score);              // composite score\nconsole.log(result.isSlm);              // true if SLM\n\n// Compare strategies\nconst cheapest = router.route({ strategy: \"cost\" });\nconst fastest = router.route({ strategy: \"speed\" });\nconst mostCapable = router.route({ strategy: \"capability\" });\n\n// Sovereign mode: open-source only\nconst sovereign = router.route({ sovereignOnly: true });\n\n// Cost ceiling\nconst budget = router.route({ maxCostPer1MInput: 1.0 });\n\n// Require specific capabilities\nconst visionModel = router.route({ capabilities: [\"vision\", \"tools\"] });\n\n// Cost estimation (cents)\nconst cost = router.estimateCost(\"gpt-4o\", 100_000, 50_000);\n```\n\n## API reference\n\n### `createRouter(config?)`\n\nFactory function. Returns a `ModelRouter` instance.\n\n| Config option           | Type                 | Default            | Description                        |\n|-------------------------|----------------------|---------------------|------------------------------------|\n| `registry`              | `ModelEntry[]`       | `DEFAUE�_REGISTRY` | Custom model registry              |\n| `strategy`              | `RoutingStrategy`    | `\"balanced\"`        | Default routing strategy           |\n| `maxCostPer1MInput`     | `number`             | `undefined`         | Cost ceiling filter                |\n| `requiredCapabilities`  | `ModelCapability[]` | `undefined`         | Required model capabilities       |\n| `preferredProvider`     | `ModelProvider`     | `undefined`         | Preferred provider (tiebreaker)   |\n| `customRules`           | `CustomRoutingRule[]`| `undefined`         | Category-to-model mapping rules   |\n\n### `router.route(request?)`\n\nRoute a request to the optimal model. Returns `RouteResult`.\n\n| Request option          | Type                 | Description                        |\n|-------------------------|----------------------|-------------------------------------|\n| `capabilities`          | `ModelCapability[]` | Required capabilities for this request |\n| `category`              | `string`             | Task category (for custom rules)   |\n| `strategy`              | `RoutingStrategy`   | Override strategy per-request      |\n| `maxCostPer1MInput`     | `number`             | Override cost ceiling per-request |\n| `sovereignOnly`         | `boolean`            | Filter to open-source models only  |\n\n### Other methods\n\n| Method                                             | Returns                 |\n|----------------------------------------------------|-------------------------|\n| `estimateCost(modelId, inputTokens, outputTokens)`| `number` (cents)        |\n| `getRegistry()`                                    | `ModelEntry[]`          |\n| `getModelById(id)`                                 | `ModelEntry \\| undefined`|\n| `getModelsByProvider(provider)`                   | `ModelEntry[]`          |\n| `getModelsWithCapabilities(caps)`                 | `ModelEntry[]`          |\n\n### Exports\n\n| Export                | Type       | Description                                      |\n|-----------------------|------------|--------------------------------------------------|\n| `createRouter`        | function   | Factory function - creates a ModelRouter       |\n| `ModelRouter`         | class      | The router class                                |\n| `DEFAULT_REGISTRY`    | const      | Built-in registry of 14 models                 |\n| `estimateCost`        | function   | Standalone cost estimation                      |\n| `isSlmModel`          | function   | SLM classification                              |\n| `selectCheapest`      | function   | Cost strategy implementation                    |\n| `selectMostCapable`   | function   | Capability strategy implementation             |\n| `selectFastest`       | function   | Speed strategy implementation                   |\n| `selectBalanced`      | function   | Balanced strategy implementation               |\n| `selectMostEfficient` | function   | Efficiency strategy implementation             |\n| `applyStrategy`       | function   | Dispatch to any strategy by name               |\n\n## Model registry\n\n14 models across 9 providers, included by default:\n\n| Model                  | Provider   | Input $/1M | Output $/1M | Latency | Capabilities                  | Open Source |\n|------------------------|------------|------------|--------------|----------|-------------------------------|-------------|\n| Claude Sonnet 4        | Anthropic  | $3.00      | $15.00       | medium  | chat, tools, vision, analysis|             |\n| Claude Haiku 4         | Anthropic  | $0.80      | $4.00        | fast    | chat, tools                   |             |\n| Claude Opus 4          | Anthropic  | $15.00     | $75.00       | slow    | chat, tools, vision, analysis, code |    |\n| GPT-4o                 | OpenAI     | $2.50      | $10.00       | medium  | chat, tools, vision, code    |             |\n| GPT-4o Mini            | OpenAI     | $0.15      | $0.60        | fast    | chat, tools                   |             |\n| Gemini 2.0 Flash       | Google     | $0.10      | $0.40        | fast    | chat, tools, vision          |             |\n| Gemini 2.5 Pro         | Google     | $1.25      | $10.00       | medium  | chat, tools, vision, analysis|             |\n| Llama 3.3 70B          | Groq       | $0.59      | $0.79        | fast    | chat, tools                   | Yes         |\n| DeepSeek V3            | DeepSeek   | $0.27      | $1.10        | fast    | chat, tools, code            | Yes         |\n| Mistral Large          | Mistral    | $2.00      | $6.00        | medium  | chat, tools, code            | Yes         |\n| Mistral Small          | Mistral    | $0.10      | $0.30        | fast    | chat, tools, edge            | Yes         |\n| Llama 3.1 8B           | Groq       | $0.05      | $0.08        | fast    | chat, tools, edge            | Yes         |\n| Llama 3.1 8B (Together)| Together   | $0.18      | $0.18        | fast    | chat, tools, edge            | Yes         |\n| Llama 3.1 8B (Fireworks)| Fireworks | $0.20      | $0.20        | fast    | chat, tools, edge            | Yes         |\n\n## Architecture\n\nThis library implements the routing algorithms described in the \"Adaptive Model Routing\" patent (Feb 2026).\n\nKey design decisions:\n- Zero runtime dependencies\n- No API keys, no provider SDK factories, no database\n- Pure routing logic: give it models, get back the best one\n- Bring-your-own registry supported\n- Dual ESM/CJS build with full TypeScript declarations\n\n---\n\nExtracted from [FORGE OS](https://www.577industries.com/forge) by [577 Industries](https://www.577industries.com).\n","readmeFilename":"README.md","_rev":"1-a09f9c1b9acd20bc9b90fef25c9d7381"}