by Isolde R.

Manifest is a smart AI model router that redirects each query to the right model based on complexity and custom rules, cutting AI costs by up to 70%. Supports 300+ models across 16 providers including OpenAI, Anthropic, Google, and local models.
Manifest is a NestJS-based AI model router backend that proxies requests to 300+ models across 16 providers, routing each query to the appropriate model based on complexity scoring, specificity detection, and custom headers. It targets teams and solo developers who want to reduce AI costs by intelligently dispatching to cheaper models when possible while maintaining observability over every token spent.
analytics/ - Controllers and services for querying message history, costs, savings, token usage, and per-agent metricsauth/ - Better Auth integration: session guard, current-user decorator, auth modulecommon/ - Shared constants, DTOs, guards (API key, session), interceptors, middleware, and utility servicesconfig/ - Application configuration factory (appConfig)database/ - TypeORM database module and migration setupentities/ - TypeORM entity definitions (e.g. ApiKey)free-models/ - Module for discovering and exposing free/open model tiersgithub/ - GitHub OAuth integration modulehealth/ - Health-check endpoint modulemodel-discovery/ - Runtime model enumeration across configured providersmodel-prices/ - Price table ingestion and lookup for cost accountingnotifications/ - Budget/limit notification servicesotlp/ - OpenTelemetry ingestion endpoint for trace/metric datapublic-stats/ - Publicly accessible aggregate statistics endpointrouting/ - Core proxy routing logic: selects provider, forwards requests, handles fallbackscoring/ - Standalone complexity and specificity scorer library (importable independently)setup/ - First-run wizard and initial admin account creationsse/ - Server-Sent Events streaming for real-time dashboard updatestelemetry/ - Internal OpenTelemetry SDK bootstrapapp.module.ts - Root NestJS module wiring all feature modulesmain.ts - Application entry point: Helmet CSP, compression, auth middleware, SPA fallbacknpm install @nestjs/common @nestjs/core @nestjs/platform-express @nestjs/cache-manager \
@nestjs/config @nestjs/serve-static @nestjs/throttler @nestjs/typeorm \
@nestjs/terminus cache-manager helmet compression better-auth \
typeorm reflect-metadata rxjs class-validator class-transformer
Spin up an isolated sandbox and run it server-side — no local setup.
Tetrees AI Review of this version
This Express backend / api completed archive review. Structure, dependency manifests, documentation, functional source, and common risk patterns were checked by the Tetrees verification pipeline; runtime phases are stated separately.
Deterministic AVCP artifact review
Pipeline avcp-2026-08-04.1 · SHA-256 faa849878dd0bb64…
This version-scoped review deterministically inspects the submitted archive for structure, dependencies, documentation, functional source, and common malicious or high-risk signals. Build and test phases are reported as passed only after an isolated sandbox audition. It is not a guarantee of perfect security.
Reviewed Aug 4, 2026
Push this product straight into your AI IDE, web builder or cloud IDE.
Connect Tetrees to a compatible AI IDE, list products you own, and request the verified ZIP without exposing seller upload controls.
No reviews yet.
Sign in to join the discussion
Loading discussion…
If you enable OpenTelemetry:
npm install @opentelemetry/sdk-node @opentelemetry/auto-instrumentations-node \
@opentelemetry/exporter-trace-otlp-http
No native build steps are required. This is a pure Node.js backend; no iOS/Android linking needed.
Copy the source/ directory into your project root, e.g. as src/.
Configure tsconfig.json for NestJS decorators:
{
"compilerOptions": {
"module": "CommonJS",
"target": "ES2021",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"strictNullChecks": true,
"esModuleInterop": true,
"outDir": "dist",
"baseUrl": ".",
"paths": {
"@src/*": ["src/*"]
}
}
}
.env):DATABASE_URL=postgresql://user:pass@localhost:5432/manifest
BETTER_AUTH_URL=http://localhost:3001
BETTER_AUTH_SECRET=your-secret-here
PORT=3001
NODE_ENV=development
# Optional
THROTTLE_TTL=60000
THROTTLE_LIMIT=100
FRAME_ANCESTORS=
WINGMAN_PORT=3002
src/main.ts. Start with:npx ts-node -r tsconfig-paths/register src/main.ts
# or via NestJS CLI:
npx nest start
/ dashboard becomes the admin.export async function bootstrap(): Promise<void>
Bootstraps the NestJS application: registers Helmet with a strict Content Security Policy, enables compression, mounts the Better Auth middleware, attaches the global SpaFallbackFilter, and starts the HTTP listener on process.env.PORT (default 3001). Call this once from your process entry point. In production, BETTER_AUTH_URL must start with https:// for HSTS to activate.
export { detectSpecificity } from './specificity-detector';
// signature (from scoring/index.ts re-export):
function detectSpecificity(input: ScorerInput): SpecificityResult
Analyzes a chat message payload and returns a specificity classification. Use this when you need to decide whether a query is concrete enough to route to a smaller, cheaper model. The result includes a tier and confidence score.
export { scanMessages } from './scan-messages';
// usage: scanMessages(messages: ScorerInput['messages']): ScoringResult
Runs the full multi-dimension scoring pipeline over a conversation's message array. Returns a ScoringResult with per-dimension scores, a final Tier, confidence, and a list of ScoringReason entries explaining the decision. Use this outside NestJS (e.g. in a middleware or edge function) when you want scoring without standing up the full server.
// common/filters/spa-fallback.filter.ts
export class SpaFallbackFilter implements ExceptionFilter {
constructor(private readonly betterAuthUrl?: string) {}
catch(exception: HttpException, host: ArgumentsHost): void
}
A NestJS exception filter that intercepts 404 responses for non-API routes and serves the SPA index.html. Register it globally via app.useGlobalFilters(new SpaFallbackFilter(betterAuthUrl)). It correctly passes through /api/ and /v1/ 404s as JSON errors.
You want to score an incoming OpenAI-format chat payload in a plain TypeScript script, without NestJS, to decide which model tier to use.
import { scanMessages } from './src/scoring/scan-messages';
import type { ScorerInput, Tier } from './src/scoring/index';
const input: ScorerInput = {
messages: [
{ role: 'user', content: 'Explain the difference between TCP and UDP in one sentence.' },
],
};
const result = scanMessages(input.messages);
console.log('Tier:', result.tier); // e.g. "low"
console.log('Confidence:', result.confidence);
console.log('Reasons:', result.reasons);
function pickModel(tier: Tier): string {
if (tier === 'high') return 'gpt-4o';
if (tier === 'medium') return 'gpt-4o-mini';
return 'gemini-2.0-flash';
}
console.log('Route to:', pickModel(result.tier));
You want to know whether the latest user turn is specific enough to route to a specialist model.
import { detectSpecificity } from './src/scoring/index';
import type { ScorerInput } from './src/scoring/index';
const input: ScorerInput = {
messages: [
{ role: 'user', content: 'I need a Python function that parses ISO 8601 dates with timezone offsets and returns a UTC timestamp as an integer.' },
{ role: 'assistant', content: 'Sure, here is a draft...' },
{ role: 'user', content: 'Add error handling for malformed strings and raise a ValueError with the offending substring.' },
],
};
const result = detectSpecificity(input);
console.log('Specificity tier:', result.tier);
console.log('Score:', result.score);
// Use result.tier === 'specific' to route to a code-specialist model.
Embed the Manifest backend inside a monorepo that already manages its own process lifecycle.
import { bootstrap } from './src/main';
async function start() {
// Set env vars before calling bootstrap
process.env['PORT'] = '4000';
process.env['BETTER_AUTH_URL'] = 'http://localhost:4000';
process.env['NODE_ENV'] = 'development';
await bootstrap();
console.log('Manifest router listening on port 4000');
}
start().catch((err) => {
console.error('Failed to start Manifest:', err);
process.exit(1);
});
main.ts - Entry point; configures Helmet CSP (with dev-only Wingman iframe allowance), compression, Better Auth middleware, global validation pipe, SPA fallback filter, and starts the listener.app.module.ts - Root @Module that imports every feature module, registers global cache, throttler, TypeORM, and serves static frontend assets when a build is present.analytics/ - REST controllers exposing /api/analytics/* endpoints for costs, savings, tokens, messages, and per-agent breakdowns; backed by TypeORM query services.auth/ - Mounts Better Auth at /api/auth/*; exports SessionGuard and @CurrentUser() decorator for controller-level auth enforcement.common/ - Cross-cutting: ApiKeyGuard, cache interceptors, error codes, IngestEventBusService, ManifestRuntimeService, and shared DTOs.config/ - appConfig factory reads env vars and exposes typed config to the DI container via ConfigModule.database/ - DatabaseModule bootstraps TypeORM with the configured DATABASE_URL and runs migrations on startup.entities/ - TypeORM entity classes (ApiKey, etc.) shared across modules.free-models/ - Discovers and caches model listings that are available without billing.github/ - GitHub OAuth callback and repository-linking flows.health/ - GET /api/health liveness/readiness probe powered by @nestjs/terminus.model-discovery/ - Polls configured providers and caches the union model list for the routing layer.model-prices/ - Ingests per-token price tables and exposes lookups for cost accounting in analytics.notifications/ - Watches spend against configured budgets and dispatches alerts.otlp/ - Accepts OTLP/HTTP trace and metric payloads and forwards them to the telemetry pipeline.public-stats/ - Unauthenticated endpoint exposing aggregate routing statistics for status pages.routing/ - Core proxy: selects provider/model based on scorer output and custom headers, streams the response, handles retries and fallback chains.scoring/ - Pure-TS library: keyword trie, structural/contextual dimension scorers, momentum adjustment, sigmoid confidence, specificity detector. No NestJS dependency.setup/ - First-run wizard: creates the SQLite/Postgres schema and seeds the first admin user.sse/ - Pushes real-time routing events to connected dashboard clients via text/event-stream.telemetry/ - Initializes the OpenTelemetry Node SDK with configured exporters before the NestJS app boots.emitDecoratorMetadata not enabled: NestJS DI silently fails to inject dependencies. Fix: ensure "emitDecoratorMetadata": true in tsconfig.json and import 'reflect-metadata' at the top of main.ts.BETTER_AUTH_URL missing or wrong origin: Auth callbacks redirect to the wrong host and sessions are rejected. Fix: set BETTER_AUTH_URL to the exact public-facing origin including scheme and port.BETTER_AUTH_URL starts with https://, causing browsers to rewrite asset URLs. Fix: use an http:// URL for local/LAN installs; terminate TLS at a reverse proxy.index.html: SPA routing breaks after deploys because the browser serves a stale entry point. Fix: index.html is served with Cache-Control: no-cache by ServeStaticModule; do not override this header at your proxy.THROTTLE_LIMIT and THROTTLE_TTL env vars before startup.scanMessages and detectSpecificity are pure functions with no NestJS decorators; importing them into a provider works fine, but do not attempt to inject them via @Injectable() wrappers you write yourself, as they have no DI tokens.I have dropped the Manifest AI Router backend source into `src/` in my project.
The integration guide is in `USAGE.md`. The upstream package is `manifest` (backend domain).
Please help me integrate this source into my existing project step by step:
1. Read `USAGE.md` fully before making any changes.
2. Check my existing `tsconfig.json` and update it for NestJS decorator support as described.
3. Wire `src/main.ts` `bootstrap()` into my process entry point, preserving any existing
startup logic I have.
4. Add the required environment variables from `USAGE.md` to my `.env` file, using
placeholder values I can fill in.
5. If I already have a database module, show me how to replace it with `src/database/`
or adapt the TypeORM config.
6. Show me how to call `scanMessages` and `detectSpecificity` from `src/scoring/`
in my existing request middleware to add model-routing decisions without touching
the NestJS app layer.
7. Point out any conflicts with my existing dependencies and suggest resolutions.
Work through each step one at a time and ask me to confirm before proceeding to the next.
See source/LICENSE if present. Based on the README, the project is licensed under the terms shown in the Manifest GitHub repository (license badge visible in README). Review the LICENSE file in the upstream repository before commercial use. Upstream project: github.com/mnfst/manifest.
This product’s unique contribution is clean room implementation of valuable code block into AVCP compatible standard.
The full install guide and integration prompts unlock after purchase.
SaaS, AI & Subscription Products
Free