DeepSeek 开发者平台的命令行工具 —— DeepSeek 版的
ant。仓库名
seek-cli,安装后终端命令为短名seek(对齐ant惯例:仓库anthropic-cli/ 命令ant)。
seek 把 DeepSeek API 的每一个资源,原样映射成 资源 动作 形式的子命令。它不是聊天机器人,也不是 coding agent,而是 API 的最薄终端外壳:用 typed flags 或管道里的 YAML 构造请求体,用内置 GJSON --transform 抽取响应字段(无需 jq),支持多种输出格式。
设计完全对照 Anthropic 官方的 ant CLI —— 因为调研发现 DeepSeek 官方没有这样的产品,社区也只有聊天/agent 方向的封装,没有一个是"把整个 API 资源化"的薄壳。seek 填的就是这个空位。
| 痛点 | curl |
seek |
|---|---|---|
| 构造请求体 | 手写 JSON 字符串 | typed flags / 管道 YAML,flags 优先合并 |
| 把文件塞进字段 | 手动 base64 | @path 自动内联(二进制自动 base64) |
| 提取响应字段 | 再管道给 jq |
内置 --transform GJSON 查询 |
| 取标量塞进变量 | jq -r |
--raw-output / -r |
| 换格式看 | 自己处理 | --format yaml/json/jsonl/pretty/raw |
Homebrew(macOS / Linux,最简单)
brew install yzfly/tap/seek一键脚本(macOS / Linux)
curl -fsSL https://raw.githubusercontent.com/yzfly/seek-cli/main/install.sh | bash
# 自定义目录: SEEK_INSTALL_DIR=~/bin curl -fsSL .../install.sh | bashgo install(需 Go 1.25+)
go install github.com/yzfly/seek-cli/cmd/seek@latest从源码构建
git clone git@github-yzfly:yzfly/seek-cli.git && cd seek-cli
make build # 产出 ./bin/seek
make install # 安装到 $(go env GOPATH)/bin或直接从 Releases 下载对应平台二进制。验证:
seek --versionDeepSeek 用 API key(无 OAuth)。三种方式,优先级 --api-key > $DEEPSEEK_API_KEY > 配置档:
# 方式一: 保存到配置档 (写入 ~/.config/seek/config.json, 权限 0600)
seek auth login # 交互式输入 key, 并做一次余额验证
seek auth status # 查看当前鉴权状态 (key 脱敏)
# 方式二: 环境变量
export DEEPSEEK_API_KEY=sk-xxxx
# 方式三: 单次命令
seek --api-key sk-xxxx models listseek chat create \
--model deepseek-v4-pro \
--max-tokens 1024 \
--message '{role: user, content: "你好, DeepSeek"}'只想拿到回复正文:
seek chat create --model deepseek-v4-pro \
--user "用一句话解释什么是大语言模型" \
--transform 'choices.0.message.content' -r命令遵循 资源 动作 模式,与 ant 一致:
seek <资源> <动作> [选项]
| 命令 | 说明 | DeepSeek 端点 |
|---|---|---|
seek chat create |
对话补全 | POST /chat/completions |
seek fim create |
FIM 中间填充补全 | POST /beta/completions |
seek models list |
列出可用模型 | GET /models |
seek models retrieve |
取单个模型(本地过滤) | GET /models |
seek balance retrieve |
查询账户余额 | GET /user/balance |
seek auth ... |
管理凭据 | 本地 |
seek profile ... |
管理命名配置档 | 本地 |
seek providers |
列出第三方服务别名 | 本地 |
任意命令加 --help 查看其 flag。
按数据形状分工(与 ant 一致):
seek chat create \
--model deepseek-v4-pro \
--message '{role: user, content: "你好"}' \
--message '{role: assistant, content: "你好, 有什么可以帮你?"}' \
--message '{role: user, content: "讲个笑话"}' \
--temperature 0.7 --max-tokens 512结构化字段用宽松 YAML(键可不加引号),可重复 flag 追加成数组:
seek chat create --model deepseek-v4-pro --user "今天天气?" \
--tool '{type: function, function: {name: get_weather, parameters: {type: object}}}' \
--tool-choice auto管道 JSON 或 YAML 作为完整请求体,flags 仍可覆盖其字段:
cat <<'YAML' | seek chat create --model deepseek-v4-flash
messages:
- role: system
content: 你是一个严谨的翻译。
- role: user
content: Translate to English: 江畔何人初见月
YAML把文件内容塞进任意字符串字段,自动判定文本/二进制:
seek chat create --model deepseek-v4-pro \
--message '{role: user, content: "@./article.md"}' \
--user "总结上面的文章"@file://path强制纯文本@data://path强制 base64\@literal转义字面量@
# 输出格式: auto(默认) / json / jsonl / yaml / pretty / raw
seek models list --format yaml
# GJSON 变换 (list 端点对每个元素生效)
seek models list --transform '{id}' --format jsonl
# 取标量塞进 shell 变量
BAL=$(seek balance retrieve --transform 'balance_infos.0.total_balance' -r)
echo "余额: $BAL"seek chat create --model deepseek-v4-pro --user "写一首短诗" --stream \
--transform 'choices.0.delta.content' -rDeepSeek API 是 OpenAI 兼容的,所以 seek 的 chat / fim / models 命令对任何 OpenAI 兼容端点都通用——阿里云百炼、硅基流动、Moonshot、智谱、OpenRouter、本地 Ollama 等。
内置别名,用 --base-url <别名> 代替一长串 URL:
seek providers # 列出所有内置别名| 别名 | 服务 |
|---|---|
deepseek |
DeepSeek 官方 |
dashscope |
阿里云百炼(兼容模式) |
siliconflow |
硅基流动 |
moonshot |
月之暗面 Kimi |
zhipu |
智谱 GLM |
openrouter |
OpenRouter |
openai |
OpenAI |
ollama |
本地 Ollama |
三种用法:
# 1) 单次命令
seek --base-url dashscope --api-key sk-xxx chat create --model deepseek-v4-pro --user 你好
# 2) 环境变量 (与 $DEEPSEEK_API_KEY / $SEEK_API_KEY 搭配)
export SEEK_BASE_URL=dashscope
seek chat create --model deepseek-v4-pro --user 你好
# 3) 存进 profile (推荐: 别名非密钥, key 仍从环境变量读)
seek profile set base_url dashscope
seek chat create --model deepseek-v4-pro --user 你好--base-url 也接受任意完整 URL(不在别名表里的服务直接传 URL 即可)。
注意:
balance是 DeepSeek 官方特有端点,第三方网关通常不支持(会返回错误)。
seek profile list
seek profile activate work
seek auth login --profile work
seek --profile work chat create --model deepseek-v4-pro --user hi| 选项 | 说明 |
|---|---|
--format |
输出格式 auto/json/jsonl/yaml/pretty/raw/explore |
--transform |
GJSON 路径,抽取/重塑响应 |
-r, --raw-output |
字符串结果去掉 JSON 引号 |
--format-error / --transform-error |
对错误响应单独应用 |
--base-url |
base URL 或 provider 别名(默认 https://api.deepseek.com,$SEEK_BASE_URL) |
--debug |
打印完整 HTTP 请求/响应到 stderr(密钥脱敏) |
--profile |
使用的命名配置档 |
--api-key |
直接传 key($DEEPSEEK_API_KEY) |
# zsh
seek completion zsh > "${fpath[1]}/_seek"
# bash
seek completion bash | sudo tee /etc/bash_completion.d/seekseek --debug chat create --model deepseek-v4-pro --user hi
# stderr 打印请求行、请求头(Authorization 已脱敏)、请求体、响应- 薄壳哲学:不发明新概念,资源/动作一一对应 API,让 shell 成为操控 DeepSeek 的单一控制点,可组合、可被脚本与 agent 治理。
balance与fim是 DeepSeek 特有,ant没有对应。models retrieve:DeepSeek 无单模型端点,seek在本地用 GJSON 从list结果过滤,对用户表现为一致的retrieve语义。
- 协议:MIT
- 作者:云中江树,微信公众号:云中江树