2026 最丝滑:Vite8.3 跑 DeepSeek-V4.1-Flash 搭建网页web版流式输出AI对话模板,打字机效果太上头!
Vue3 + Vite8 集成 DeepSeek-V4.1-Flash(SSE 流式 / Markdown / 代码高亮)




申请一个deepseek apikey,替换掉项目根目录下.env文件里的key。

# title
VITE_APP_TITLE = 'Vue3-Web-DeepSeek'
# port
VITE_PORT = 3001
# 运行时自动打开浏览器
VITE_OPEN = true
# 开启https
VITE_HTTPS = false
# 是否删除生产环境 console
VITE_DROP_CONSOLE = true
# DeepSeek API配置
VITE_DEEPSEEK_API_KEY = 替换为你的 API Key
VITE_DEEPSEEK_BASE_URL = https://api.deepseek.com



<script setup>
import Sidebar from '@/layouts/components/sidebar/index.vue'
</script>
<template>
<div class="vu__container">
<div class="vu__layout flexbox flex-col">
<div class="vu__layout-body flex1 flexbox">
<!-- 侧边区域 -->
<Sidebar />
<!-- 主面板区域 -->
<div class="vu__layout-main flex1">
<router-view v-slot="{ Component, route }">
<keep-alive>
<component :is="Component" :key="route.path" />
</keep-alive>
</router-view>
</div>
</div>
</div>
</div>
</template>

const completion = await openai.chat.completions.create({
messages: props.multiConversation ? historySession.value : [{role: 'user', content: editorValue}],
// 对话模型
model: 'deepseek-flash',
// 是否深度思考
thinking: {'type': chatState.thinkingEnabled ? 'enabled' : 'disabled'},
// 流式输出
stream: true,
})









从 0 到 1:Vue3 + Pinia + OpenAI SDK 接入 DeepSeek V4.1-Flash 网页 AI 助手就分享到这里,希望对大家有些帮助!
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。