Registry / llm-agents / langchain-deepseek

langchain-deepseek

JSON →
library1.1.0pypypi✓ verified 22d ago

langchain-deepseek is an official LangChain partner package that integrates DeepSeek's large language models (LLMs) and embeddings into the LangChain ecosystem. It allows developers to easily use DeepSeek models for chat completions and text embeddings within their LangChain applications. The current version is 1.0.1, and it follows the rapid development and release cadence typical of LangChain's partner libraries, often aligning with `langchain-core` updates.

pip install langchain-deepseek
INSTALL
IMPORT
SIG · LANGCHAIN-DEEPSEEK
L
langchain-deepseek
llm-agentspythonv1.1.0
Install
10.0s avg
Import
5042ms
Disk
102MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 5.172s · 99.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 10.0s · import 4.912s · 108MB
102MB installed
● package 102MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ChatDeepSeek
from langchain_deepseek import ChatDeepSeek
DeepSeekEmbeddings
from langchain_deepseek import DeepSeekEmbeddings

This quickstart demonstrates how to initialize the `ChatDeepSeek` model and use it to invoke a simple chat completion. It assumes the `DEEPSEEK_API_KEY` is set as an environment variable, which is the recommended secure practice. The model processes a list of `HumanMessage` objects and returns a response.

import os from langchain_deepseek import ChatDeepSeek from langchain_core.messages import HumanMessage # Ensure your DeepSeek API key is set as an environment variable # or passed directly to the ChatDeepSeek constructor. # os.environ["DEEPSEEK_API_KEY"] = "your-deepseek-api-key" deepseek_api_key = os.environ.get("DEEPSEEK_API_KEY") if not deepseek_api_key: raise ValueError("DEEPSEEK_API_KEY environment variable not set.") chat_model = ChatDeepSeek(deepseek_api_key=deepseek_api_key) messages = [ HumanMessage(content="Tell me a short story about a brave knight.") ] response = chat_model.invoke(messages) print(response.content)
Debug
Known issues
gotchaThe DeepSeek API key is required for authentication. It can be provided either as an environment variable `DEEPSEEK_API_KEY` or directly as a `deepseek_api_key` argument to the `ChatDeepSeek` or `DeepSeekEmbeddings` constructors. The argument takes precedence.
fix
Set `os.environ["DEEPSEEK_API_KEY"] = "your_key"` or pass `deepseek_api_key="your_key"` to the constructor.
affects: All versions
gotchaThis library has strict Python version requirements: `>=3.10.0` and `<4.0.0`. Using incompatible Python versions will lead to installation or runtime errors.
fix
Ensure your development environment uses a Python version within the specified range, e.g., Python 3.10, 3.11, or 3.12.
affects: All versions
gotcha`langchain-deepseek` depends on `langchain-core` with specific version constraints (e.g., `langchain-core>=0.1.0,<0.2.0`). Mismatches between `langchain-deepseek`'s declared `langchain-core` dependency and other `langchain` packages in your environment can cause runtime issues or unexpected behavior. Use `pip install` with care in mixed LangChain environments.
fix
Always use a dedicated virtual environment. If issues arise, consider pinning `langchain-core` to the version specified in `langchain-deepseek`'s `install_requires`.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'langchain_deepseek'
The 'langchain-deepseek' package is not installed in your current Python environment or the environment is not correctly activated.
fix
Ensure the package is installed using pip: `pip install -U langchain-deepseek`
AuthenticationError: Invalid credentials
The DeepSeek API key is missing, incorrect, or not properly configured as an environment variable or passed during model instantiation.
fix
Set the `DEEPSEEK_API_KEY` environment variable (recommended) or pass it directly to the `ChatDeepSeek` or `DeepSeekEmbeddings` constructor. Example: `os.environ["DEEPSEEK_API_KEY"] = "YOUR_DEEPSEEK_API_KEY"` or `llm = ChatDeepSeek(model="deepseek-chat", deepseek_api_key="YOUR_DEEPSEEK_API_KEY")`.
AttributeError: items
This specific error often arises in `langchain_core.runnables.config.py` when a Pydantic `ConfigDict` object is passed where `langchain_core` expects a standard dictionary (to call `.items()`). This can happen when using custom DeepSeek models with LangChain's configuration handling.
fix
Ensure that configuration objects passed to LangChain methods are explicitly converted to a dictionary, or use workarounds like the one found in the GitHub issue #4676 of `browser-use` by ensuring the `config` argument is a `dict`.
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
The DeepSeek API returned a response that was not valid JSON, which LangChain's internal parsers failed to decode. This can be due to transient API issues, unexpected model outputs, or incorrect model parameters.
fix
Implement retry logic with exponential backoff. If the issue persists, verify model parameters (especially `response_format` if used), check DeepSeek's API status, or report the issue to DeepSeek/LangChain if it appears to be an API-side problem with valid inputs.
Upgrade
Version history
1.1.0latest on PyPI · released Jun 3, 2026
Audit
Dependencies
langchain-corerequiredProvides the core abstractions and interfaces for all LangChain integrations. Specific version constraints (e.g., `>=0.1.0,<0.2.0`) are defined by `langchain-deepseek`.
Agent activity
21 hits · last 30 days
node
18
OpenAI (training)
1
Resources
langchain-deepseek — pip install langchain-deepseek · libregistry