Skill: jiajiaoy/deepseek-v4 (version 1.0.1)

--- name: deepseek-v4 version: 1.0.0 author: jiajiaoy homepage: https://clawhub.ai/skills/deepseek-v4 description: "Use DeepSeek V4 (Flash & Pro) from the command line — one-shot Q&A, thinking mode, multi-turn chat. OpenAI-compatible API, no special CLI needed. Supports deepseek-v4-flash and deepseek-v4-pro." keywords: - deepseek - deepseek v4 - deepseek-v4-flash - deepseek-v4-pro - deepseek api - deepseek cli - deepseek chat - deepseek reasoning - deepseek thinking mode - LLM cli - AI cli - cheap LLM - fast LLM - openai compatible - chinese AI - open source LLM - deepseek v4 flash - deepseek v4 pro - AI model - LLM api - deepseek-reasoner - deepseek-chat - AI assistant cli - command line AI - 深度求索 - DeepSeek接口 metadata: {"clawdbot":{"emoji":"🧠","requires":{"bins":["uv"],"env":["DEEPSEEK_API_KEY"]},"install":[{"id":"uv-brew","kind":"brew","formula":"uv","bins":["uv"],"label":"Install uv (brew)"}]}} --- # DeepSeek V4 Use DeepSeek V4 Flash and Pro directly from your terminal — one-shot questions, deep reasoning with thinking mode, and multi-turn chat. No special CLI required; uses the OpenAI-compatible API via a small Python script. ## Setup **1. Get API key:** https://platform.deepseek.com/api_keys **2. Set environment variable:** ```bash export DEEPSEEK_API_KEY=your_key_here # Add to ~/.zshrc or ~/.bashrc to persist ``` ## Models | Model | ID | Best for | Price (input/output) | |-------|----|----------|---------------------| | V4 Flash ⚡ | `deepseek-v4-flash` | Q&A, writing, coding, summaries | $0.014 / $0.028 per 1M | | V4 Pro 🚀 | `deepseek-v4-pro` | Hard reasoning, math, deep analysis | $0.174 / $0.348 per 1M | Both support **1M token context**. Cache hits are 10× cheaper. Legacy aliases (`deepseek-chat` → flash, `deepseek-reasoner` → pro) deprecated 2026-07-24. ## Commands ### One-shot question (Flash — fast & cheap) ```bash uv run {baseDir}/scripts/ask.py "Explain the difference between V4 Flash and V4 Pro" ``` ### One-shot with Pro model ```bash uv run {baseDir}/scripts/ask.py "Write a merge sort in Rust" --model pro ``` ### Thinking mode (Pro with visible reasoning trace) ```bash uv run {baseDir}/scripts/ask.py "Prove that there are infinitely many primes" --think ``` ### Multi-turn chat ```bash uv run {baseDir}/scripts/chat.py --model flash uv run {baseDir}/scripts/chat.py --model pro --think ``` ### Show models & pricing ```bash uv run {baseDir}/scripts/models.py ``` ## Model Selection Guide Use **Flash** when: - Everyday Q&A and explanations - Writing, editing, translation - Code generation and review - Summarization and classification - Cost is a priority Use **Pro** when: - Multi-step math or logic problems - Complex debugging or architecture decisions - Deep research and analysis - You want to see the reasoning process (--think) ## Tips - **Thinking mode** (`--think`) streams the internal reasoning before the final answer — useful for hard problems and to verify correctness - **System prompt**: `--system "You are a concise assistant"` to set tone - **No streaming**: `--no-stream` for cleaner output in scripts - DeepSeek's API is OpenAI-compatible — any OpenAI SDK works with `base_url="https://api.deepseek.com/v1"`

path: README.md
content: # DeepSeek — V4 Flash & Pro CLI Skill

> Use DeepSeek V4 from the command line — one-shot Q&A, thinking mode, multi-turn chat. No special CLI needed.

[![clawhub](https://img.shields.io/badge/clawhub-deepseek--v4-blue)](https://clawhub.ai/skills/deepseek-v4)
[![deepseek](https://img.shields.io/badge/DeepSeek-V4-green)](https://platform.deepseek.com)
[![openclaw](https://img.shields.io/badge/openclaw-skill-orange)](https://openclaw.ai)

## The Problem

DeepSeek V4 is one of the most capable and affordable LLMs available — but there's no official CLI. Getting started requires writing API boilerplate every time. This skill gives you a clean, one-command interface to DeepSeek V4 Flash and Pro directly from your terminal.

## What it does

**One-shot Q&A** — ask Flash or Pro a question, get a streamed answer  
**Thinking mode** — watch DeepSeek V4-Pro reason through hard problems step by step  
**Multi-turn chat** — interactive conversation with context  
**Model guide** — pricing, model IDs, when to use which  
**No special CLI** — uses `uv` + Python, works anywhere  

## Models

| Model | Speed | Cost | Best for |
|-------|-------|------|----------|
| V4 Flash ⚡ | Fast | $0.014/M in | Q&A, writing, code, summaries |
| V4 Pro 🚀 | Slower | $0.174/M in | Math, hard reasoning, deep analysis |

Both support 1M token context. Cache hits are 10× cheaper.

## Installation

```bash
openclaw install deepseek
export DEEPSEEK_API_KEY=your_key_here
```

Get your API key at [platform.deepseek.com/api_keys](https://platform.deepseek.com/api_keys)

## Usage

```bash
# Quick question (Flash — fast & cheap)
uv run ~/.openclaw/skills/deepseek/scripts/ask.py "What changed in DeepSeek V4?"

# Use Pro for hard problems
uv run ~/.openclaw/skills/deepseek/scripts/ask.py "Explain transformer attention" --model pro

# Thinking mode — see the reasoning process
uv run ~/.openclaw/skills/deepseek/scripts/ask.py "Prove sqrt(2) is irrational" --think

# Interactive chat
uv run ~/.openclaw/skills/deepseek/scripts/chat.py --model flash

# Show models & pricing
uv run ~/.openclaw/skills/deepseek/scripts/models.py
```

## Keywords

DeepSeek · DeepSeek V4 · DeepSeek V4 Flash · DeepSeek V4 Pro · deepseek-v4-flash · deepseek-v4-pro · deepseek api · deepseek cli · deepseek chat · thinking mode · deepseek reasoning · LLM cli · cheap LLM · fast LLM · openai compatible · open source LLM · chinese AI · AI model · command line AI · deepseek-reasoner · deepseek-chat · 深度求索 · DeepSeek接口 · AI assistant cli

---

Built for [OpenClaw](https://openclaw.ai) · Published on [clawhub.ai](https://clawhub.ai/skills/deepseek-v4)


path: scripts/ask.py
content: #!/usr/bin/env python3
# /// script
# requires-python = ">=3.10"
# dependencies = ["openai>=1.0.0"]
# ///
"""
DeepSeek one-shot query.
Usage: uv run ask.py "your question" [--model flash|pro|v4-flash|v4-pro] [--think]
"""

import sys
import argparse
import os

def get_api_key():
    key = os.environ.get("DEEPSEEK_API_KEY")
    if not key:
        print("❌ DEEPSEEK_API_KEY not set.")
        print("   Get your key at: https://platform.deepseek.com/api_keys")
        print("   Then run: export DEEPSEEK_API_KEY=your_key_here")
        sys.exit(1)
    return key

MODEL_MAP = {
    "flash":    "deepseek-v4-flash",
    "pro":      "deepseek-v4-pro",
    "v4-flash": "deepseek-v4-flash",
    "v4-pro":   "deepseek-v4-pro",
    "v3":       "deepseek-v4-flash",  # v4-flash replaces v3/chat
    "r1":       "deepseek-v4-pro",    # v4-pro replaces r1/reasoner
    "chat":     "deepseek-v4-flash",
    "reasoner": "deepseek-v4-pro",
}

PRICING = {
    "deepseek-v4-flash": {"input": 0.014, "output": 0.028, "cache": 0.0014},
    "deepseek-v4-pro":   {"input": 0.174, "output": 0.348, "cache": 0.0174},
}

def main():
    parser = argparse.ArgumentParser(description="Ask DeepSeek a question")
    parser.add_argument("prompt", nargs="?", help="Your question or prompt")
    parser.add_argument("--model", "-m", default="flash",
                        help="Model: flash (default), pro, v4-flash, v4-pro (default: flash)")
    parser.add_argument("--think", action="store_true",
                        help="Enable thinking/reasoning mode (forces pro model)")
    parser.add_argument("--system", "-s", default=None, help="System prompt")
    parser.add_argument("--no-stream", action="store_true", help="Disable streaming")
    args = parser.parse_args()

    if not args.prompt:
        print("Usage: uv run ask.py \"your question\" [--model flash|pro] [--think]")
        sys.exit(1)

    from openai import OpenAI

    model_id = MODEL_MAP.get(args.model, args.model)
    if args.think:
        model_id = "deepseek-v4-pro"

    client = OpenAI(
        [REDACTED_SECRET]),
        base_url="https://api.deepseek.com/v1",
    )

    messages = []
    if args.system:
        messages.append({"role": "system", "content": args.system})
    messages.append({"role": "user", "content": args.prompt})

    model_label = "⚡ Flash" if "flash" in model_id else "🚀 Pro"
    think_label = " [thinking]" if args.think else ""
    print(f"\nDeepSeek {model_label}{think_label}\n{'─' * 40}")

    if args.no_stream:
        response = client.chat.completions.create(
            model=model_id,
            messages=messages,
        )
        content = response.choices[0].message.content
        print(content)

        usage = response.usage
        if usage and model_id in PRICING:
            p = PRICING[model_id]
            cost = (usage.prompt_tokens / 1e6 * p["input"]) + \
                   (usage.completion_tokens / 1e6 * p["output"])
            print(f"\n{'─' * 40}")
            print(f"Tokens: {usage.prompt_tokens} in / {usage.completion_tokens} out | "
                  f"Cost: ~${cost:.5f}")
    else:
        with client.chat.completions.create(
            model=model_id,
            messages=messages,
            stream=True,
        ) as stream:
            full = ""
            reasoning = ""
            in_think = False
            for chunk in stream:
                delta = chunk.choices[0].delta if chunk.choices else None
                if not delta:
                    continue
                # Handle thinking tokens (pro model)
                if hasattr(delta, "reasoning_content") and delta.reasoning_content:
                    if not in_think:
                        print("\n[Thinking...]", flush=True)
                        in_think = True
                    reasoning += delta.reasoning_content
                    print(delta.reasoning_content, end="", flush=True)
                if delta.content:
                    if in_think:
                        print(f"\n{'─' * 40}\n[Answer]", flush=True)
                        in_think = False
                    print(delta.content, end="", flush=True)
                    full += delta.content
            print()

    print()

if __name__ == "__main__":
    main()


path: scripts/chat.py
content: #!/usr/bin/env python3
# /// script
# requires-python = ">=3.10"
# dependencies = ["openai>=1.0.0"]
# ///
"""
DeepSeek multi-turn chat (non-interactive — outputs a full conversation prompt).
Usage: uv run chat.py --model flash|pro [--think] [--history "..."]
"""

import sys
import argparse
import os
import json

def get_api_key():
    key = os.environ.get("DEEPSEEK_API_KEY")
    if not key:
        print("❌ DEEPSEEK_API_KEY not set.")
        print("   Get your key at: https://platform.deepseek.com/api_keys")
        print("   Then: export DEEPSEEK_API_KEY=your_key_here")
        sys.exit(1)
    return key

MODEL_MAP = {
    "flash": "deepseek-v4-flash",
    "pro":   "deepseek-v4-pro",
    "v4-flash": "deepseek-v4-flash",
    "v4-pro":   "deepseek-v4-pro",
}

def main():
    parser = argparse.ArgumentParser(description="DeepSeek multi-turn chat")
    parser.add_argument("--model", "-m", default="flash", help="flash or pro")
    parser.add_argument("--think", action="store_true", help="Thinking mode (pro only)")
    parser.add_argument("--system", "-s", default=None, help="System prompt")
    parser.add_argument("--messages", help="JSON array of prior messages to continue")
    parser.add_argument("--user", help="Next user message to send")
    args = parser.parse_args()

    from openai import OpenAI

    model_id = MODEL_MAP.get(args.model, args.model)
    if args.think:
        model_id = "deepseek-v4-pro"

    client = OpenAI(
        [REDACTED_SECRET]),
        base_url="https://api.deepseek.com/v1",
    )

    messages = []
    if args.system:
        messages.append({"role": "system", "content": args.system})
    if args.messages:
        try:
            messages.extend(json.loads(args.messages))
        except json.JSONDecodeError:
            print("❌ --messages must be valid JSON array")
            sys.exit(1)

    if not args.user:
        model_label = "Flash ⚡" if "flash" in model_id else "Pro 🚀"
        print(f"\nDeepSeek {model_label} — Chat Mode")
        print("Type your message and press Enter. Type 'exit' to quit.\n")
        while True:
            try:
                user_input = input("You: ").strip()
            except (EOFError, KeyboardInterrupt):
                print("\nGoodbye!")
                break
            if not user_input or user_input.lower() in ("exit", "quit", "bye"):
                print("Goodbye!")
                break
            messages.append({"role": "user", "content": user_input})
            print("\nDeepSeek: ", end="", flush=True)
            full = ""
            with client.chat.completions.create(
                model=model_id,
                messages=messages,
                stream=True,
            ) as stream:
                for chunk in stream:
                    delta = chunk.choices[0].delta if chunk.choices else None
                    if delta and delta.content:
                        print(delta.content, end="", flush=True)
                        full += delta.content
            print("\n")
            messages.append({"role": "assistant", "content": full})
    else:
        messages.append({"role": "user", "content": args.user})
        full = ""
        with client.chat.completions.create(
            model=model_id,
            messages=messages,
            stream=True,
        ) as stream:
            for chunk in stream:
                delta = chunk.choices[0].delta if chunk.choices else None
                if delta and delta.content:
                    print(delta.content, end="", flush=True)
                    full += delta.content
        print()
        messages.append({"role": "assistant", "content": full})
        print(f"\n# Continue conversation:\n# --messages '{json.dumps(messages)}'")

if __name__ == "__main__":
    main()


path: scripts/models.py
content: #!/usr/bin/env python3
# /// script
# requires-python = ">=3.10"
# dependencies = []
# ///
"""Show DeepSeek V4 models, pricing, and usage guide."""

def main():
    print("""
DeepSeek V4 — Models & Pricing
═══════════════════════════════════════════════════════

Model              ID                   Input      Output     Context
────────────────── ──────────────────── ─────────  ─────────  ────────
V4 Flash  ⚡       deepseek-v4-flash    $0.014/M   $0.028/M   1M tok
V4 Pro    🚀       deepseek-v4-pro      $0.174/M   $0.348/M   1M tok

Cache hit prices are 10× cheaper (Flash: $0.0014/M, Pro: $0.0174/M)
Limited-time 75% discount on V4-Pro through May 5, 2026.

Legacy model aliases (deprecated 2026-07-24):
  deepseek-chat      →  deepseek-v4-flash
  deepseek-reasoner  →  deepseek-v4-pro

─────────────────────────────────────────────────────
When to use which model:

⚡ V4 Flash  — everyday tasks, fast responses, low cost
   Best for: Q&A, summaries, writing, code generation,
             translation, classification

🚀 V4 Pro   — complex reasoning, hard problems, thinking mode
   Best for: math, coding challenges, deep analysis,
             multi-step reasoning, research

─────────────────────────────────────────────────────
Quick start:

  export DEEPSEEK_API_KEY=your_key_here

  # Ask Flash (fast & cheap)
  uv run {baseDir}/scripts/ask.py "Explain quantum entanglement"

  # Ask Pro
  uv run {baseDir}/scripts/ask.py "Solve this math problem: ..." --model pro

  # Use thinking mode (Pro with reasoning trace)
  uv run {baseDir}/scripts/ask.py "Prove that sqrt(2) is irrational" --think

  # Multi-turn chat
  uv run {baseDir}/scripts/chat.py --model flash

─────────────────────────────────────────────────────
API key: https://platform.deepseek.com/api_keys
Docs:    https://api-docs.deepseek.com
""")

if __name__ == "__main__":
    main()


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (MEDIUM)