Updated 2026-11-20
Make Your First DeepSeek V4.1 Flash API Call
One curl request is enough to get a text answer from deepseek-flash. This guide uses DeepSeek's official Chat Completions endpoint, saves its response locally and shows you where to find the assistant's text.
Set up the key and model ID
Get an API key from the official DeepSeek API platform and make sure the account has API credit. In the model field use deepseek-flash. The model table lists DeepSeek-V4.1-Flash-1017 as the version served by that ID.
Run these commands in Bash on your computer. The prompt hides the key as you type. Keep the same terminal open for the next step.
read -r -s -p "Official DeepSeek API key: " DEEPSEEK_API_KEY
export DEEPSEEK_API_KEY
printf '\n'Send one short text prompt
OpenAI-compatible clients use https://api.deepseek.com as the base URL. With curl, include the /chat/completions path as shown. Put your question in the user message. This example disables thinking for a short answer and requests a single JSON response with streaming turned off.
The command prints the HTTP status and saves the body to flash-response.json. Choose a folder where you can create that file.
curl --silent --show-error --max-time 120 \
--output flash-response.json --write-out 'HTTP %{http_code}\n' \
"https://api.deepseek.com/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DEEPSEEK_API_KEY" \
--data '{
"model": "deepseek-flash",
"messages": [{"role": "user", "content": "Explain a cache hit in one sentence."}],
"thinking": {"type": "disabled"},
"max_tokens": 120,
"stream": false
}'Find the answer in the response
After HTTP 200, open flash-response.json or run the short Python 3 snippet below. The final answer is in choices[0].message.content. The usage object gives token counts for this call. A finish_reason of length means the output reached its cap before the model finished.
On an error, the response body has an error object. For 401, check the key and that it belongs to the official API account. For 402, check that account's balance. For 429, wait for active requests to finish before sending another.
python3 - <<'PY'
import json
from pathlib import Path
response = json.loads(Path("flash-response.json").read_text(encoding="utf-8"))
if "error" in response:
raise SystemExit(response["error"].get("message", "Request failed"))
choice = response["choices"][0]
print(choice["message"]["content"])
print("Finish:", choice["finish_reason"])
print("Usage:", response["usage"])
PYFAQ
Do I need an SDK?
Curl handles the API request. The optional Python snippet only reads the JSON file that curl saved.
Can I ask a second question in the same conversation?
Yes. Send a new request with the earlier user message, the returned assistant message and your new user message in the messages array. For an unrelated question, send a new array containing just that question.