---
name: DeepSeek API Expert
slug: deepseek-api-expert
category: AI Engineering
description: DeepSeek API Expert covers OpenAI-compatible calls for DeepSeek and similar Chinese LLM APIs, including streaming, retries, timeouts, token counting, and prompt setup. Use it when wiring Python code to chat completions or handling API errors and long outputs.
github: "https://github.com/val1813/kwcode/tree/master/kaiwu/builtin_experts/deepseekapi"
language: Python
stars: 688
forks: 92
install: "npx degit https://github.com/val1813/kwcode/tree/master/kaiwu/builtin_experts/deepseekapi ~/.claude/skills/deepseekapi"
installs_to: ~/.claude/skills/deepseekapi
source_path: kaiwu/builtin_experts/deepseekapi/SKILL.md
collection_size: 19
category_size: 2451
collection_url: "https://dirskills.com/collections/val1813/kwcode"
added: 2026-08-12T04:43:48.309Z
last_synced: 2026-08-12T04:43:48.309Z
canonical_url: "https://dirskills.com/skills/deepseek-api-expert"
---

# DeepSeek API Expert

DeepSeek API Expert covers OpenAI-compatible calls for DeepSeek and similar Chinese LLM APIs, including streaming, retries, timeouts, token counting, and prompt setup. Use it when wiring Python code to chat completions or handling API errors and long outputs.

**Install:**

```bash
npx degit https://github.com/val1813/kwcode/tree/master/kaiwu/builtin_experts/deepseekapi ~/.claude/skills/deepseekapi
```

## README

## 领域知识

- 国产LLM统一用 OpenAI 兼容接口格式（/v1/chat/completions）
- DeepSeek base_url: https://api.deepseek.com，Qwen: https://dashscope.aliyuncs.com/compatible-mode/v1
- 流式响应：stream=True + SSE解析，逐chunk拼接content字段
- token计费：输入/输出分别计价，用tiktoken或API返回的usage字段统计
- 限流处理：捕获429状态码，指数退避重试（1s/2s/4s），最多3次
- 超时设置：连接超时10s，读取超时60s（长文本生成可加到120s）
- prompt工程：system message定角色，few-shot放user/assistant交替
- 温度参数：代码生成用0.0-0.3，创意文本用0.7-1.0
- 错误处理：区分可重试错误（429/500/503）和不可重试错误（400/401）
- 长文本：超过模型max_tokens时自动截断或分段处理

## 经验规则（自动生成）
