langchain-typesafe
langchain-typesafe is for Python teams already on LangChain who want TypeSafe Jev inside the agent graph. TypeSafeClassifier batches Choice, Score, and Noul in one call, and the experimental extra adds middleware that picks a model tier and gates risky tools.
Overview
langchain-typesafe (PyPI langchain-typesafe v0.0.1a3, MIT, maintained by LangChain) lives in the langchain-ai/langchain monorepo. TypeSafeClassifier is a Runnable: pass state as text, JSON, or LangChain messages plus a questions map built from Choice, Score, and Noul helpers; invoke returns typed answers per question in one System One request. Set TYPESAFE_API_KEY. The experimental extra adds ModelRouterMiddleware (once-per-run model tier Choice from the latest human message) and AutoModeMiddleware (Noul gate before configured tools). Provider errors inherit LangChain model-error hierarchy. LangChain's Building a Harness with Jev post and docs.langchain.com integration pages document routing and Auto Mode patterns; this directory page covers the package surface, not hosted Jev pricing.
Problem: LangGraph and LangChain agents still burn a full chat model call whenever they need a label, a route, or a pre-tool risk check, even when the answer set is finite.
Built for: Python teams already on LangChain who want official TypeSafeClassifier runnables, parallel Choice, Score, and Noul, and optional middleware inside create_agent flows.
First indexed on Jev Directory: 2026-09-27
Creator and team
- Name
- LangChain
- Handle
- @langchain-ai
How Jev is used
- Role in the product flow
- Parallel System One questions inside LangChain Runnable pipelines and optional agent middleware
- Primitives
- ChoiceScoreNoul
- State in
- ClassifierRequest state field: plain string, structured dict, or BaseMessage lists converted to role/content objects per PyPI docs.
- Decision out
- Per-question ChoiceAnswer, ScoreAnswer, or NoulAnswer objects with probabilities; middleware stores full ChoiceAnswer in agent state for traces.
- uv add langchain-typesafe and export TYPESAFE_API_KEY
- Build questions map and call TypeSafeClassifier.invoke or ainvoke
- Optional: uv add langchain-typesafe[experimental] for middleware
- Attach ModelRouterMiddleware or AutoModeMiddleware when using create_agent
- Branch in Python on thresholds instead of parsing model prose
This is the LangChain-native SDK lane next to typesafe-ai-typesafe-sdk-python for raw HTTP and vercel-ai-sdk-provider for Vercel AI SDK apps. Use middleware when your harness already calls create_agent; call TypeSafeClassifier inside LangGraph nodes when you own the state machine. nidhi-singh02-agent-router and gargpratyush-jev-router solve multi-CLI model tier picks in terminals; langchain-typesafe stays in your Python service. Pair with antoniocoppe-jev-harness when teammates need vocabulary for gate design, and the /guides/jev-with-ai-agents/langchain-langgraph page for install snippets.
Sourced performance claims
- PyPI lists langchain-typesafe 0.0.1a3 with LangChain org ownership and MIT license.Source: pypi.org/project/langchain-typesafe
- LangChain blog post Building a Harness with Jev documents ModelRouterMiddleware and AutoModeMiddleware examples.Source: langchain.com/blog/building-a-harness-with-jev
Features and stack
Features
- TypeSafeClassifier Runnable with parallel question batching
- Choice, Score, and Noul helper constructors
- Experimental ModelRouterMiddleware for cost-aware model Choice
- Experimental AutoModeMiddleware for tool-risk Noul gates
- Message-as-state conversion for chat-shaped agent loops
Stack
- Python 3.10+
- LangChain
- TypeSafe System One API
- Optional LangGraph nodes
Pricing: MIT package; TypeSafe bills per System One request unless you point clients at a self-hosted decision server.
Links
FAQ
- Where is the source code?
- The integration ships inside github.com/langchain-ai/langchain; PyPI package langchain-typesafe is the install surface.
- Do I need the experimental extra?
- Only for ModelRouterMiddleware and AutoModeMiddleware. TypeSafeClassifier works from the base install documented on PyPI.
- Which environment variable?
- PyPI and LangChain docs use TYPESAFE_API_KEY for the TypeSafe client backing the classifier.
- Is this a text generator?
- No. TypeSafeClassifier returns typed probabilities for questions you define; it does not draft user-facing prose.
Related learn guides
Original Jev guidance that pairs with this product pattern.
- Jev use cases
The patterns builders actually search for: moderation, routing, triage, RAG verify, and agent gates.
Related products
Hand-picked neighbors with rich profiles or overlapping tags.