Model Router Middleware
BipkitModelRouterMiddleware inspects incoming prompts and selects the appropriate System Two LLM tier (gpt-4o-mini vs. frontier reasoning models) before you incur generative token costs.
Installation
Section titled “Installation”pip install "bipkit[langchain]"from bipkit.integrations.langchain import ( BipkitClassifier, BipkitModelRouterMiddleware, ModelChoice,)
# Reads BIPKIT_API_KEY from environment by defaultclassifier = BipkitClassifier(engine="bip-instant")
router = BipkitModelRouterMiddleware( choices={ "fast": ModelChoice( model="openai:gpt-4o-mini", criteria="Direct keyword lookups, simple extractions, routine responses.", ), "powerful": ModelChoice( model="openai:o3", criteria="Complex system architecture, distributed algorithms, high-stakes decisions.", ), }, classifier=classifier,)
selected_model = router.route("Design a distributed consensus mechanism")print(selected_model) # "openai:o3"