Instructions to use deepseek-ai/DeepSeek-V4.1-Flash with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use deepseek-ai/DeepSeek-V4.1-Flash with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="deepseek-ai/DeepSeek-V4.1-Flash")# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-V4.1-Flash", device_map="auto") - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use deepseek-ai/DeepSeek-V4.1-Flash with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "deepseek-ai/DeepSeek-V4.1-Flash" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "deepseek-ai/DeepSeek-V4.1-Flash", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/deepseek-ai/DeepSeek-V4.1-Flash
- SGLang
How to use deepseek-ai/DeepSeek-V4.1-Flash with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "deepseek-ai/DeepSeek-V4.1-Flash" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "deepseek-ai/DeepSeek-V4.1-Flash", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "deepseek-ai/DeepSeek-V4.1-Flash" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "deepseek-ai/DeepSeek-V4.1-Flash", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use deepseek-ai/DeepSeek-V4.1-Flash with Docker Model Runner:
docker model run hf.co/deepseek-ai/DeepSeek-V4.1-Flash
Running DeepSWE with dsh-minimal and mini-swe-agent
1. Prerequisites
- Docker, running and able to pull images
- Python 3.12+ and uv
- An endpoint and key for any DeepSeek-API-compatible service (the DeepSeek official API is used as the example below)
export DEEPSEEK_API_KEY=sk-your-key-here
export DEEPSEEK_BASE_URL=https://api.deepseek.com
2. Get Pier and DeepSWE
git clone https://github.com/datacurve-ai/pier.git
git -C pier checkout 0c802fc067a425345b24d1c69411aa98acf61a1d
git clone https://github.com/datacurve-ai/deep-swe.git
git -C deep-swe checkout 0b9fabbb63b9104d678fe965e1632f2dd9eaa2ea
3. Patch and install Pier
dsh-minimal.patch ships next to this document. Treat it as a reference patch and adapt it to your own setup.
cd pier
git apply /path/to/dsh-minimal.patch
uv sync
What the patch changes:
- Adds the
dsh-minimalagent, which drives the Harness SDK and folds its event stream into a Pier ATIF trajectory. The SDK artifact is never installed into the image: step 4's--mounts-jsonbind-mounts it read-only into the sandbox, so no trial installs anything. - Appends a runtime-constraints section to the task instruction for both agents: work in
/app, leave/testsalone, no network or package mirror. - Passes test-runner concurrency caps into the container: Docker's
--cpusis only a quota, sonprocinside the container reports the host's core count and test runners size their worker pools from that rather than from the container's share. - Enables IPv6 loopback in the container: Docker disables it by default, so suites that bind
::1are skipped and scored as failures. - Makes
--mounts-jsonadditive instead of replacing the default mounts, keeping the/logsbinds that carry agent logs and collected patches.
4. Run the suite
Both agents take the same task set, concurrency, and --no-delete (which keeps the task images cached between trials). Repeat each run with a different --job-name and average the results.
Each trial's container takes the 2 CPUs and 8 GB its task declares, so size -n against the host's cores and memory.
mini-swe-agent
Pier installs it into each task image at trial time, so no host-side preparation is needed.
uv run pier run \
-p ../deep-swe/tasks \
--agent mini-swe-agent \
--model deepseek/deepseek-flash \
--ak reasoning_effort=max \
--ak cost_limit=0 \
--ae DEEPSEEK_API_KEY="$DEEPSEEK_API_KEY" \
--ae DEEPSEEK_BASE_URL="$DEEPSEEK_BASE_URL" \
-n 32 --no-delete -r 2 --job-name deepswe-mini-run1 -y
--modeltakes a litellm-styleprovider/modelstring.
dsh-minimal
Install the Harness SDK artifact once on the host, then bind-mount it read-only into every container.
mkdir -p ~/dsh-minimal && cd ~/dsh-minimal
uv pip install --target dsh-dist \
--python-version 3.12 --python-platform x86_64-manylinux_2_28 \
'deepseek-harness-sdk==0.1.5.*'
uv run pier run \
-p ../deep-swe/tasks \
--agent dsh-minimal \
--model deepseek-flash \
--ak reasoning_effort=max \
--ae DEEPSEEK_API_KEY="$DEEPSEEK_API_KEY" \
--ae DEEPSEEK_BASE_URL="$DEEPSEEK_BASE_URL" \
--mounts-json '[{"type":"bind","source":"'"$HOME"'/dsh-minimal/dsh-dist","target":"/opt/dsh-minimal","read_only":true}]' \
-n 32 --no-delete --job-name deepswe-dsh-run1 -y
- In
--mounts-json,sourceis the absolute path of thedsh-distdirectory above;targetis always/opt/dsh-minimal.
5. Read the results
jobs/<job-name>/
result.json pass rate and token totals
<task>__<id>/
result.json reward, fail-to-pass / pass-to-pass counts, tokens
agent/trajectory.json full ATIF trajectory (dsh-minimal)
agent/mini-swe-agent.trajectory.json mini-swe-agent trajectory
verifier/ reward.json and test output
Browse a job with uv run pier view jobs/<job-name>.