本页还没有译文
本页 22 段还没译成한국어,下面显示的是英文原文。ChatDeepSeek integration
还没翻译译自英文(docs.langchain.com)本页 22 段都还没译
This will help you getting started with ChatDeepSeek chat models. For detailed documentation of all ChatDeepSeek features and configurations head to the API reference.
Overview
Integration details
| Class | Package | Serializable | PY support | Downloads | Version |
|---|---|---|---|---|---|
ChatDeepSeek | @langchain/deepseek | beta | ✅ |
Model features
See the links in the table headers below for guides on how to use specific features.
| Tool calling | Structured output | Image input | Audio input | Video input | Token-level streaming | Token usage | Logprobs |
|---|---|---|---|---|---|---|---|
| ✅ | ✅ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ |
Note that as of 1/27/25, tool calling and structured output are not currently supported for deepseek-reasoner.
Setup
To access DeepSeek models you'll need to create a DeepSeek account, get an API key, and install the @langchain/deepseek integration package.
You can also access the DeepSeek API through providers like Ollama.
Credentials
Head to deepseek.com to sign up to DeepSeek and generate an API key. Once you've done this set the DEEPSEEK_API_KEY environment variable:
export DEEPSEEK_API_KEY="your-api-key"If you want to get automated tracing of your model calls you can also set your LangSmith API key by uncommenting below:
# export LANGSMITH_TRACING="true"
# export LANGSMITH_API_KEY="your-api-key"Installation
The LangChain ChatDeepSeek integration lives in the @langchain/deepseek package:
npm install @langchain/deepseek @langchain/coreyarn add @langchain/deepseek @langchain/corepnpm add @langchain/deepseek @langchain/coreInstantiation
Now we can instantiate our model object and generate chat completions:
import { ChatDeepSeek } from "@langchain/deepseek";
const llm = new ChatDeepSeek({
model: "deepseek-reasoner",
temperature: 0,
// other params...
})const aiMsg = await llm.invoke([
[
"system",
"You are a helpful assistant that translates English to French. Translate the user sentence.",
],
["human", "I love programming."],
])
aiMsgAIMessage {
"id": "e2874482-68a7-4552-8154-b6a245bab429",
"content": "J'adore la programmation.",
"additional_kwargs": {
"reasoning_content": "..."
},
"response_metadata": {
"tokenUsage": {
"promptTokens": 23,
"completionTokens": 7,
"totalTokens": 30
},
"finish_reason": "stop",
"model_name": "deepseek-reasoner",
"usage": {
"prompt_tokens": 23,
"completion_tokens": 7,
"total_tokens": 30,
"prompt_tokens_details": {
"cached_tokens": 0
},
"prompt_cache_hit_tokens": 0,
"prompt_cache_miss_tokens": 23
},
"system_fingerprint": "fp_3a5770e1b4"
},
"tool_calls": [],
"invalid_tool_calls": [],
"usage_metadata": {
"output_tokens": 7,
"input_tokens": 23,
"total_tokens": 30,
"input_token_details": {
"cache_read": 0
},
"output_token_details": {}
}
}console.log(aiMsg.content)J'adore la programmation.API reference
For detailed documentation of all ChatDeepSeek features and configurations head to the API reference.