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-deepseekVerified import paths — ran on the pinned version, not inferred.
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.
Set `os.environ["DEEPSEEK_API_KEY"] = "your_key"` or pass `deepseek_api_key="your_key"` to the constructor.
Ensure your development environment uses a Python version within the specified range, e.g., Python 3.10, 3.11, or 3.12.
Always use a dedicated virtual environment. If issues arise, consider pinning `langchain-core` to the version specified in `langchain-deepseek`'s `install_requires`.
Ensure the package is installed using pip: `pip install -U langchain-deepseek`
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")`.
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`.
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.