DeepSeek 接入 Unity

DeepSeek 可以接入 Unity 并帮助开发。以下是一些关于如何在 Unity 中集成 DeepSeek 的详细信息:

  1. 申请 API Key
    要在 Unity 中使用 DeepSeek,首先需要申请一个 API Key。申请地址为:https://platform.deepseek.com/api_keys。成功申请 Key 后,要在本地妥善保存,因为 DeepSeek 后台只能查看 Key 的列表和 token 余额等信息,完整的 Key 只会在申请成功后显示一次。
  2. 集成 DeepSeek 到 Unity
    有两种主要方式可以在 Unity 中集成 DeepSeek:
    2.1 使用现有的 Unity 包
    有一个现有的 Unity 包可以帮助你无缝集成 DeepSeek-R1 API,这个包提供了高级推理、聊天功能和任务自动化。以下是集成步骤:
    导入包:在 Unity (2019+) 中,通过 Window > Package Manager 导入包,点击 “+” 并选择 “Add package from git URL”,输入 URL:https://github.com/yagizeraslan/DeepSeek-Unity.git。
    配置 API Key:从 DeepSeek 平台获取 API Key,编辑 Config.json 文件中的 api_key 和 endpoint。
    实现功能:将 DeepSeekManager 预制件添加到场景中,使用 DeepSeekApi 和 DeepSeekChat 脚本进行 API 交互。
    示例代码:
csharp 
using DeepSeekUnity;
using System.Threading.Tasks;
using UnityEngine;

public class ExampleScript : MonoBehaviour
{
   
    
    
    private async void Start()
    {
   
    
    
        var message = new DeepSeekMessage
        {
   
    
    
            Role = "user",
            Content =