Calling DeepSeek from Python is a standard HTTPS chat-completions flow once you have an API key from the platform. Pick deepseek-flash or deepseek-v4-pro, log token usage, and remember consumer chat is free but the API is not. Attribute rates to the 17 September 2026 pricing page and recheck platform.deepseek.com. Keep secrets out of git.

Keys and environment setup
Sign in at platform.deepseek.com, create an API key, and store it in an environment variable or secret manager. Python scripts should read the key at runtime—not from a hard-coded string in the repo. Rotate keys if they leak. Free consumer chat credentials are not a substitute for API keys. When you first test, call a tiny prompt on Flash and print usage so you see billing units before you scale. Always recheck platform docs if auth headers change. Treat every rate and limit as a dated snapshot from DeepSeek or the other vendor docs linked in sources, not as a permanent contract price.
Model selection in code
Pass deepseek-flash for V4.1 Flash or deepseek-v4-pro for Pro. Flash: peak $0.30 / $1.20 per million (off-peak half), vision yes, concurrency cited 2,500. Pro: peak $1.32 / $3.96 (off-peak half), no vision, concurrency 500. Both list 1M context and 384K max output per the 17 September 2026 pricing page. Cached input is much cheaper—structure system prompts so prefixes can hit cache. Confirm live model IDs on the platform; names can change. Treat every rate and limit as a dated snapshot from DeepSeek or the other vendor docs linked in sources, not as a permanent contract price.
Batching, peak hours, and India
Peak hours are described as weekdays 01:00–04:00 and 06:00–10:00 UTC. India daytime often falls outside that UTC window, so many Indian API jobs are off-peak—still confirm the clock on DeepSeek’s pricing page because it can change. For large Python batch jobs, sleep or queue into off-peak, enable caching where the API supports it, and cap max tokens. Do not invent SLAs. Pair this with Cursor or Copilot only if your editor billing is separate—those are not DeepSeek Python fees. Treat every rate and limit as a dated snapshot from DeepSeek or the other vendor docs linked in sources, not as a permanent contract price.
Related on this site
Frequently asked questions
-
Which Python library should I use?
Use whatever official or OpenAI-compatible client DeepSeek documents on platform.deepseek.com. Prefer their current examples over random gists. Auth and base URLs can changeu2014follow the platform docs. Confirm live details on the vendor docs linked in this brief before you quote a client or ship production traffic. Attribute DeepSeek Flash and Pro figures to the 17 September 2026 pricing page when you reuse them, then recheck platform.deepseek.com.
-
How do I avoid surprise bills?
Log prompt and completion tokens, set max_tokens, start on Flash, and watch peak versus off-peak. Rates above are from 17 September 2026u2014recheck platform.deepseek.com. Free chat does not cover API calls. Confirm live details on the vendor docs linked in this brief before you quote a client or ship production traffic. Attribute DeepSeek Flash and Pro figures to the 17 September 2026 pricing page when you reuse them, then recheck platform.deepseek.com.
-
Can I use vision from Python?
Vision is supported on Flash in this brief, not on Pro. Send image inputs only on deepseek-flash and confirm the multimodal request shape in DeepSeek’s docs. Confirm live details on the vendor docs linked in this brief before you quote a client or ship production traffic. Attribute DeepSeek Flash and Pro figures to the 17 September 2026 pricing page when you reuse them, then recheck platform.deepseek.com.
-
Is R1 the Python default?
No. Current API names in this brief are V4.1 Flash and V4 Pro. R1 was earlier reasoning gear. Pin an explicit model string in code. Confirm live details on the vendor docs linked in this brief before you quote a client or ship production traffic. Attribute DeepSeek Flash and Pro figures to the 17 September 2026 pricing page when you reuse them, then recheck platform.deepseek.com.
Sources
Bdeb Technology builds websites, WordPress systems, and tools on top of models like these. A written quote comes back within 24 hours.
