langchain-morse
This package connects Morse and LangChain.
Morse is a private, OpenAI-compatible inference API for open-weight models (DeepSeek, GLM, Qwen, Kimi, Gemma, Llama, MiniMax, Mistral and others). Morse keeps no prompt and no response, and providers see Morse as the customer, not you. Some models also run in a trusted execution environment (TEE).
Installation
pip install -U langchain-morse
Get an API key at console.trymorse.ai and set it:
export MORSE_API_KEY="your-api-key"
Chat models
ChatMorse is a LangChain chat model for every chat model on Morse. Model ids are listed at trymorse.ai/inference/models, or as JSON at https://inference.trymorse.ai/v1/models (no key needed).
from langchain_morse import ChatMorse
llm = ChatMorse(model="deepseek/deepseek-v4.1-flash")
llm.invoke("Sing a ballad of LangChain.")
Streaming
for chunk in llm.stream("Write one line about rain."):
print(chunk.text, end="")
Tool calling and structured output
from langchain_core.tools import tool
@tool
def get_weather(city: str) -> str:
"""The weather now in a city."""
return f"It's raining in {city}."
reply = llm.bind_tools([get_weather]).invoke("Is it raining in Lisbon?")
print(reply.tool_calls)
with_structured_output works the same way as with ChatOpenAI. On a model without JSON schema output, pass method="function_calling".
Reasoning
Reasoning models return their thinking in additional_kwargs["reasoning_content"]:
llm = ChatMorse(model="z-ai/glm-5.3", reasoning_effort="high")
response = llm.invoke("What is 3^3?")
print(response.additional_kwargs.get("reasoning_content"))
Morse request options
Send Morse's own parameters in extra_body, for example to keep a request on TEE hardware:
llm = ChatMorse(
model="z-ai/glm-5.3",
extra_body={"provider": {"min_privacy": "tee"}},
)
Agents
from langchain.agents import create_agent
agent = create_agent(llm, tools=[get_weather])
Configuration
| Argument | Environment variable | Default |
|---|---|---|
api_key |
MORSE_API_KEY |
required |
base_url |
MORSE_API_BASE |
https://inference.trymorse.ai/v1 |
model |
deepseek/deepseek-v4.1-flash |
OPENAI_API_KEY is never read, so an OpenAI key is never sent to Morse.
Docs
Development
uv sync --group test
uv run pytest --disable-socket --allow-unix-socket tests/unit_tests
MORSE_API_KEY=... uv run pytest tests/integration_tests
Metadata
Release files for langchain-morse 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| langchain_morse-0.1.0.tar.gz | 7.1 kB | With provenance | Details for langchain_morse-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| langchain_morse-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for langchain_morse-0.1.0-py3-none-any.whl |
Total release size: 13.9 kB
Release files / langchain_morse-0.1.0.tar.gz
| Download URL | langchain_morse-0.1.0.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3af06fa50653bf26589c9b61466c60f18da773c66bb0ba881144ab088eced256
|
|
BLAKE2b-256 checksum How to use checksums |
9cff4d9e7da4d122981691542006abde7c39409d0a4c317cbcff856a4f5f623b
|
| 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 30, 2026.
Transparency logRelease files / langchain_morse-0.1.0-py3-none-any.whl
| Download URL | langchain_morse-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b937338546ccc2860c23b24672566c9e5d9a3747daee408b80a04d85dc785026
|
|
BLAKE2b-256 checksum How to use checksums |
005c2d636f4bf70ae24cf6470526c21551b4f537e7a1c1ab53451ce7be906127
|
| 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 30, 2026.
Transparency logSecurity for langchain-morse 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.
Attestation for langchain_morse-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 30, 2026.
Transparency logA 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.