Skip to main content

langchain-levanto

Levanto for LangChain: Sage decisions and Levanto's LLMs.

pip install langchain-levanto

It reads your key from LEVANTO_API_KEY.

Decisions

LevantoDecisionModel is a LangChain decision model. It answers yes/no (Noul), Choice and Score questions about text, JSON or chat messages, with full probabilities.

from langchain_core.decisions import Choice, Noul, Score
from langchain_levanto import LevantoDecisionModel

sage = LevantoDecisionModel()
response = sage.invoke({
    "state": "I was charged twice. Please refund the duplicate today.",
    "questions": {
        "refund": Noul(instructions="Is the customer asking for money back?"),
        "team": Choice(
            instructions="Which team should handle this?",
            criteria={"billing": "Charges and refunds", "technical": "Bugs and outages"},
        ),
        "urgency": Score(instructions="How urgent is it?", criteria=["Can wait", "This week", "Today"]),
    },
})

response.nouls["refund"].noul      # 0.996
response.choices["team"].choice    # "billing"
response.scores["urgency"].score   # 1.99, from 0 to 2

Options: reasoning ("off", "auto", "on"), grounding, timeout (15 s by default, 60 s with reasoning), max_retries. Box questions and images aren't supported; for images, call POST /decide.

Guard and route agents

LangChain's agent middleware takes any decision model.

from langchain.agents import create_agent
from langchain.agents.middleware import AutoModeMiddleware

# Sage blocks risky tool calls the user didn't ask for.
agent = create_agent(
    model,
    tools=[read_file, delete_file],
    middleware=[AutoModeMiddleware(tools=[delete_file], classifier=LevantoDecisionModel())],
)

ModelRouterMiddleware(choices=..., instructions=..., classifier=LevantoDecisionModel()) picks a model per run.

LLMs

from langchain_levanto import ChatLevanto

llm = ChatLevanto(target="economy")   # model="auto" lets the router pick
reply = llm.invoke("Summarize this ticket in one sentence: ...")
reply.response_metadata["model_name"]  # the model that answered

ChatLevanto is ChatOpenAI pointed at https://api.levanto.ai/v1: streaming, tools and with_structured_output work as usual. It never reads OPENAI_API_KEY.

Development

uv venv && uv pip install -e . --group test
pytest tests/unit_tests
LEVANTO_API_KEY=... pytest -m live tests/integration_tests

Docs: https://docs.levanto.ai/integrations/langchain

Metadata

Release files for langchain-levanto 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-levanto 0.1.0
File Size Uploaded Provenance Actions
langchain_levanto-0.1.0.tar.gz 11.3 kB With provenance Details for langchain_levanto-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-levanto 0.1.0
File Interpreter ABI Platform Actions
langchain_levanto-0.1.0-py3-none-any.whl Python 3 none any Details for langchain_levanto-0.1.0-py3-none-any.whl

Total release size: 21.1 kB

Release files / langchain_levanto-0.1.0.tar.gz

Download URL langchain_levanto-0.1.0.tar.gz
Size 11.3 kB
Tags Source
SHA-256 checksum
How to use checksums
124a761271cfb3afa71954710e4d12ad281cb8fa9c3551d20c2fc96017c5ed55
BLAKE2b-256 checksum
How to use checksums
3192bf49630fc756a1b2adbc58b28620fead1c290a20f31a6cb25e18c7789735
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / langchain_levanto-0.1.0-py3-none-any.whl

Download URL langchain_levanto-0.1.0-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a89906a776459b7e0015277c089de35c602d6bf76910ea1aeb8e1b50e7aef4b4
BLAKE2b-256 checksum
How to use checksums
893e748ced2a2139815fb63cf4d9d42f6ee7224d8692afb87eb6edc9d5f59af8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Security for langchain-levanto 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for langchain_levanto-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page