DeepSeek API 全场景应用指南——编程、文本、绘画一站式解决方案
DeepSeek接入CherryStudioDeepSeek+word:AI处理文本的智能助手DeepSeek+Continue+JetBrains:AI编程新体验DeepSeek+AI绘画:DeepSeek书写提示词,AI绘画创作,激发灵感,无限创作
在人工智能技术飞速发展的今天,DeepSeek 作为一款强大的 AI 工具,正在以其灵活、高效的问题处理能力赋能各行各业。无论是编程开发、文档处理,还是创意绘画,DeepSeek 都能通过 API 接入,帮助用户大幅提升效率,激发无限潜能。本文将为您详细介绍如何将 DeepSeek API 接入各种应用场景,打造专属于您的 AI 生产力工具。
目录
三、DeepSeek API 接入 Word:AI 处理文本的智能助手
四、DeepSeek API + Continue 接入 JetBrains:AI 编程新体验
五、DeepSeek API+AI绘画:DeepSeek书写提示词,AI绘画创作
一、API的获取
平台名称 | 地址 | 版本 | 输入/每百万tokens | 输出/每百万tokens | 连接 | 备注 |
---|---|---|---|---|---|---|
OpenRouter | DeepSeek: R1 (free) – Run with an API | OpenRouter | 满血R1 | ¥0 | ¥0 | 直连 | 免费API |
天翼云 | 一站式智算服务平台 | 满血R1 | 计费说明:计费说明-一站式智算服务平台 - 天翼云 | 直连 | 两周 2500万Tokens免费使用 | |
腾讯云 | 登录 - 腾讯云 | 满血R1 | ¥4 | ¥16 | 直连 | 2月25日结束前免费 |
百度智能云,千帆 | 百度智能云千帆大模型平台 | 满血R1 | ¥2 | ¥8 | 直连 | 2月18日结束前免费 |
英伟达(疑似降速) | deepseek-r1 Model by Deepseek-ai | NVIDIA NIM | 满血R1 | 免费1000次 | 免费1000次 | 直连 | 免费1000次调用,偶尔会不调用思考部分 |
华为云 | https://console.huaweicloud.com/modelarts/ | 满血R1 | 计费说明:ModelArts计费模式概述_AI开发平台ModelArts_华为云 | 直连 | 免费送200万tokens,包年/包月 的计费方式 | |
火山方舟 | 火山方舟-火山引擎 | 满血R1 | ¥4 | ¥16 | 直连 | 免费50万token,2月18日结束前半价优惠 |
阿里云百炼 | 阿里云登录 - 欢迎登录阿里云,安全稳定的云计算服务平台 | 满血R1 | ¥4 | ¥16 | 直连 | 送 100 万 tokens |
微软 Azure | Azure AI Foundry | 满血R1 | 暂时免费 | 暂时免费 | 直连 | 需要VISA信用卡 |
Together ai | https://api.together.xyz/ | 满血R1 | $7 | $7 | 直连 | 免费1刀 需要VISA信用卡 |
硅基流动 | Models | 满血R1 | ¥4 | ¥16 | 直连 | 送14块,但是很卡,通过邀请新用户也可以获得一定的tokens |
DeepSeek官网 | DeepSeek | 满血R1 |
¥4(缓存未命中) ¥1(缓存命中) |
¥16 | 直连 | 之前新用户注册时送了10块的额度(一个月有效期),目前暂停了充值服务,不过之前赠送的额度还可以继续使用 |
二、DeepSeek接入Cherry-Studio
这款客户端工具可以接入各大服务商的API,使用非常方便。
类似的工具还有很多,比如Chatbox等等。
在它的官网有提供下载地址,同时为了也提供了网盘下载的渠道
Cherry-studio百度网盘为您提供文件的网络备份、同步和分享服务。空间大、速度快、安全稳固,支持教育网加速,支持手机端。注册使用百度网盘即可享受免费存储空间
https://pan.baidu.com/s/1EgMxS-pdb4wq1zMdxjHNpw?pwd=mcy2CherryStudio官方版下载丨最新版下载丨绿色版下载丨APP下载-123云盘123云盘为您提供CherryStudio最新版正式版官方版绿色版下载,CherryStudio安卓版手机版apk免费下载安装到手机,支持电脑端一键快捷安装
https://www.123865.com/s/IvG7jv-YEahd
Cherry-studio夸克网盘是夸克推出的一款云服务产品,功能包括云存储、高清看剧、文件在线解压、PDF一键转换等。通过夸克网盘可随时随地管理和使用照片、文档、手机资料,目前支持Android、iOS、PC、iPad。https://pan.quark.cn/s/377075e69c83
下载好之后是这样的,只需要在设置中配置API和APIkey就可以使用了
Cherry-Studio配置在线模型
下面以siliconflow(硅基流动)为例,硅基流动目前是注册送14元的额度,如果邀请了新用户,又可以送14元的额度。
①复制APIKEY
②将APIKEY填写到Cherry-Studio中,连接成功后就可以开始使用了
③如果没有想要用的模型,可以自己添加模型
成功配置自己想要的模型,开始对话。
开启显示消耗的token数量
三、DeepSeek API 接入 Word:AI 处理文本的智能助手
开启开发者工具
文件->更多->选项->自定义功能区->勾选开发者工具
打开信任中心
文件->更多->选项->信任中心->点击信任中心设置->宏设置->启用所有宏
创建宏,写入相关代码
点击开发者工具,点击Visual Basic
网上关于这种代码很多,这里贴几个网上找的
最重要的是要把自己的APIKey替换上去,否则无法生效
①deepseek-v3
Function CallDeepSeekAPI(api_key As String, inputText As String) As String
Dim API As String
Dim SendTxt As String
Dim Http As Object
Dim status_code As Integer
Dim response As String
API = "https://api.deepseek.com/chat/completions"
SendTxt = "{""model"": ""deepseek-chat"", ""messages"": [{""role"":""system"", ""content"":""你是一个乐于助人的AI助手,请根据用户的问题给出详细的解答。""}, {""role"":""user"", ""content"":""" & inputText & """}], ""stream"": false}"
Set Http = CreateObject("MSXML2.XMLHTTP")
With Http
.Open "POST", API, False
.setRequestHeader "Content-Type", "application/json"
.setRequestHeader "Authorization", "Bearer " & api_key
.send SendTxt
status_code = .Status
response = .responseText
End With
' 弹出窗口显示 API 响应(调试用)
' MsgBox "API Response: " & response, vbInformation, "Debug Info"
If status_code = 200 Then
CallDeepSeekAPI = response
Else
CallDeepSeekAPI = "Error: " & status_code & " - " & response
End If
Set Http = Nothing
End Function
Sub DeepSeekV3()
Dim api_key As String
Dim inputText As String
Dim response As String
Dim regex As Object
Dim matches As Object
Dim originalSelection As Object
api_key = "替换为你的api key"
If api_key = "" Then
MsgBox "Please enter the API key."
Exit Sub
ElseIf Selection.Type <> wdSelectionNormal Then
MsgBox "Please select text."
Exit Sub
End If
' 保存原始选中的文本
Set originalSelection = Selection.Range.Duplicate
inputText = Replace(Replace(Replace(Replace(Replace(Selection.text, "\", "\\"), vbCrLf, ""), vbCr, ""), vbLf, ""), Chr(34), "\""")
response = CallDeepSeekAPI(api_key, inputText)
If Left(response, 5) <> "Error" Then
Set regex = CreateObject("VBScript.RegExp")
With regex
.Global = True
.MultiLine = True
.IgnoreCase = False
.Pattern = """content"":""(.*?)"""
End With
Set matches = regex.Execute(response)
If matches.Count > 0 Then
response = matches(0).SubMatches(0)
response = Replace(Replace(response, """", Chr(34)), """", Chr(34))
' 取消选中原始文本
Selection.Collapse Direction:=wdCollapseEnd
' 将内容插入到选中文字的下一行
Selection.TypeParagraph ' 插入新行
Selection.TypeText text:=response
' 将光标移回原来选中文本的末尾
originalSelection.Select
Else
MsgBox "Failed to parse API response.", vbExclamation
End If
Else
MsgBox response, vbCritical
End If
End Sub
②deepseek-R1
Function CallDeepSeekAPI(api_key As String, inputText As String) As String
Dim API As String
Dim SendTxt As String
Dim Http As Object
Dim status_code As Integer
Dim response As String
API = "https://api.deepseek.com/chat/completions"
SendTxt = "{""model"": ""deepseek-reasoner"", ""messages"": [{""role"":""system"", ""content"":""你是一个乐于助人的AI助手,请根据用户的问题给出详细的解答。""}, {""role"":""user"", ""content"":""" & inputText & """}], ""stream"": false}"
Set Http = CreateObject("MSXML2.XMLHTTP")
With Http
.Open "POST", API, False
.setRequestHeader "Content-Type", "application/json"
.setRequestHeader "Authorization", "Bearer " & api_key
.send SendTxt
status_code = .Status
response = .responseText
End With
' 弹出窗口显示 API 响应(调试用)
' MsgBox "API Response: " & response, vbInformation, "Debug Info"
If status_code = 200 Then
CallDeepSeekAPI = response
Else
CallDeepSeekAPI = "Error: " & status_code & " - " & response
End If
Set Http = Nothing
End Function
Sub DeepSeekR1()
Dim api_key As String
Dim inputText As String
Dim response As String
Dim regex As Object
Dim reasoningRegex As Object
Dim contentRegex As Object
Dim matches As Object
Dim reasoningMatches As Object
Dim originalSelection As Object
Dim reasoningContent As String
Dim finalContent As String
api_key = "替换为你的api key"
If api_key = "" Then
MsgBox "Please enter the API key."
Exit Sub
ElseIf Selection.Type <> wdSelectionNormal Then
MsgBox "Please select text."
Exit Sub
End If
' 保存原始选中的文本
Set originalSelection = Selection.Range.Duplicate
inputText = Replace(Replace(Replace(Replace(Replace(Selection.text, "\", "\\"), vbCrLf, ""), vbCr, ""), vbLf, ""), Chr(34), "\""")
response = CallDeepSeekAPI(api_key, inputText)
If Left(response, 5) <> "Error" Then
' 创建正则表达式对象来分别匹配推理内容和最终回答
Set reasoningRegex = CreateObject("VBScript.RegExp")
With reasoningRegex
.Global = True
.MultiLine = True
.IgnoreCase = False
.Pattern = """reasoning_content"":""(.*?)"""
End With
Set contentRegex = CreateObject("VBScript.RegExp")
With contentRegex
.Global = True
.MultiLine = True
.IgnoreCase = False
.Pattern = """content"":""(.*?)"""
End With
' 提取推理内容
Set reasoningMatches = reasoningRegex.Execute(response)
If reasoningMatches.Count > 0 Then
reasoningContent = reasoningMatches(0).SubMatches(0)
reasoningContent = Replace(reasoningContent, "\n\n", vbNewLine)
reasoningContent = Replace(reasoningContent, "\n", vbNewLine)
reasoningContent = Replace(Replace(reasoningContent, """", Chr(34)), """", Chr(34))
End If
' 提取最终回答
Set matches = contentRegex.Execute(response)
If matches.Count > 0 Then
finalContent = matches(0).SubMatches(0)
finalContent = Replace(finalContent, "\n\n", vbNewLine)
finalContent = Replace(finalContent, "\n", vbNewLine)
finalContent = Replace(Replace(finalContent, """", Chr(34)), """", Chr(34))
' 取消选中原始文本
Selection.Collapse Direction:=wdCollapseEnd
' 插入推理过程(如果存在)
If Len(reasoningContent) > 0 Then
Selection.TypeParagraph
Selection.TypeText "推理过程:"
Selection.TypeParagraph
Selection.TypeText reasoningContent
Selection.TypeParagraph
Selection.TypeText "最终回答:"
Selection.TypeParagraph
End If
' 插入最终回答
Selection.TypeText finalContent
' 将光标移回原来选中文本的末尾
originalSelection.Select
Else
MsgBox "Failed to parse API response.", vbExclamation
End If
Else
MsgBox response, vbCritical
End If
End Sub
然后代码一定要记得保存,否则无法生效
设置图标
文件->文件->更多->选项->自定义功能区
先要新建组,然后自己重命名一下,我这里命名为ChatAI
点击宏
添加宏到ChatAI下面
重命名+设置图标(非必须)
设置好了之后,点击开发者工具,就有相应的按钮,选中文本就可以执行任务了
四、DeepSeek API + Continue 接入 JetBrains:AI 编程新体验
Continue这款插件,在VS Code和JetBrains里面都有,这里以JetBrains为例说说如何在JetBrains IDEA使用
安装Continue插件
在IDEA中的Plugins(插件)中搜索Continue,安装(安装可能失败,可以去JetBrains的官网下载压缩包然后自己手动导入插件)
安装完成后重启IDEA,就可以看到了这个插件
选择Continue提供的模型
自己添加想用的模型
IDEA下载的Continue里面也有硅基流动,但是没有看到硅基流动的deepseek
因此要自己手动添加一下硅基流动里面的deepseek
配置config.json文件
两种打开config.json文件的方式:
①在模型选择这里点击设置小图标,可以打开config.json文件(随便哪一个模型的设置按钮都行)
②第二种打开config.json的方式
打开config.json后主要就是仿照models的文件自己添加一下JSON格式的数据
核心配置参数:
这里面的参数要根据服务商的API文档去填写
apiBase:服务商提供的api地址,硅基流动文档中为https://api.siliconflow.cn/v1/chat/completions,但在这里填https://api.siliconflow.cn或者
https://api.siliconflow.cn/v1
title:这个随便填,自己方便就好
model:这个不能随便填,要严格按照API文档的写,比如硅基流动中的deepseek-R1是deepseek-ai/DeepSeek-R1,而deepseek自己的文档关于deepseek-R1写的是deepseek-reasoner,看服务商文档怎么写就怎么写
provider:这个要按照Continue提供的来写,在provider的value值输入的时候,会自动弹出补全提示,选择相应服务商就行(都是英文)
systemMessage:不填也行,自己可以设置一个基础的模型,比如我这里设置基础模型就是一个AI代码助手
写完后,一定要Ctrl+S保存才能生效,自己添加的模型才能看的到
{
"apiBase": "https://api.siliconflow.cn",
"title": "硅基流动/deepseek-R1",
"model": "deepseek-ai/DeepSeek-R1",
"contextLength": 64000,
"apiKey": "你自己的apiKey",
"provider": "siliconflow",
"systemMessage": "You're a code expert, and you need to solve all the code needs of your users"
},
设置完成后,就可以对话了
五、DeepSeek API+AI绘画:DeepSeek书写提示词,AI绘画创作
使用DeepSeek帮我书写提示词:
超精细日系二次元美少女插画,[银色长发及腰/渐变挑染可替换],九头身完美比例,雪纺露肩lo裙/赛博朋克机械臂可替换,樱花庭院/水晶城堡背景可选,4k分辨率,UHD超清细节,赛璐璐风格,hololive画风,明暗交界线处理,发丝根根分明,瞳孔透光反射,水玉光晕特效
然后交给豆包创作:
大家快去试试吧!!!
更多推荐
所有评论(0)