diff --git a/docs/core_docs/docs/integrations/chat/deepseek.ipynb b/docs/core_docs/docs/integrations/chat/deepseek.ipynb
new file mode 100644
index 000000000000..3b3bb839e8dc
--- /dev/null
+++ b/docs/core_docs/docs/integrations/chat/deepseek.ipynb
@@ -0,0 +1,312 @@
+{
+ "cells": [
+ {
+ "cell_type": "raw",
+ "id": "afaf8039",
+ "metadata": {
+ "vscode": {
+ "languageId": "raw"
+ }
+ },
+ "source": [
+ "---\n",
+ "sidebar_label: DeepSeek\n",
+ "---"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "e49f1e0d",
+ "metadata": {},
+ "source": [
+ "# ChatDeepSeek\n",
+ "\n",
+ "This will help you getting started with DeepSeek [chat models](/docs/concepts/#chat-models). For detailed documentation of all `ChatDeepSeek` features and configurations head to the [API reference](https://api.js.langchain.com/classes/_langchain_deepseek.ChatDeepSeek.html).\n",
+ "\n",
+ "## Overview\n",
+ "### Integration details\n",
+ "\n",
+ "| Class | Package | Local | Serializable | [PY support](https://python.langchain.com/docs/integrations/chat/deepseek) | Package downloads | Package latest |\n",
+ "| :--- | :--- | :---: | :---: | :---: | :---: | :---: |\n",
+ "| [`ChatDeepSeek`](https://api.js.langchain.com/classes/_langchain_deepseek.ChatDeepSeek.html) | [`@langchain/deepseek`](https://npmjs.com/@langchain/deepseek) | ❌ (see [Ollama](/docs/integrations/chat/ollama)) | beta | ✅ | ![NPM - Downloads](https://img.shields.io/npm/dm/@langchain/deepseek?style=flat-square&label=%20&) | ![NPM - Version](https://img.shields.io/npm/v/@langchain/deepseek?style=flat-square&label=%20&) |\n",
+ "\n",
+ "### Model features\n",
+ "\n",
+ "See the links in the table headers below for guides on how to use specific features.\n",
+ "\n",
+ "| [Tool calling](/docs/how_to/tool_calling) | [Structured output](/docs/how_to/structured_output/) | JSON mode | [Image input](/docs/how_to/multimodal_inputs/) | Audio input | Video input | [Token-level streaming](/docs/how_to/chat_streaming/) | [Token usage](/docs/how_to/chat_token_usage_tracking/) | [Logprobs](/docs/how_to/logprobs/) |\n",
+ "| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |\n",
+ "| ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ | \n",
+ "\n",
+ "Note that as of 1/27/25, tool calling and structured output are not currently supported for `deepseek-reasoner`.\n",
+ "\n",
+ "## Setup\n",
+ "\n",
+ "To access DeepSeek models you'll need to create a DeepSeek account, get an API key, and install the `@langchain/deepseek` integration package.\n",
+ "\n",
+ "You can also access the DeepSeek API through providers like [Together AI](/docs/integrations/chat/togetherai) or [Ollama](/docs/integrations/chat/ollama).\n",
+ "\n",
+ "### Credentials\n",
+ "\n",
+ "Head to https://deepseek.com/ to sign up to DeepSeek and generate an API key. Once you've done this set the `DEEPSEEK_API_KEY` environment variable:\n",
+ "\n",
+ "```bash\n",
+ "export DEEPSEEK_API_KEY=\"your-api-key\"\n",
+ "```\n",
+ "\n",
+ "If you want to get automated tracing of your model calls you can also set your [LangSmith](https://docs.smith.langchain.com/) API key by uncommenting below:\n",
+ "\n",
+ "```bash\n",
+ "# export LANGSMITH_TRACING=\"true\"\n",
+ "# export LANGSMITH_API_KEY=\"your-api-key\"\n",
+ "```\n",
+ "\n",
+ "### Installation\n",
+ "\n",
+ "The LangChain ChatDeepSeek integration lives in the `@langchain/deepseek` package:\n",
+ "\n",
+ "```{=mdx}\n",
+ "import IntegrationInstallTooltip from \"@mdx_components/integration_install_tooltip.mdx\";\n",
+ "import Npm2Yarn from \"@theme/Npm2Yarn\";\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ " @langchain/deepseek @langchain/core\n",
+ "\n",
+ "\n",
+ "```"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "a38cde65-254d-4219-a441-068766c0d4b5",
+ "metadata": {},
+ "source": [
+ "## Instantiation\n",
+ "\n",
+ "Now we can instantiate our model object and generate chat completions:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "id": "cb09c344-1836-4e0c-acf8-11d13ac1dbae",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import { ChatDeepSeek } from \"@langchain/deepseek\";\n",
+ "\n",
+ "const llm = new ChatDeepSeek({\n",
+ " model: \"deepseek-reasoner\",\n",
+ " temperature: 0,\n",
+ " // other params...\n",
+ "})"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "2b4f3e15",
+ "metadata": {},
+ "source": [
+ ""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "id": "62e0dbc3",
+ "metadata": {
+ "tags": []
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "AIMessage {\n",
+ " \"id\": \"e2874482-68a7-4552-8154-b6a245bab429\",\n",
+ " \"content\": \"J'adore la programmation.\",\n",
+ " \"additional_kwargs\": {,\n",
+ " \"reasoning_content\": \"...\",\n",
+ " },\n",
+ " \"response_metadata\": {\n",
+ " \"tokenUsage\": {\n",
+ " \"promptTokens\": 23,\n",
+ " \"completionTokens\": 7,\n",
+ " \"totalTokens\": 30\n",
+ " },\n",
+ " \"finish_reason\": \"stop\",\n",
+ " \"model_name\": \"deepseek-reasoner\",\n",
+ " \"usage\": {\n",
+ " \"prompt_tokens\": 23,\n",
+ " \"completion_tokens\": 7,\n",
+ " \"total_tokens\": 30,\n",
+ " \"prompt_tokens_details\": {\n",
+ " \"cached_tokens\": 0\n",
+ " },\n",
+ " \"prompt_cache_hit_tokens\": 0,\n",
+ " \"prompt_cache_miss_tokens\": 23\n",
+ " },\n",
+ " \"system_fingerprint\": \"fp_3a5770e1b4\"\n",
+ " },\n",
+ " \"tool_calls\": [],\n",
+ " \"invalid_tool_calls\": [],\n",
+ " \"usage_metadata\": {\n",
+ " \"output_tokens\": 7,\n",
+ " \"input_tokens\": 23,\n",
+ " \"total_tokens\": 30,\n",
+ " \"input_token_details\": {\n",
+ " \"cache_read\": 0\n",
+ " },\n",
+ " \"output_token_details\": {}\n",
+ " }\n",
+ "}\n"
+ ]
+ }
+ ],
+ "source": [
+ "const aiMsg = await llm.invoke([\n",
+ " [\n",
+ " \"system\",\n",
+ " \"You are a helpful assistant that translates English to French. Translate the user sentence.\",\n",
+ " ],\n",
+ " [\"human\", \"I love programming.\"],\n",
+ "])\n",
+ "aiMsg"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "id": "d86145b3-bfef-46e8-b227-4dda5c9c2705",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "J'adore la programmation.\n"
+ ]
+ }
+ ],
+ "source": [
+ "console.log(aiMsg.content)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "18e2bfc0-7e78-4528-a73f-499ac150dca8",
+ "metadata": {},
+ "source": [
+ "## Chaining\n",
+ "\n",
+ "We can [chain](/docs/how_to/sequence/) our model with a prompt template like so:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "id": "e197d1d7-a070-4c96-9f8a-a0e86d046e0b",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "AIMessage {\n",
+ " \"id\": \"6e7f6f8c-8d7a-4dad-be07-425384038fd4\",\n",
+ " \"content\": \"Ich liebe es zu programmieren.\",\n",
+ " \"additional_kwargs\": {,\n",
+ " \"reasoning_content\": \"...\",\n",
+ " },\n",
+ " \"response_metadata\": {\n",
+ " \"tokenUsage\": {\n",
+ " \"promptTokens\": 18,\n",
+ " \"completionTokens\": 9,\n",
+ " \"totalTokens\": 27\n",
+ " },\n",
+ " \"finish_reason\": \"stop\",\n",
+ " \"model_name\": \"deepseek-reasoner\",\n",
+ " \"usage\": {\n",
+ " \"prompt_tokens\": 18,\n",
+ " \"completion_tokens\": 9,\n",
+ " \"total_tokens\": 27,\n",
+ " \"prompt_tokens_details\": {\n",
+ " \"cached_tokens\": 0\n",
+ " },\n",
+ " \"prompt_cache_hit_tokens\": 0,\n",
+ " \"prompt_cache_miss_tokens\": 18\n",
+ " },\n",
+ " \"system_fingerprint\": \"fp_3a5770e1b4\"\n",
+ " },\n",
+ " \"tool_calls\": [],\n",
+ " \"invalid_tool_calls\": [],\n",
+ " \"usage_metadata\": {\n",
+ " \"output_tokens\": 9,\n",
+ " \"input_tokens\": 18,\n",
+ " \"total_tokens\": 27,\n",
+ " \"input_token_details\": {\n",
+ " \"cache_read\": 0\n",
+ " },\n",
+ " \"output_token_details\": {}\n",
+ " }\n",
+ "}\n"
+ ]
+ }
+ ],
+ "source": [
+ "import { ChatPromptTemplate } from \"@langchain/core/prompts\"\n",
+ "\n",
+ "const prompt = ChatPromptTemplate.fromMessages(\n",
+ " [\n",
+ " [\n",
+ " \"system\",\n",
+ " \"You are a helpful assistant that translates {input_language} to {output_language}.\",\n",
+ " ],\n",
+ " [\"human\", \"{input}\"],\n",
+ " ]\n",
+ ")\n",
+ "\n",
+ "const chain = prompt.pipe(llm);\n",
+ "await chain.invoke(\n",
+ " {\n",
+ " input_language: \"English\",\n",
+ " output_language: \"German\",\n",
+ " input: \"I love programming.\",\n",
+ " }\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "3a5bb5ca-c3ae-4a58-be67-2cd18574b9a3",
+ "metadata": {},
+ "source": [
+ "## API reference\n",
+ "\n",
+ "For detailed documentation of all ChatDeepSeek features and configurations head to the API reference: https://api.js.langchain.com/classes/_langchain_deepseek.ChatDeepSeek.html"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "TypeScript",
+ "language": "typescript",
+ "name": "tslab"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "mode": "typescript",
+ "name": "javascript",
+ "typescript": true
+ },
+ "file_extension": ".ts",
+ "mimetype": "text/typescript",
+ "name": "typescript",
+ "version": "3.7.2"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/docs/core_docs/docs/integrations/chat/xai.ipynb b/docs/core_docs/docs/integrations/chat/xai.ipynb
index 830eec608441..7bdd5c23d217 100644
--- a/docs/core_docs/docs/integrations/chat/xai.ipynb
+++ b/docs/core_docs/docs/integrations/chat/xai.ipynb
@@ -23,7 +23,7 @@
"\n",
"[xAI](https://x.ai/) is an artificial intelligence company that develops large language models (LLMs). Their flagship model, Grok, is trained on real-time X (formerly Twitter) data and aims to provide witty, personality-rich responses while maintaining high capability on technical tasks.\n",
"\n",
- "This guide will help you getting started with `ChatXAI` [chat models](/docs/concepts/chat_models). For detailed documentation of all `ChatXAI` features and configurations head to the [API reference](https://api.js.langchain.com/classes/langchain_community_chat_models_fireworks.ChatXAI.html).\n",
+ "This guide will help you getting started with `ChatXAI` [chat models](/docs/concepts/chat_models). For detailed documentation of all `ChatXAI` features and configurations head to the [API reference](https://api.js.langchain.com/classes/_langchain_xai.ChatXAI.html).\n",
"\n",
"## Overview\n",
"### Integration details\n",
diff --git a/examples/package.json b/examples/package.json
index e06c5ebbe717..957ee04f1596 100644
--- a/examples/package.json
+++ b/examples/package.json
@@ -45,6 +45,7 @@
"@langchain/cohere": "workspace:*",
"@langchain/community": "workspace:*",
"@langchain/core": "workspace:*",
+ "@langchain/deepseek": "workspace:*",
"@langchain/exa": "workspace:*",
"@langchain/google-common": "workspace:*",
"@langchain/google-genai": "workspace:*",
diff --git a/libs/langchain-deepseek/.env.example b/libs/langchain-deepseek/.env.example
new file mode 100644
index 000000000000..35d3b23d9b15
--- /dev/null
+++ b/libs/langchain-deepseek/.env.example
@@ -0,0 +1 @@
+DEEPSEEK_API_KEY="your_key"
diff --git a/libs/langchain-deepseek/.eslintrc.cjs b/libs/langchain-deepseek/.eslintrc.cjs
new file mode 100644
index 000000000000..e3033ac0160c
--- /dev/null
+++ b/libs/langchain-deepseek/.eslintrc.cjs
@@ -0,0 +1,74 @@
+module.exports = {
+ extends: [
+ "airbnb-base",
+ "eslint:recommended",
+ "prettier",
+ "plugin:@typescript-eslint/recommended",
+ ],
+ parserOptions: {
+ ecmaVersion: 12,
+ parser: "@typescript-eslint/parser",
+ project: "./tsconfig.json",
+ sourceType: "module",
+ },
+ plugins: ["@typescript-eslint", "no-instanceof"],
+ ignorePatterns: [
+ ".eslintrc.cjs",
+ "scripts",
+ "node_modules",
+ "dist",
+ "dist-cjs",
+ "*.js",
+ "*.cjs",
+ "*.d.ts",
+ ],
+ rules: {
+ "no-process-env": 2,
+ "no-instanceof/no-instanceof": 2,
+ "@typescript-eslint/explicit-module-boundary-types": 0,
+ "@typescript-eslint/no-empty-function": 0,
+ "@typescript-eslint/no-shadow": 0,
+ "@typescript-eslint/no-empty-interface": 0,
+ "@typescript-eslint/no-use-before-define": ["error", "nofunc"],
+ "@typescript-eslint/no-unused-vars": ["warn", { args: "none" }],
+ "@typescript-eslint/no-floating-promises": "error",
+ "@typescript-eslint/no-misused-promises": "error",
+ camelcase: 0,
+ "class-methods-use-this": 0,
+ "import/extensions": [2, "ignorePackages"],
+ "import/no-extraneous-dependencies": [
+ "error",
+ { devDependencies: ["**/*.test.ts"] },
+ ],
+ "import/no-unresolved": 0,
+ "import/prefer-default-export": 0,
+ "keyword-spacing": "error",
+ "max-classes-per-file": 0,
+ "max-len": 0,
+ "no-await-in-loop": 0,
+ "no-bitwise": 0,
+ "no-console": 0,
+ "no-restricted-syntax": 0,
+ "no-shadow": 0,
+ "no-continue": 0,
+ "no-void": 0,
+ "no-underscore-dangle": 0,
+ "no-use-before-define": 0,
+ "no-useless-constructor": 0,
+ "no-return-await": 0,
+ "consistent-return": 0,
+ "no-else-return": 0,
+ "func-names": 0,
+ "no-lonely-if": 0,
+ "prefer-rest-params": 0,
+ "new-cap": ["error", { properties: false, capIsNew: false }],
+ },
+ overrides: [
+ {
+ files: ["**/*.test.ts"],
+ rules: {
+ "@typescript-eslint/no-unused-vars": "off",
+ },
+ },
+ ],
+};
diff --git a/libs/langchain-deepseek/.gitignore b/libs/langchain-deepseek/.gitignore
new file mode 100644
index 000000000000..c10034e2f1be
--- /dev/null
+++ b/libs/langchain-deepseek/.gitignore
@@ -0,0 +1,7 @@
+index.cjs
+index.js
+index.d.ts
+index.d.cts
+node_modules
+dist
+.yarn
diff --git a/libs/langchain-deepseek/.prettierrc b/libs/langchain-deepseek/.prettierrc
new file mode 100644
index 000000000000..ba08ff04f677
--- /dev/null
+++ b/libs/langchain-deepseek/.prettierrc
@@ -0,0 +1,19 @@
+{
+ "$schema": "https://json.schemastore.org/prettierrc",
+ "printWidth": 80,
+ "tabWidth": 2,
+ "useTabs": false,
+ "semi": true,
+ "singleQuote": false,
+ "quoteProps": "as-needed",
+ "jsxSingleQuote": false,
+ "trailingComma": "es5",
+ "bracketSpacing": true,
+ "arrowParens": "always",
+ "requirePragma": false,
+ "insertPragma": false,
+ "proseWrap": "preserve",
+ "htmlWhitespaceSensitivity": "css",
+ "vueIndentScriptAndStyle": false,
+ "endOfLine": "lf"
+}
diff --git a/libs/langchain-deepseek/.release-it.json b/libs/langchain-deepseek/.release-it.json
new file mode 100644
index 000000000000..522ee6abf705
--- /dev/null
+++ b/libs/langchain-deepseek/.release-it.json
@@ -0,0 +1,10 @@
+{
+ "github": {
+ "release": true,
+ "autoGenerate": true,
+ "tokenRef": "GITHUB_TOKEN_RELEASE"
+ },
+ "npm": {
+ "versionArgs": ["--workspaces-update=false"]
+ }
+}
diff --git a/libs/langchain-deepseek/LICENSE b/libs/langchain-deepseek/LICENSE
new file mode 100644
index 000000000000..5ca9f27fb092
--- /dev/null
+++ b/libs/langchain-deepseek/LICENSE
@@ -0,0 +1,21 @@
+The MIT License
+
+Copyright (c) 2025 LangChain
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
\ No newline at end of file
diff --git a/libs/langchain-deepseek/README.md b/libs/langchain-deepseek/README.md
new file mode 100644
index 000000000000..e3de71427102
--- /dev/null
+++ b/libs/langchain-deepseek/README.md
@@ -0,0 +1,80 @@
+# @langchain/deepseek
+
+This package contains the LangChain.js integrations for DeepSeek.
+
+## Installation
+
+```bash npm2yarn
+npm install @langchain/deepseek @langchain/core
+```
+
+## Chat models
+
+This package adds support for DeepSeek's chat model inference.
+
+Set the necessary environment variable (or pass it in via the constructor):
+
+```bash
+export DEEPSEEK_API_KEY=
+```
+
+```typescript
+import { ChatDeepSeek } from "@langchain/deepseek";
+import { HumanMessage } from "@langchain/core/messages";
+
+const model = new ChatDeepSeek({
+ apiKey: process.env.DEEPSEEK_API_KEY, // Default value.
+ model: "",
+});
+
+const res = await model.invoke([
+ {
+ role: "user",
+ content: message,
+ },
+]);
+```
+
+## Development
+
+To develop the `@langchain/deepseek` package, you'll need to follow these instructions:
+
+### Install dependencies
+
+```bash
+yarn install
+```
+
+### Build the package
+
+```bash
+yarn build
+```
+
+Or from the repo root:
+
+```bash
+yarn build --filter=@langchain/deepseek
+```
+
+### Run tests
+
+Test files should live within a `tests/` file in the `src/` folder. Unit tests should end in `.test.ts` and integration tests should
+end in `.int.test.ts`:
+
+```bash
+$ yarn test
+$ yarn test:int
+```
+
+### Lint & Format
+
+Run the linter & formatter to ensure your code is up to standard:
+
+```bash
+yarn lint && yarn format
+```
+
+### Adding new entrypoints
+
+If you add a new file to be exported, either import & re-export from `src/index.ts`, or add it to the `entrypoints` field in the `config` variable located inside `langchain.config.js` and run `yarn build` to generate the new entrypoint.
diff --git a/libs/langchain-deepseek/jest.config.cjs b/libs/langchain-deepseek/jest.config.cjs
new file mode 100644
index 000000000000..994826496bc5
--- /dev/null
+++ b/libs/langchain-deepseek/jest.config.cjs
@@ -0,0 +1,21 @@
+/** @type {import('ts-jest').JestConfigWithTsJest} */
+module.exports = {
+ preset: "ts-jest/presets/default-esm",
+ testEnvironment: "./jest.env.cjs",
+ modulePathIgnorePatterns: ["dist/", "docs/"],
+ moduleNameMapper: {
+ "^(\\.{1,2}/.*)\\.js$": "$1",
+ },
+ transform: {
+ "^.+\\.tsx?$": ["@swc/jest"],
+ },
+ transformIgnorePatterns: [
+ "/node_modules/",
+ "\\.pnp\\.[^\\/]+$",
+ "./scripts/jest-setup-after-env.js",
+ ],
+ setupFiles: ["dotenv/config"],
+ testTimeout: 20_000,
+ passWithNoTests: true,
+ collectCoverageFrom: ["src/**/*.ts"],
+};
diff --git a/libs/langchain-deepseek/jest.env.cjs b/libs/langchain-deepseek/jest.env.cjs
new file mode 100644
index 000000000000..2ccedccb8672
--- /dev/null
+++ b/libs/langchain-deepseek/jest.env.cjs
@@ -0,0 +1,12 @@
+const { TestEnvironment } = require("jest-environment-node");
+
+class AdjustedTestEnvironmentToSupportFloat32Array extends TestEnvironment {
+ constructor(config, context) {
+ // Make `instanceof Float32Array` return true in tests
+ // to avoid https://github.com/xenova/transformers.js/issues/57 and https://github.com/jestjs/jest/issues/2549
+ super(config, context);
+ this.global.Float32Array = Float32Array;
+ }
+}
+
+module.exports = AdjustedTestEnvironmentToSupportFloat32Array;
diff --git a/libs/langchain-deepseek/langchain.config.js b/libs/langchain-deepseek/langchain.config.js
new file mode 100644
index 000000000000..46b1a2b31264
--- /dev/null
+++ b/libs/langchain-deepseek/langchain.config.js
@@ -0,0 +1,22 @@
+import { resolve, dirname } from "node:path";
+import { fileURLToPath } from "node:url";
+
+/**
+ * @param {string} relativePath
+ * @returns {string}
+ */
+function abs(relativePath) {
+ return resolve(dirname(fileURLToPath(import.meta.url)), relativePath);
+}
+
+export const config = {
+ internals: [/node\:/, /@langchain\/core\//],
+ entrypoints: {
+ index: "index",
+ },
+ requiresOptionalDependency: [],
+ tsConfigPath: resolve("./tsconfig.json"),
+ cjsSource: "./dist-cjs",
+ cjsDestination: "./dist",
+ abs,
+};
diff --git a/libs/langchain-deepseek/package.json b/libs/langchain-deepseek/package.json
new file mode 100644
index 000000000000..a381b5f0752b
--- /dev/null
+++ b/libs/langchain-deepseek/package.json
@@ -0,0 +1,89 @@
+{
+ "name": "@langchain/deepseek",
+ "version": "0.0.0",
+ "description": "Deepseek integration for LangChain.js",
+ "type": "module",
+ "engines": {
+ "node": ">=18"
+ },
+ "main": "./index.js",
+ "types": "./index.d.ts",
+ "repository": {
+ "type": "git",
+ "url": "git@github.com:langchain-ai/langchainjs.git"
+ },
+ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/@langchain/deepseek",
+ "scripts": {
+ "build": "yarn turbo:command build:internal --filter=@langchain/deepseek",
+ "build:internal": "yarn lc_build --create-entrypoints --pre --tree-shaking",
+ "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/",
+ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts",
+ "lint": "yarn lint:eslint && yarn lint:dpdm",
+ "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm",
+ "clean": "rm -rf .turbo dist/",
+ "prepack": "yarn build",
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
+ "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
+ "test:single": "NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000",
+ "test:int": "NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.int\\.test.ts --testTimeout 100000 --maxWorkers=50%",
+ "format": "prettier --config .prettierrc --write \"src\"",
+ "format:check": "prettier --config .prettierrc --check \"src\""
+ },
+ "author": "LangChain",
+ "license": "MIT",
+ "dependencies": {
+ "@langchain/openai": "^0.4.2",
+ "zod": "^3.24.1"
+ },
+ "peerDependencies": {
+ "@langchain/core": ">=0.3.0 <0.4.0"
+ },
+ "devDependencies": {
+ "@jest/globals": "^29.5.0",
+ "@langchain/core": "workspace:*",
+ "@langchain/scripts": ">=0.1.0 <0.2.0",
+ "@langchain/standard-tests": "workspace:*",
+ "@swc/core": "^1.3.90",
+ "@swc/jest": "^0.2.29",
+ "@tsconfig/recommended": "^1.0.3",
+ "@typescript-eslint/eslint-plugin": "^6.12.0",
+ "@typescript-eslint/parser": "^6.12.0",
+ "dotenv": "^16.3.1",
+ "dpdm": "^3.12.0",
+ "eslint": "^8.33.0",
+ "eslint-config-airbnb-base": "^15.0.0",
+ "eslint-config-prettier": "^8.6.0",
+ "eslint-plugin-import": "^2.27.5",
+ "eslint-plugin-no-instanceof": "^1.0.1",
+ "eslint-plugin-prettier": "^4.2.1",
+ "jest": "^29.5.0",
+ "jest-environment-node": "^29.6.4",
+ "prettier": "^2.8.3",
+ "release-it": "^15.10.1",
+ "rollup": "^4.5.2",
+ "ts-jest": "^29.1.0",
+ "typescript": "<5.2.0"
+ },
+ "publishConfig": {
+ "access": "public"
+ },
+ "exports": {
+ ".": {
+ "types": {
+ "import": "./index.d.ts",
+ "require": "./index.d.cts",
+ "default": "./index.d.ts"
+ },
+ "import": "./index.js",
+ "require": "./index.cjs"
+ },
+ "./package.json": "./package.json"
+ },
+ "files": [
+ "dist/",
+ "index.cjs",
+ "index.js",
+ "index.d.ts",
+ "index.d.cts"
+ ]
+}
diff --git a/libs/langchain-deepseek/scripts/jest-setup-after-env.js b/libs/langchain-deepseek/scripts/jest-setup-after-env.js
new file mode 100644
index 000000000000..7323083d0ea5
--- /dev/null
+++ b/libs/langchain-deepseek/scripts/jest-setup-after-env.js
@@ -0,0 +1,9 @@
+import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";
+import { afterAll, jest } from "@jest/globals";
+
+afterAll(awaitAllCallbacks);
+
+// Allow console.log to be disabled in tests
+if (process.env.DISABLE_CONSOLE_LOGS === "true") {
+ console.log = jest.fn();
+}
diff --git a/libs/langchain-deepseek/src/chat_models.ts b/libs/langchain-deepseek/src/chat_models.ts
new file mode 100644
index 000000000000..7127a2b482b9
--- /dev/null
+++ b/libs/langchain-deepseek/src/chat_models.ts
@@ -0,0 +1,534 @@
+import { BaseLanguageModelInput } from "@langchain/core/language_models/base";
+import { BaseMessage } from "@langchain/core/messages";
+import { Runnable } from "@langchain/core/runnables";
+import { getEnvironmentVariable } from "@langchain/core/utils/env";
+import {
+ ChatOpenAI,
+ ChatOpenAICallOptions,
+ ChatOpenAIFields,
+ ChatOpenAIStructuredOutputMethodOptions,
+ OpenAIClient,
+} from "@langchain/openai";
+import { z } from "zod";
+
+export interface ChatDeepSeekCallOptions extends ChatOpenAICallOptions {
+ headers?: Record;
+}
+
+export interface ChatDeepSeekInput extends ChatOpenAIFields {
+ /**
+ * The Deepseek API key to use for requests.
+ * @default process.env.DEEPSEEK_API_KEY
+ */
+ apiKey?: string;
+ /**
+ * The name of the model to use.
+ */
+ model?: string;
+ /**
+ * Up to 4 sequences where the API will stop generating further tokens. The
+ * returned text will not contain the stop sequence.
+ * Alias for `stopSequences`
+ */
+ stop?: Array;
+ /**
+ * Up to 4 sequences where the API will stop generating further tokens. The
+ * returned text will not contain the stop sequence.
+ */
+ stopSequences?: Array;
+ /**
+ * Whether or not to stream responses.
+ */
+ streaming?: boolean;
+ /**
+ * The temperature to use for sampling.
+ */
+ temperature?: number;
+ /**
+ * The maximum number of tokens that the model can process in a single response.
+ * This limits ensures computational efficiency and resource management.
+ */
+ maxTokens?: number;
+}
+
+/**
+ * Deepseek chat model integration.
+ *
+ * The Deepseek API is compatible to the OpenAI API with some limitations.
+ *
+ * Setup:
+ * Install `@langchain/deepseek` and set an environment variable named `DEEPSEEK_API_KEY`.
+ *
+ * ```bash
+ * npm install @langchain/deepseek
+ * export DEEPSEEK_API_KEY="your-api-key"
+ * ```
+ *
+ * ## [Constructor args](https://api.js.langchain.com/classes/_langchain_deepseek.ChatDeepSeek.html#constructor)
+ *
+ * ## [Runtime args](https://api.js.langchain.com/interfaces/_langchain_deepseek.ChatDeepSeekCallOptions.html)
+ *
+ * Runtime args can be passed as the second argument to any of the base runnable methods `.invoke`. `.stream`, `.batch`, etc.
+ * They can also be passed via `.bind`, or the second arg in `.bindTools`, like shown in the examples below:
+ *
+ * ```typescript
+ * // When calling `.bind`, call options should be passed via the first argument
+ * const llmWithArgsBound = llm.bind({
+ * stop: ["\n"],
+ * tools: [...],
+ * });
+ *
+ * // When calling `.bindTools`, call options should be passed via the second argument
+ * const llmWithTools = llm.bindTools(
+ * [...],
+ * {
+ * tool_choice: "auto",
+ * }
+ * );
+ * ```
+ *
+ * ## Examples
+ *
+ *
+ * Instantiate
+ *
+ * ```typescript
+ * import { ChatDeepSeek } from '@langchain/deepseek';
+ *
+ * const llm = new ChatDeepSeek({
+ * model: "deepseek-reasoner",
+ * temperature: 0,
+ * // other params...
+ * });
+ * ```
+ *
+ *
+ *
+ *
+ *
+ * Invoking
+ *
+ * ```typescript
+ * const input = `Translate "I love programming" into French.`;
+ *
+ * // Models also accept a list of chat messages or a formatted prompt
+ * const result = await llm.invoke(input);
+ * console.log(result);
+ * ```
+ *
+ * ```txt
+ * AIMessage {
+ * "content": "The French translation of \"I love programming\" is \"J'aime programmer\". In this sentence, \"J'aime\" is the first person singular conjugation of the French verb \"aimer\" which means \"to love\", and \"programmer\" is the French infinitive for \"to program\". I hope this helps! Let me know if you have any other questions.",
+ * "additional_kwargs": {
+ * "reasoning_content": "...",
+ * },
+ * "response_metadata": {
+ * "tokenUsage": {
+ * "completionTokens": 82,
+ * "promptTokens": 20,
+ * "totalTokens": 102
+ * },
+ * "finish_reason": "stop"
+ * },
+ * "tool_calls": [],
+ * "invalid_tool_calls": []
+ * }
+ * ```
+ *
+ *
+ *
+ *
+ *
+ * Streaming Chunks
+ *
+ * ```typescript
+ * for await (const chunk of await llm.stream(input)) {
+ * console.log(chunk);
+ * }
+ * ```
+ *
+ * ```txt
+ * AIMessageChunk {
+ * "content": "",
+ * "additional_kwargs": {
+ * "reasoning_content": "...",
+ * },
+ * "response_metadata": {
+ * "finishReason": null
+ * },
+ * "tool_calls": [],
+ * "tool_call_chunks": [],
+ * "invalid_tool_calls": []
+ * }
+ * AIMessageChunk {
+ * "content": "The",
+ * "additional_kwargs": {
+ * "reasoning_content": "...",
+ * },
+ * "response_metadata": {
+ * "finishReason": null
+ * },
+ * "tool_calls": [],
+ * "tool_call_chunks": [],
+ * "invalid_tool_calls": []
+ * }
+ * AIMessageChunk {
+ * "content": " French",
+ * "additional_kwargs": {
+ * "reasoning_content": "...",
+ * },
+ * "response_metadata": {
+ * "finishReason": null
+ * },
+ * "tool_calls": [],
+ * "tool_call_chunks": [],
+ * "invalid_tool_calls": []
+ * }
+ * AIMessageChunk {
+ * "content": " translation",
+ * "additional_kwargs": {
+ * "reasoning_content": "...",
+ * },
+ * "response_metadata": {
+ * "finishReason": null
+ * },
+ * "tool_calls": [],
+ * "tool_call_chunks": [],
+ * "invalid_tool_calls": []
+ * }
+ * AIMessageChunk {
+ * "content": " of",
+ * "additional_kwargs": {
+ * "reasoning_content": "...",
+ * },
+ * "response_metadata": {
+ * "finishReason": null
+ * },
+ * "tool_calls": [],
+ * "tool_call_chunks": [],
+ * "invalid_tool_calls": []
+ * }
+ * AIMessageChunk {
+ * "content": " \"",
+ * "additional_kwargs": {
+ * "reasoning_content": "...",
+ * },
+ * "response_metadata": {
+ * "finishReason": null
+ * },
+ * "tool_calls": [],
+ * "tool_call_chunks": [],
+ * "invalid_tool_calls": []
+ * }
+ * AIMessageChunk {
+ * "content": "I",
+ * "additional_kwargs": {
+ * "reasoning_content": "...",
+ * },
+ * "response_metadata": {
+ * "finishReason": null
+ * },
+ * "tool_calls": [],
+ * "tool_call_chunks": [],
+ * "invalid_tool_calls": []
+ * }
+ * AIMessageChunk {
+ * "content": " love",
+ * "additional_kwargs": {
+ * "reasoning_content": "...",
+ * },
+ * "response_metadata": {
+ * "finishReason": null
+ * },
+ * "tool_calls": [],
+ * "tool_call_chunks": [],
+ * "invalid_tool_calls": []
+ * }
+ * ...
+ * AIMessageChunk {
+ * "content": ".",
+ * "additional_kwargs": {
+ * "reasoning_content": "...",
+ * },
+ * "response_metadata": {
+ * "finishReason": null
+ * },
+ * "tool_calls": [],
+ * "tool_call_chunks": [],
+ * "invalid_tool_calls": []
+ * }
+ * AIMessageChunk {
+ * "content": "",
+ * "additional_kwargs": {
+ * "reasoning_content": "...",
+ * },
+ * "response_metadata": {
+ * "finishReason": "stop"
+ * },
+ * "tool_calls": [],
+ * "tool_call_chunks": [],
+ * "invalid_tool_calls": []
+ * }
+ * ```
+ *
+ *
+ *
+ *
+ *
+ * Aggregate Streamed Chunks
+ *
+ * ```typescript
+ * import { AIMessageChunk } from '@langchain/core/messages';
+ * import { concat } from '@langchain/core/utils/stream';
+ *
+ * const stream = await llm.stream(input);
+ * let full: AIMessageChunk | undefined;
+ * for await (const chunk of stream) {
+ * full = !full ? chunk : concat(full, chunk);
+ * }
+ * console.log(full);
+ * ```
+ *
+ * ```txt
+ * AIMessageChunk {
+ * "content": "The French translation of \"I love programming\" is \"J'aime programmer\". In this sentence, \"J'aime\" is the first person singular conjugation of the French verb \"aimer\" which means \"to love\", and \"programmer\" is the French infinitive for \"to program\". I hope this helps! Let me know if you have any other questions.",
+ * "additional_kwargs": {
+ * "reasoning_content": "...",
+ * },
+ * "response_metadata": {
+ * "finishReason": "stop"
+ * },
+ * "tool_calls": [],
+ * "tool_call_chunks": [],
+ * "invalid_tool_calls": []
+ * }
+ * ```
+ *
+ *
+ *
+ *
+ *
+ * Bind tools
+ *
+ * ```typescript
+ * import { z } from 'zod';
+ *
+ * const llmForToolCalling = new ChatDeepSeek({
+ * model: "deepseek-chat",
+ * temperature: 0,
+ * // other params...
+ * });
+ *
+ * const GetWeather = {
+ * name: "GetWeather",
+ * description: "Get the current weather in a given location",
+ * schema: z.object({
+ * location: z.string().describe("The city and state, e.g. San Francisco, CA")
+ * }),
+ * }
+ *
+ * const GetPopulation = {
+ * name: "GetPopulation",
+ * description: "Get the current population in a given location",
+ * schema: z.object({
+ * location: z.string().describe("The city and state, e.g. San Francisco, CA")
+ * }),
+ * }
+ *
+ * const llmWithTools = llmForToolCalling.bindTools([GetWeather, GetPopulation]);
+ * const aiMsg = await llmWithTools.invoke(
+ * "Which city is hotter today and which is bigger: LA or NY?"
+ * );
+ * console.log(aiMsg.tool_calls);
+ * ```
+ *
+ * ```txt
+ * [
+ * {
+ * name: 'GetWeather',
+ * args: { location: 'Los Angeles, CA' },
+ * type: 'tool_call',
+ * id: 'call_cd34'
+ * },
+ * {
+ * name: 'GetWeather',
+ * args: { location: 'New York, NY' },
+ * type: 'tool_call',
+ * id: 'call_68rf'
+ * },
+ * {
+ * name: 'GetPopulation',
+ * args: { location: 'Los Angeles, CA' },
+ * type: 'tool_call',
+ * id: 'call_f81z'
+ * },
+ * {
+ * name: 'GetPopulation',
+ * args: { location: 'New York, NY' },
+ * type: 'tool_call',
+ * id: 'call_8byt'
+ * }
+ * ]
+ * ```
+ *
+ *
+ *
+ *
+ *
+ * Structured Output
+ *
+ * ```typescript
+ * import { z } from 'zod';
+ *
+ * const Joke = z.object({
+ * setup: z.string().describe("The setup of the joke"),
+ * punchline: z.string().describe("The punchline to the joke"),
+ * rating: z.number().optional().describe("How funny the joke is, from 1 to 10")
+ * }).describe('Joke to tell user.');
+ *
+ * const structuredLlm = llmForToolCalling.withStructuredOutput(Joke, { name: "Joke" });
+ * const jokeResult = await structuredLlm.invoke("Tell me a joke about cats");
+ * console.log(jokeResult);
+ * ```
+ *
+ * ```txt
+ * {
+ * setup: "Why don't cats play poker in the wild?",
+ * punchline: 'Because there are too many cheetahs.'
+ * }
+ * ```
+ *
+ *
+ *
+ */
+export class ChatDeepSeek extends ChatOpenAI {
+ static lc_name() {
+ return "ChatDeepSeek";
+ }
+
+ _llmType() {
+ return "deepseek";
+ }
+
+ get lc_secrets(): { [key: string]: string } | undefined {
+ return {
+ apiKey: "DEEPSEEK_API_KEY",
+ };
+ }
+
+ lc_serializable = true;
+
+ lc_namespace = ["langchain", "chat_models", "deepseek"];
+
+ constructor(fields?: Partial) {
+ const apiKey = fields?.apiKey || getEnvironmentVariable("DEEPSEEK_API_KEY");
+ if (!apiKey) {
+ throw new Error(
+ `Deepseek API key not found. Please set the DEEPSEEK_API_KEY environment variable or pass the key into "apiKey" field.`
+ );
+ }
+
+ super({
+ ...fields,
+ apiKey,
+ configuration: {
+ baseURL: "https://api.deepseek.com",
+ ...fields?.configuration,
+ },
+ });
+ }
+
+ protected override _convertOpenAIDeltaToBaseMessageChunk(
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ delta: Record,
+ rawResponse: OpenAIClient.ChatCompletionChunk,
+ defaultRole?:
+ | "function"
+ | "user"
+ | "system"
+ | "developer"
+ | "assistant"
+ | "tool"
+ ) {
+ const messageChunk = super._convertOpenAIDeltaToBaseMessageChunk(
+ delta,
+ rawResponse,
+ defaultRole
+ );
+ messageChunk.additional_kwargs.reasoning_content = delta.reasoning_content;
+ return messageChunk;
+ }
+
+ protected override _convertOpenAIChatCompletionMessageToBaseMessage(
+ message: OpenAIClient.ChatCompletionMessage,
+ rawResponse: OpenAIClient.ChatCompletion
+ ) {
+ const langChainMessage =
+ super._convertOpenAIChatCompletionMessageToBaseMessage(
+ message,
+ rawResponse
+ );
+ langChainMessage.additional_kwargs.reasoning_content =
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ (message as any).reasoning_content;
+ return langChainMessage;
+ }
+
+ withStructuredOutput<
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ RunOutput extends Record = Record
+ >(
+ outputSchema:
+ | z.ZodType
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ | Record,
+ config?: ChatOpenAIStructuredOutputMethodOptions
+ ): Runnable;
+
+ withStructuredOutput<
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ RunOutput extends Record = Record
+ >(
+ outputSchema:
+ | z.ZodType
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ | Record,
+ config?: ChatOpenAIStructuredOutputMethodOptions
+ ): Runnable;
+
+ withStructuredOutput<
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ RunOutput extends Record = Record
+ >(
+ outputSchema:
+ | z.ZodType
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ | Record,
+ config?: ChatOpenAIStructuredOutputMethodOptions
+ ):
+ | Runnable
+ | Runnable;
+
+ withStructuredOutput<
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ RunOutput extends Record = Record
+ >(
+ outputSchema:
+ | z.ZodType
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ | Record,
+ config?: ChatOpenAIStructuredOutputMethodOptions
+ ):
+ | Runnable
+ | Runnable<
+ BaseLanguageModelInput,
+ { raw: BaseMessage; parsed: RunOutput }
+ > {
+ const ensuredConfig = { ...config };
+ // Deepseek does not support json schema yet
+ if (ensuredConfig?.method === undefined) {
+ ensuredConfig.method = "functionCalling";
+ }
+ return super.withStructuredOutput(outputSchema, ensuredConfig);
+ }
+}
diff --git a/libs/langchain-deepseek/src/index.ts b/libs/langchain-deepseek/src/index.ts
new file mode 100644
index 000000000000..38c7cea7f478
--- /dev/null
+++ b/libs/langchain-deepseek/src/index.ts
@@ -0,0 +1 @@
+export * from "./chat_models.js";
diff --git a/libs/langchain-deepseek/src/tests/chat_models.int.test.ts b/libs/langchain-deepseek/src/tests/chat_models.int.test.ts
new file mode 100644
index 000000000000..2069a2984690
--- /dev/null
+++ b/libs/langchain-deepseek/src/tests/chat_models.int.test.ts
@@ -0,0 +1,16 @@
+/* eslint-disable no-process-env */
+/* eslint-disable @typescript-eslint/no-explicit-any */
+import { test, expect } from "@jest/globals";
+import { ChatDeepSeek } from "../chat_models.js";
+
+test("Can send deepseek-reasoner requests", async () => {
+ const llm = new ChatDeepSeek({
+ model: "deepseek-reasoner",
+ });
+ const input = `Translate "I love programming" into French.`;
+ // Models also accept a list of chat messages or a formatted prompt
+ const result = await llm.invoke(input);
+ expect(
+ (result.additional_kwargs.reasoning_content as any).length
+ ).toBeGreaterThan(10);
+});
diff --git a/libs/langchain-deepseek/src/tests/chat_models.standard.int.test.ts b/libs/langchain-deepseek/src/tests/chat_models.standard.int.test.ts
new file mode 100644
index 000000000000..223eff75d4d6
--- /dev/null
+++ b/libs/langchain-deepseek/src/tests/chat_models.standard.int.test.ts
@@ -0,0 +1,126 @@
+/* eslint-disable no-process-env */
+import { test } from "@jest/globals";
+import { ChatModelIntegrationTests } from "@langchain/standard-tests";
+import { AIMessageChunk } from "@langchain/core/messages";
+// import { readFileSync } from "fs";
+// import { join } from "path";
+// import { concat } from "@langchain/core/utils/stream";
+// import { BaseLanguageModelInput } from "@langchain/core/language_models/base";
+import { ChatDeepSeek, ChatDeepSeekCallOptions } from "../chat_models.js";
+
+// const REPO_ROOT_DIR = process.cwd();
+
+class ChatDeepSeekStandardIntegrationTests extends ChatModelIntegrationTests<
+ ChatDeepSeekCallOptions,
+ AIMessageChunk
+> {
+ constructor() {
+ if (!process.env.DEEPSEEK_API_KEY) {
+ throw new Error(
+ "DEEPSEEK_API_KEY must be set to run standard integration tests."
+ );
+ }
+ super({
+ Cls: ChatDeepSeek,
+ chatModelHasToolCalling: true,
+ chatModelHasStructuredOutput: true,
+ supportsParallelToolCalls: false,
+ constructorArgs: {
+ model: "deepseek-chat",
+ maxRetries: 0,
+ },
+ });
+ }
+
+ supportedUsageMetadataDetails: {
+ invoke: Array<
+ "audio_input" | "audio_output"
+ // | "reasoning_output"
+ // | "cache_read_input"
+ // | "cache_creation_input"
+ >;
+ stream: Array<
+ "audio_input" | "audio_output"
+ // | "reasoning_output"
+ // | "cache_read_input"
+ // | "cache_creation_input"
+ >;
+ } = {
+ invoke: [
+ // "cache_read_input" "reasoning_output"
+ ],
+ stream: [],
+ };
+
+ // async invokeWithReasoningOutput(stream: boolean) {
+ // const chatModel = new ChatDeepSeek({
+ // model: "deepseek-reasoner",
+ // streamUsage: true,
+ // temperature: 1,
+ // });
+ // const input =
+ // "explain the relationship between the 2008/9 economic crisis and the startup ecosystem in the early 2010s";
+
+ // return invoke(chatModel, input, stream);
+ // }
+
+ // async testUsageMetadataStreaming() {
+ // // ChatDeepSeek does not support streaming tokens by
+ // // default, so we must pass in a call option to
+ // // enable streaming tokens.
+ // const callOptions: ChatDeepSeek["ParsedCallOptions"] = {
+ // stream_options: {
+ // include_usage: true,
+ // },
+ // };
+ // await super.testUsageMetadataStreaming(callOptions);
+ // }
+
+ // async invokeWithCacheReadInput(stream: boolean = false): Promise {
+ // const readme = readFileSync(join(REPO_ROOT_DIR, "README.md"), "utf-8");
+
+ // const input = `What's langchain? Here's the langchain README:
+
+ // ${readme}
+ // `;
+ // const llm = new ChatDeepSeek({ model: "deepseek-chat", streamUsage: true });
+ // await invoke(llm, input, stream);
+ // // invoke twice so first invocation is cached
+ // return invoke(llm, input, stream);
+ // }
+
+ async testInvokeMoreComplexTools() {
+ this.skipTestMessage(
+ "testInvokeMoreComplexTools",
+ "ChatDeepSeek",
+ "Deepseek does not support tool schemas which contain object with unknown/any parameters." +
+ "\nDeepseek only supports objects in schemas when the parameters are defined."
+ );
+ }
+}
+
+const testClass = new ChatDeepSeekStandardIntegrationTests();
+
+test("ChatDeepSeekStandardIntegrationTests", async () => {
+ const testResults = await testClass.runTests();
+ expect(testResults).toBe(true);
+});
+
+// async function invoke(
+// chatModel: ChatDeepSeek,
+// input: BaseLanguageModelInput,
+// stream: boolean
+// ): Promise {
+// if (stream) {
+// let finalChunks: AIMessageChunk | undefined;
+
+// // Stream the response for a simple "Hello" prompt
+// for await (const chunk of await chatModel.stream(input)) {
+// // Concatenate chunks to get the final result
+// finalChunks = finalChunks ? concat(finalChunks, chunk) : chunk;
+// }
+// return finalChunks as AIMessage;
+// } else {
+// return chatModel.invoke(input);
+// }
+// }
diff --git a/libs/langchain-deepseek/src/tests/chat_models.standard.test.ts b/libs/langchain-deepseek/src/tests/chat_models.standard.test.ts
new file mode 100644
index 000000000000..3c29adad80bf
--- /dev/null
+++ b/libs/langchain-deepseek/src/tests/chat_models.standard.test.ts
@@ -0,0 +1,39 @@
+/* eslint-disable no-process-env */
+import { test, expect } from "@jest/globals";
+import { ChatModelUnitTests } from "@langchain/standard-tests";
+import { AIMessageChunk } from "@langchain/core/messages";
+import { ChatDeepSeek, ChatDeepSeekCallOptions } from "../chat_models.js";
+
+class ChatDeepSeekStandardUnitTests extends ChatModelUnitTests<
+ ChatDeepSeekCallOptions,
+ AIMessageChunk
+> {
+ constructor() {
+ super({
+ Cls: ChatDeepSeek,
+ chatModelHasToolCalling: true,
+ chatModelHasStructuredOutput: true,
+ constructorArgs: {},
+ });
+ // This must be set so method like `.bindTools` or `.withStructuredOutput`
+ // which we call after instantiating the model will work.
+ // (constructor will throw if API key is not set)
+ process.env.DEEPSEEK_API_KEY = "test";
+ }
+
+ testChatModelInitApiKey() {
+ // Unset the API key env var here so this test can properly check
+ // the API key class arg.
+ process.env.DEEPSEEK_API_KEY = "";
+ super.testChatModelInitApiKey();
+ // Re-set the API key env var here so other tests can run properly.
+ process.env.DEEPSEEK_API_KEY = "test";
+ }
+}
+
+const testClass = new ChatDeepSeekStandardUnitTests();
+
+test("ChatDeepSeekStandardUnitTests", () => {
+ const testResults = testClass.runTests();
+ expect(testResults).toBe(true);
+});
diff --git a/libs/langchain-deepseek/tsconfig.cjs.json b/libs/langchain-deepseek/tsconfig.cjs.json
new file mode 100644
index 000000000000..3b7026ea406c
--- /dev/null
+++ b/libs/langchain-deepseek/tsconfig.cjs.json
@@ -0,0 +1,8 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "module": "commonjs",
+ "declaration": false
+ },
+ "exclude": ["node_modules", "dist", "docs", "**/tests"]
+}
diff --git a/libs/langchain-deepseek/tsconfig.json b/libs/langchain-deepseek/tsconfig.json
new file mode 100644
index 000000000000..bc85d83b6229
--- /dev/null
+++ b/libs/langchain-deepseek/tsconfig.json
@@ -0,0 +1,23 @@
+{
+ "extends": "@tsconfig/recommended",
+ "compilerOptions": {
+ "outDir": "../dist",
+ "rootDir": "./src",
+ "target": "ES2021",
+ "lib": ["ES2021", "ES2022.Object", "DOM"],
+ "module": "ES2020",
+ "moduleResolution": "nodenext",
+ "esModuleInterop": true,
+ "declaration": true,
+ "noImplicitReturns": true,
+ "noFallthroughCasesInSwitch": true,
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "useDefineForClassFields": true,
+ "strictPropertyInitialization": false,
+ "allowJs": true,
+ "strict": true
+ },
+ "include": ["src/**/*"],
+ "exclude": ["node_modules", "dist", "docs"]
+}
diff --git a/libs/langchain-deepseek/turbo.json b/libs/langchain-deepseek/turbo.json
new file mode 100644
index 000000000000..d024cee15c81
--- /dev/null
+++ b/libs/langchain-deepseek/turbo.json
@@ -0,0 +1,11 @@
+{
+ "extends": ["//"],
+ "pipeline": {
+ "build": {
+ "outputs": ["**/dist/**"]
+ },
+ "build:internal": {
+ "dependsOn": ["^build:internal"]
+ }
+ }
+}
diff --git a/libs/langchain-groq/src/chat_models.ts b/libs/langchain-groq/src/chat_models.ts
index 488f36280de4..642c3a2cd99c 100644
--- a/libs/langchain-groq/src/chat_models.ts
+++ b/libs/langchain-groq/src/chat_models.ts
@@ -1,4 +1,4 @@
-import { z } from "zod";
+import type { z } from "zod";
import { zodToJsonSchema } from "zod-to-json-schema";
import { NewTokenIndices } from "@langchain/core/callbacks/base";
import { CallbackManagerForLLMRun } from "@langchain/core/callbacks/manager";
diff --git a/libs/langchain-xai/src/chat_models.ts b/libs/langchain-xai/src/chat_models.ts
index 5a1f5177c246..8a948e630945 100644
--- a/libs/langchain-xai/src/chat_models.ts
+++ b/libs/langchain-xai/src/chat_models.ts
@@ -72,9 +72,9 @@ export interface ChatXAIInput extends BaseChatModelParams {
* export XAI_API_KEY="your-api-key"
* ```
*
- * ## [Constructor args](https://api.js.langchain.com/classes/langchain_xai.ChatXAI.html#constructor)
+ * ## [Constructor args](https://api.js.langchain.com/classes/_langchain_xai.ChatXAI.html#constructor)
*
- * ## [Runtime args](https://api.js.langchain.com/interfaces/langchain_xai.ChatXAICallOptions.html)
+ * ## [Runtime args](https://api.js.langchain.com/interfaces/_langchain_xai.ChatXAICallOptions.html)
*
* Runtime args can be passed as the second argument to any of the base runnable methods `.invoke`. `.stream`, `.batch`, etc.
* They can also be passed via `.bind`, or the second arg in `.bindTools`, like shown in the examples below:
diff --git a/yarn.lock b/yarn.lock
index 86ddafa3bfce..e6344eed352e 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -12465,6 +12465,41 @@ __metadata:
languageName: unknown
linkType: soft
+"@langchain/deepseek@workspace:*, @langchain/deepseek@workspace:libs/langchain-deepseek":
+ version: 0.0.0-use.local
+ resolution: "@langchain/deepseek@workspace:libs/langchain-deepseek"
+ dependencies:
+ "@jest/globals": ^29.5.0
+ "@langchain/core": "workspace:*"
+ "@langchain/openai": ^0.4.2
+ "@langchain/scripts": ">=0.1.0 <0.2.0"
+ "@langchain/standard-tests": "workspace:*"
+ "@swc/core": ^1.3.90
+ "@swc/jest": ^0.2.29
+ "@tsconfig/recommended": ^1.0.3
+ "@typescript-eslint/eslint-plugin": ^6.12.0
+ "@typescript-eslint/parser": ^6.12.0
+ dotenv: ^16.3.1
+ dpdm: ^3.12.0
+ eslint: ^8.33.0
+ eslint-config-airbnb-base: ^15.0.0
+ eslint-config-prettier: ^8.6.0
+ eslint-plugin-import: ^2.27.5
+ eslint-plugin-no-instanceof: ^1.0.1
+ eslint-plugin-prettier: ^4.2.1
+ jest: ^29.5.0
+ jest-environment-node: ^29.6.4
+ prettier: ^2.8.3
+ release-it: ^15.10.1
+ rollup: ^4.5.2
+ ts-jest: ^29.1.0
+ typescript: <5.2.0
+ zod: ^3.24.1
+ peerDependencies:
+ "@langchain/core": ">=0.3.0 <0.4.0"
+ languageName: unknown
+ linkType: soft
+
"@langchain/exa@workspace:*, @langchain/exa@workspace:libs/langchain-exa":
version: 0.0.0-use.local
resolution: "@langchain/exa@workspace:libs/langchain-exa"
@@ -12968,7 +13003,7 @@ __metadata:
languageName: unknown
linkType: soft
-"@langchain/openai@>=0.1.0 <0.5.0, @langchain/openai@>=0.2.0 <0.5.0, @langchain/openai@workspace:*, @langchain/openai@workspace:^, @langchain/openai@workspace:libs/langchain-openai":
+"@langchain/openai@>=0.1.0 <0.5.0, @langchain/openai@>=0.2.0 <0.5.0, @langchain/openai@^0.4.2, @langchain/openai@workspace:*, @langchain/openai@workspace:^, @langchain/openai@workspace:libs/langchain-openai":
version: 0.0.0-use.local
resolution: "@langchain/openai@workspace:libs/langchain-openai"
dependencies:
@@ -13170,7 +13205,7 @@ __metadata:
languageName: unknown
linkType: soft
-"@langchain/standard-tests@0.0.0, @langchain/standard-tests@workspace:libs/langchain-standard-tests":
+"@langchain/standard-tests@0.0.0, @langchain/standard-tests@workspace:*, @langchain/standard-tests@workspace:libs/langchain-standard-tests":
version: 0.0.0-use.local
resolution: "@langchain/standard-tests@workspace:libs/langchain-standard-tests"
dependencies:
@@ -27806,6 +27841,7 @@ __metadata:
"@langchain/cohere": "workspace:*"
"@langchain/community": "workspace:*"
"@langchain/core": "workspace:*"
+ "@langchain/deepseek": "workspace:*"
"@langchain/exa": "workspace:*"
"@langchain/google-common": "workspace:*"
"@langchain/google-genai": "workspace:*"