### Initialize and Run AstrBot Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/astrbot Initialize AstrBot environment for the first time and then start the AstrBot service. The run command checks for existing installations. ```bash astrbot init # 仅首次使用时执行,用于初始化环境。这个指令会将 AstrBot 安装到当前终端所在的目录。 ``` ```bash astrbot run # 启动 AstrBot。这个指令会检测当前目录是否安装了 AstrBot,如果未安装会提示使用 `astrbot init` 初始化。 ``` -------------------------------- ### Get User Balance Example Source: https://api-docs.deepseek.com/zh-cn/api/get-user-balance This example shows the structure of a successful response when querying user balance details. ```json { "is_available": true, "balance_infos": [ { "currency": "CNY", "total_balance": "110.00", "granted_balance": "10.00", "topped_up_balance": "100.00" } ] } ``` -------------------------------- ### Start Reasonix Agent Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/reasonix Navigate to your project directory and execute the Reasonix agent using npx. This command initiates the agent without requiring global installation. ```bash cd /path/to/my-project npx reasonix code ``` -------------------------------- ### Clone AstrBot Repository Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/astrbot Clone the AstrBot repository to start the Docker installation process. ```bash git clone https://github.com/AstrBotDevs/AstrBot --depth 1 ``` ```bash cd AstrBot ``` -------------------------------- ### Migrate to DeepSeek Provider in OpenClaw Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/openclaw Run this command to re-enter the configuration phase and switch to the DeepSeek provider if you have an existing OpenClaw installation. Follow the on-screen prompts to complete the setup. ```bash openclaw onboard --install-daemon ``` -------------------------------- ### Install Crush Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/crush Install the Crush agent globally using npm. Verify the installation by checking the version. ```bash npm install -g @charmland/crush ``` ```bash crush --version ``` -------------------------------- ### Python FIM Completion Example Source: https://api-docs.deepseek.com/zh-cn/guides/fim_completion This example demonstrates how to use the FIM completion API in Python. It provides the beginning and end of a Fibonacci function and asks the model to complete the middle part. Ensure you have the `openai` library installed and replace `` with your actual API key. ```python from openai import OpenAI client = OpenAI( api_key="", base_url="https://api.deepseek.com/beta", ) response = client.completions.create( model="deepseek-v4-pro", prompt="def fib(a):", suffix=" return fib(a-1) + fib(a-2)", max_tokens=128 ) print(response.choices[0].text) ``` -------------------------------- ### Start OpenCode Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/opencode Execute this command to launch the OpenCode application. ```bash opencode ``` -------------------------------- ### Install Pi Coding Agent Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/pi_mono Install the Pi coding agent globally using npm. Verify the installation by checking the version. ```bash npm install -g @mariozechner/pi-coding-agent ``` ```bash pi --version ``` -------------------------------- ### Install Pi using Official Script (Linux/macOS) Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/pi_mono Alternative installation method for Linux and macOS users using a curl script. ```bash curl -fsSL https://pi.dev/install.sh | sh ``` -------------------------------- ### Install OpenClaw on Linux/Mac Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/openclaw Execute this command to install OpenClaw using the installation script on Linux or macOS systems. ```bash curl -fsSL https://openclaw.ai/install.sh | bash ``` -------------------------------- ### Install OpenClaw (Windows) Source: https://api-docs.deepseek.com/zh-cn/guides/coding_agents Install OpenClaw on Windows using the provided installation script via PowerShell. ```powershell iwr -useb https://openclaw.ai/install.ps1 | iex ``` -------------------------------- ### Install Anthropic SDK Source: https://api-docs.deepseek.com/zh-cn/guides/anthropic_api Install the official Anthropic SDK using pip. This is the first step to interact with the Anthropic API. ```bash pip install anthropic ``` -------------------------------- ### Install OpenClaw on Windows Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/openclaw Execute this command to install OpenClaw using the installation script on Windows systems. ```powershell iwr -useb https://openclaw.ai/install.ps1 | iex ``` -------------------------------- ### Start Langcli Session Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/langcli Launch Langcli from your terminal. After starting, you can interact with it by typing commands like 'hi'. ```bash # 启动Langcli langcli # 之后在回话中输入: hi ``` -------------------------------- ### Start Deep Code in Project Directory Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/deepcode Navigate to your project directory and launch the Deep Code CLI to start an AI coding session. ```bash cd /path/to/my-project deepcode ``` -------------------------------- ### Install OpenClaw (Linux/Mac) Source: https://api-docs.deepseek.com/zh-cn/guides/coding_agents Install OpenClaw on Linux or Mac using the provided installation script via curl. ```bash curl -fsSL https://openclaw.ai/install.sh | bash ``` -------------------------------- ### Install GitHub Copilot CLI Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/copilot_cli Install the GitHub Copilot CLI globally using npm. Requires Node.js 22 or higher. ```bash npm install -g @github/copilot ``` -------------------------------- ### Install Claude Code using npm Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/claude_code Install Claude Code globally using npm. Ensure you have Node.js 18+ installed. Windows users should also install Git for Windows. ```bash npm install -g @anthropic-ai/claude-code ``` -------------------------------- ### Start OpenClaw Dashboard Source: https://api-docs.deepseek.com/zh-cn/guides/coding_agents Launch the OpenClaw Web UI to interact with the AI assistant. ```bash openclaw dashboard ``` -------------------------------- ### Install Langcli (macOS/Linux/WSL) Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/langcli Use this command for a quick installation of Langcli on macOS, Linux, and WSL environments. A terminal restart is recommended after installation. ```bash bash -c "$(curl -fsSL https://assets.langcli.com/installation/install-langcli.sh)" ``` -------------------------------- ### Manual Langcli Installation Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/langcli Install Langcli globally using npm. Ensure Node.js version 20 or higher is installed before running this command. ```bash npm i -g langcli-com ``` -------------------------------- ### Install AstrBot on Windows Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/astrbot Use this command to install AstrBot on Windows systems. ```powershell iwr -useb https://docs.astrbot.app/install.ps1 | iex ``` -------------------------------- ### Install AstrBot on macOS/Linux Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/astrbot Use this command to install AstrBot on macOS and Linux systems. ```bash curl -LsSf https://docs.astrbot.app/install.sh | bash ``` -------------------------------- ### Start Claude Code in Project Directory Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/claude_code After configuring environment variables, navigate to your project directory and run the 'claude' command to start the AI programming assistant. ```bash cd /path/to/my-project claude ``` -------------------------------- ### Start OpenClaw Web UI Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/openclaw Open the Web UI to interact with OpenClaw in the Chat page. ```bash openclaw dashboard ``` -------------------------------- ### Access V3.1-Terminus using OpenAI-compatible API (Python) Source: https://api-docs.deepseek.com/zh-cn/guides/comparison_testing This Python script demonstrates how to use the OpenAI SDK to interact with the V3.1-Terminus model. Install the SDK using `pip3 install openai` and set your `DEEPSEEK_API_KEY` environment variable. ```python # Please install OpenAI SDK first: `pip3 install openai` import os from openai import OpenAI client = OpenAI( api_key=os.environ.get('DEEPSEEK_API_KEY'), base_url="https://api.deepseek.com/v3.1_terminus_expires_on_20251015") response = client.chat.completions.create( model="deepseek-chat", messages=[ {"role": "system", "content": "You are a helpful assistant"}, {"role": "user", "content": "Hello"}, ], stream=False ) print(f"Model is: {response.model}") print(f"Output is: {response.choices[0].message.content}") ``` -------------------------------- ### Install Langcli (Windows) Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/langcli For Windows users, run this command in an Administrator PowerShell to install Langcli. It downloads and executes a batch script. ```powershell cmd /c "curl -fsSL -o %TEMP%\install-langcli.bat https://assets.langcli.com/installation/install-langcli.bat && %TEMP%\install-langcli.bat" ``` -------------------------------- ### Access V3.1-Terminus using OpenAI-compatible API (Node.js) Source: https://api-docs.deepseek.com/zh-cn/guides/comparison_testing This Node.js script shows how to use the OpenAI SDK to communicate with the V3.1-Terminus model. Install the SDK using `npm install openai` and ensure the `DEEPSEEK_API_KEY` environment variable is set. ```javascript // Please install OpenAI SDK first: `npm install openai` import OpenAI from "openai"; const openai = new OpenAI({ baseURL: 'https://api.deepseek.com/v3.1_terminus_expires_on_20251015', apiKey: process.env.DEEPSEEK_API_KEY, }); async function main() { const completion = await openai.chat.completions.create({ messages: [ { role: "system", content: "You are a helpful assistant." }, { role: "user", content: "Hello!."} ], model: "deepseek-chat", }); console.log("Model is:", completion.model) console.log("Output is:", completion.choices[0].message.content); } main(); ``` -------------------------------- ### Using OpenAI Compatible API to Access V3.1-Terminus Source: https://api-docs.deepseek.com/zh-cn/guides/comparison_testing This section provides examples of how to access the V3.1-Terminus model using an OpenAI-compatible API by setting a specific base URL. It includes cURL, Python, and Node.js examples. ```APIDOC ## Using OpenAI Compatible API to Access V3.1-Terminus To access the `DeepSeek-V3.1-Terminus` model using an OpenAI-compatible API, modify your `base_url` to `https://api.deepseek.com/v3.1_terminus_expires_on_20251015`. ### cURL Example ```bash curl https://api.deepseek.com/v3.1_terminus_expires_on_20251015/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer ${DEEPSEEK_API_KEY}" \ -d '{ "model": "deepseek-chat", "messages": [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"} ], "stream": false }' ``` **Output Example:** ```json { "model": "deepseek-v3.1-terminus", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Hello! How can I help you today?" }, "logprobs": null, "finish_reason": "stop" } ] } ``` ### Python Example ```python # Please install OpenAI SDK first: `pip3 install openai` import os from openai import OpenAI client = OpenAI( api_key=os.environ.get('DEEPSEEK_API_KEY'), base_url="https://api.deepseek.com/v3.1_terminus_expires_on_20251015") response = client.chat.completions.create( model="deepseek-chat", messages=[ {"role": "system", "content": "You are a helpful assistant"}, {"role": "user", "content": "Hello"}, ], stream=False ) print(f"Model is: {response.model}") print(f"Output is: {response.choices[0].message.content}") ``` **Sample Output:** ``` Model is: deepseek-v3.1-terminus Output is: Hello! How can I help you today? ``` ### Node.js Example ```javascript // Please install OpenAI SDK first: `npm install openai` import OpenAI from "openai"; const openai = new OpenAI({ baseURL: 'https://api.deepseek.com/v3.1_terminus_expires_on_20251015', apiKey: process.env.DEEPSEEK_API_KEY, }); async function main() { const completion = await openai.chat.completions.create({ messages: [ { role: "system", content: "You are a helpful assistant." }, { role: "user", content: "Hello!."} ], model: "deepseek-chat", }); console.log("Model is:", completion.model) console.log("Output is:", completion.choices[0].message.content); } main(); ``` **Output Example:** ``` Model is: deepseek-v3.1-terminus Output is: Hello! How can I help you today? ``` **Verification:** You can verify that you are using the V3.1-Terminus model by checking the `model` field in the API response. ``` -------------------------------- ### Upgrade OpenCode Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/opencode Run this command to upgrade your OpenCode installation to the latest version, which is required for compatibility. ```bash opencode upgrade ``` -------------------------------- ### 初始化 nanobot 配置文件 Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/nanobot 运行 `nanobot onboard` 命令来初始化 nanobot 的配置文件。配置文件路径因操作系统而异。 ```bash nanobot onboard ``` -------------------------------- ### Run Pi and Select Model Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/pi_mono Navigate to your project directory and run the `pi` command. Use `/model` to switch to DeepSeek models. ```bash cd /path/to/my-project pi ``` -------------------------------- ### Verify Claude Code Installation Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/claude_code After installation, run this command to verify that Claude Code is installed correctly. It should display the version number if the installation was successful. ```bash claude --version ``` -------------------------------- ### Complete Python Example for Tool Calls Source: https://api-docs.deepseek.com/zh-cn/guides/tool_calls Demonstrates a full Python implementation for fetching user's current weather information using Tool Calls. Requires user-defined function implementations for tools. ```python from openai import OpenAI def send_messages(messages): response = client.chat.completions.create( model="deepseek-v4-pro", messages=messages, tools=tools ) return response.choices[0].message client = OpenAI( api_key="", base_url="https://api.deepseek.com", ) tools = [ { "type": "function", "function": { "name": "get_weather", "description": "Get weather of a location, the user should supply a location first.", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g. San Francisco, CA", } }, "required": ["location"] }, } }, ] messages = [{"role": "user", "content": "How's the weather in Hangzhou, Zhejiang?"}] message = send_messages(messages) print(f"User>\t {messages[0]['content']}") tool = message.tool_calls[0] messages.append(message) messages.append({"role": "tool", "tool_call_id": tool.id, "content": "24℃"}) message = send_messages(messages) print(f"Model>\t {message.content}") ``` -------------------------------- ### Initializing Deepseek API Client Source: https://api-docs.deepseek.com/zh-cn/guides/thinking_mode Sets up the Deepseek API client using environment variables for the API key and base URL. ```python client = OpenAI( api_key=os.environ.get('DEEPSEEK_API_KEY'), base_url=os.environ.get('DEEPSEEK_BASE_URL'), ) ``` -------------------------------- ### Run Crush and Select Model Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/crush Navigate to your project directory and run the 'crush' command. Use Ctrl+L or '/model' to open the model switcher and select a DeepSeek model. ```bash cd /path/to/my-project crush ``` -------------------------------- ### Install Deep Code CLI Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/deepcode Install the Deep Code command-line interface globally using npm. Ensure Node.js version 18 or higher is installed. ```bash npm install -g @vegamo/deepcode-cli ``` -------------------------------- ### 安装 nanobot Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/nanobot 使用 `uv tool install` 命令安装 nanobot。在 Windows 上,请确保将 `.local\bin` 添加到 PATH 环境变量,或使用 `uv tool update-shell` 更新终端。 ```bash uv tool install nanobot-ai ``` ```powershell $env:PATH = "$env:USERPROFILE\.local\bin;$env:PATH" ``` ```bash uv tool update-shell ``` ```bash nanobot --version ``` -------------------------------- ### Start AstrBot with Docker Compose Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/astrbot Start the AstrBot services in detached mode using Docker Compose. ```bash sudo docker compose up -d ``` -------------------------------- ### Verify Deep Code Installation Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/deepcode Check if the Deep Code CLI was installed successfully by running the version command. ```bash deepcode --version ``` -------------------------------- ### Connect to DeepSeek in OpenCode Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/opencode Within OpenCode, use the /connect command followed by 'deepseek' to initiate the connection to the DeepSeek provider. You will then be prompted to enter your DeepSeek API Key and select the DeepSeek-V4-Pro model. ```bash /connect ``` -------------------------------- ### Start Copilot CLI Source: https://api-docs.deepseek.com/zh-cn/quick_start/agent_integrations/copilot_cli Launch the Copilot CLI after configuring the environment variables. This enables Agent mode, tool calls, and MCP powered by DeepSeek. ```bash copilot ``` -------------------------------- ### Strict Mode Tool Definition Example Source: https://api-docs.deepseek.com/zh-cn/guides/tool_calls An example of defining a tool with the 'strict' attribute set to true for strict adherence to JSON Schema format in Beta. ```json { "type": "function", "function": { "name": "get_weather", "strict": true, "description": "Get weather of a location, the user should supply a location first.", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g. San Francisco, CA", } }, "required": ["location"], "additionalProperties": false } } } ``` -------------------------------- ### Call DeepSeek API with Python SDK Source: https://api-docs.deepseek.com/zh-cn This Python script demonstrates how to use the OpenAI SDK to interact with the DeepSeek API. Install the SDK using 'pip3 install openai'. ```python # Please install OpenAI SDK first: `pip3 install openai` import os from openai import OpenAI client = OpenAI( api_key=os.environ.get('DEEPSEEK_API_KEY'), base_url="https://api.deepseek.com") response = client.chat.completions.create( model="deepseek-v4-pro", messages=[ {"role": "system", "content": "You are a helpful assistant"}, {"role": "user", "content": "Hello"}, ], stream=False, reasoning_effort="high", extra_body={"thinking": {"type": "enabled"}} ) print(response.choices[0].message.content) ```