Provides the shared TypeScript interfaces and Zod schemas for defining LLM routing configurations, budget tracking, and circuit breaker states. It serves as the foundational type library for the `@reaatech/llm-router` ecosystem, requiring `zod` as a runtime dependency for schema validation.
Status: Pre-1.0 — APIs may change in minor versions. Pin to a specific version in production.
Core TypeScript types, Zod schemas, and input validation for the llm-router ecosystem. This package is the single source of truth for all domain types used throughout the @reaatech/llm-router-* monorepo.
Circuit breaker types — CLOSED | OPEN | HALF_OPEN state machine with config shapes
Zero dependencies beyond zod — lightweight and tree-shakeable
Dual ESM/CJS output — works with import and require
Quick Start
typescript
import { ModelDefinitionSchema, RoutingRequestSchema, RouterConfigSchema, type ModelDefinition, type RoutingRequest,} from "@reaatech/llm-router-core";// Validate a model definition at the boundaryconst model = ModelDefinitionSchema.parse({ id: "gpt-4-turbo", provider: "openai", costPerMillionInput: 10, costPerMillionOutput: 30, maxTokens: 128000, capabilities: ["code", "reasoning"],});// Validate an incoming routing requestconst req = RoutingRequestSchema.parse({ prompt: "Review this code for bugs.", strategy: "cost-optimized", maxTokens: 4096,});
Exports
Domain Types
The core domain objects the entire router operates on.
Export
Description
ModelDefinition
Model config: id, provider, cost per million tokens, max tokens, capabilities, API key env
Every schema export has a matching type export. Use the schema for runtime validation and the type for compile-time checking:
typescript
import { ModelDefinitionSchema, type ModelDefinition } from "@reaatech/llm-router-core";function loadModel(raw: unknown): ModelDefinition { // Parse at the boundary — throws ZodError on invalid data return ModelDefinitionSchema.parse(raw);}