Back to blog

Cost optimizationComparison

Run DeepSeek locally or use an API? Hardware, speed, cost

Check whether your GPU and RAM can run DeepSeek V4-Flash, what speed to expect, and when changing base_url is simpler. Includes a cost table.

By CheapTokens TeamPublished Updated 7 min read

Two columns, Local and API, comparing running DeepSeek on your own hardware with calling a hosted API by changing base_url
On this page
  1. Will DeepSeek fit in your memory?
  2. How fast is it?
  3. What the same workload costs through an API
  4. When does your own hardware pay off?
  5. Moving from local to a hosted API
  6. If it doesn't work
  7. Which one to pick

Probably not, unless you own 128 GB of RAM or a Mac Studio-class machine, or you have a reason to keep every token on your own disk. A DeepSeek V4-Flash file alone is around 100 GB, and one community guide reports roughly 6–10 tokens per second even on expensive hardware. For most apps and agent loops the shorter route is to point the OpenAI client at a hosted API: you change base_url and the key, and nothing else in your code.

Below: how to check your own machine in five minutes, what speed to expect, and what a real workload costs through an API.

Will DeepSeek fit in your memory?#

The sizes here come from a community guide to running DeepSeek locally (deepseek-local-guide-ru on GitHub, 18 parts, CC BY 4.0, read on 22 October 2026). It is unofficial and not affiliated with DeepSeek. The guide's own pages don't fully agree with each other on sizes, so confirm the file size on the Hugging Face model card before you start a 100 GB download.

According to the guide, DeepSeek V4-Flash-0731 has 284B parameters, of which 13B are active per token. The files:

Quantization File size (guide's figure)
Q3 about 103 GB
Q4 about 155 GB
Q8 about 162 GB

The model does not have to sit entirely in video memory. llama.cpp can keep the expert layers in system RAM, but the guide's rule of thumb is blunt: a 24 GB GPU needs 128 GB of RAM next to it.

Say you have a good gaming PC with a 24 GB GPU and 64 GB of RAM. Add the two up and compare with the smallest file:

24 + 64 = 88 GB, and the Q3 file is 103 GB.

It doesn't fit, and the operating system still needs memory of its own. With 24 GB of VRAM and 128 GB of RAM you have 152 GB, and the 103 GB file fits with room to spare.

The newer DeepSeek-V4.1-Flash-1017 is bigger: about 552B parameters plus 196B of Engram, around 510 GB in FP8 and about 167 GB at 2-bit, according to the same guide. Support is the other problem. As of the guide (checked 22 October 2026) it does not run in Ollama, because the deepseek_v41 architecture is not supported, and llama.cpp and LM Studio support is not in their main branches. This changes fast, so look at the release notes of your engine before you plan around it.

How fast is it?#

The guide gives two measurements, both at heavy quantization and both community numbers, so read them as orders of magnitude and not as a benchmark:

  • DGX Spark with 128 GB, V4-Flash at IQ2: about 6–7 tokens per second.
  • Mac Studio M3 Ultra with 256 GB, V4.1-Flash in MLX 2-bit: about 9.5 tokens per second.

The guide has no figure for an RTX 4090 or 5090.

What does that feel like? A 1,000-token answer is roughly a page and a half of text:

1,000 ÷ 9.5 = 105.3 seconds

1,000 ÷ 6 = 166.7 seconds

For a chat you read as it streams, that is slow but usable. For an agent that makes dozens of calls per task, it adds up fast. Say your loop produces 2,000,000 output tokens a day and the machine really generates 9.5 tokens per second without a break:

2,000,000 ÷ 9.5 = 210,526 seconds

210,526 ÷ 3,600 = 58.5 hours

That is more than a day of generation for one day of work. Real servers batch several requests together, so the picture is not that grim for a team, but you would be tuning the engine instead of building your product.

What the same workload costs through an API#

Let's make the example concrete. Assume an agent loop that sends 10 million input tokens and gets 2 million output tokens a day. These are assumed numbers, replace them with yours from the usage log.

DeepSeek's own pricing page (22 October 2026, the page itself shows no date) lists deepseek-flash, served by DeepSeek-V4.1-Flash-1017, at these prices per 1M tokens, off-peak / peak: input with a cache miss $0.15 / $0.30, output $0.60 / $1.20. Peak hours are 01:00–04:00 and 06:00–10:00 UTC, Monday to Friday, excluding Chinese public holidays; off-peak is half of peak. Cache-hit input is much cheaper ($0.003 / $0.006), so a loop that re-sends the same long prefix will land below the numbers here.

For the assumed workload, with cache misses:

Off-peak: 10 × $0.15 + 2 × $0.60 = $2.70 per day

Peak: 10 × $0.30 + 2 × $1.20 = $5.40 per day

On CheapTokens, for the same kind of agent loop, take MiniMax-M2.7 (minimax-m2.7): one fixed price at any hour, no peak window, up to 8,192 output tokens per answer, a 180K context, and one balance for all models. The same 10M input and 2M output tokens cost $0.80 per day. Overall, with input and output counted together, it is cheaper than OpenRouter; here is the live table for exactly this workload:

Model Cost OpenRouter
GLM-5.3-Flash $0.28 $0.565
DeepSeek-V4-Flash $0.35 $0.789
MiniMax-M2.7 $0.80 $5.40

10,000,000 input and 2,000,000 output tokens in total. Prices per 1M tokens are current and change together with our tariffs; the OpenRouter column shows reference prices for the same workload.

The table reads the current price list each time it is shown, so it stays correct when prices change. The full price list is on the CheapTokens pricing page, and DeepSeek API pricing in 2026 explains how cache hits and peak hours change a bill.

When does your own hardware pay off?#

Local tokens cost nothing per request, but the machine does. A simple way to check:

text
payback days = hardware price ÷ (daily API bill − daily electricity)

I am not giving a hardware price here because it moves too much; put in the one you were quoted. To get a feel, take the off-peak bill from the DeepSeek pricing page above. Every $1,000 of hardware needs this many days of the API bill to break even, before electricity and your own time:

1,000 ÷ 2.70 = 370.4 days

And that assumes the machine can deliver this volume at all: at 9.5 tokens per second it cannot (see the speed section above), so for an agent workload the payback does not add up. Local makes more sense when:

  • the data must not leave your network, and that matters more than the bill;
  • you already own the machine and the load is light, say a few hundred requests a day for a personal tool;
  • you want to experiment with the weights themselves: quantization, fine-tuning, an engine of your choice.

An API makes more sense when the workload is an agent or a service, when you need the answer in seconds, or when your hardware is below the memory sizes above. If your machine is too small even for the lightest DeepSeek file, MiniMax-M2.7 (180K context, up to 8,192 output tokens per answer, overall cheaper than OpenRouter) is a model to try through the same client.

Moving from local to a hosted API#

Hobby projects often start on Ollama and then outgrow it. The good news: the local engines speak the OpenAI protocol. Ollama's compatibility page (docs.ollama.com, checked 22 October 2026) shows the endpoint http://localhost:11434/v1/; the client needs some api_key value, but Ollama ignores it. Streaming, JSON mode and tools work; logprobs do not.

So the switch is two lines plus the model name:

python
import os
from openai import OpenAI

# Local Ollama: the key is required by the client but ignored by the server
# client = OpenAI(base_url="http://localhost:11434/v1/", api_key="ollama")

client = OpenAI(
    base_url="https://api.cheaptokens.dev/v1",
    api_key=os.environ["CHEAPTOKENS_API_KEY"],
)

reply = client.chat.completions.create(
    model="MiniMaxAI/MiniMax-M2.7",  # take the exact id from the CheapTokens docs
    messages=[{"role": "user", "content": "Summarize this ticket in one sentence: ..."}],
    max_tokens=200,
)
print(reply.choices[0].message.content)
print(reply.usage)

When it works you see a one-sentence summary and a usage object with the prompt and completion token counts, the same numbers your bill is built from. The CheapTokens API also accepts the Anthropic Messages format, and the docs show the first request step by step. If base_url is new to you, OpenAI-compatible API: what base_url is takes two minutes.

If it doesn't work#

  • Connection refused on localhost:11434: Ollama is not running, or you are still pointing at the local address.
  • 401: the key is missing or copied with a space; read it from an environment variable, as in the example.
  • 404 or an unknown model: the model id does not match. Local names and hosted names differ, so copy the id from the docs.

Which one to pick#

If you own 128 GB or more and are curious, run the weights at home and enjoy the control. If you build an agent that burns millions of tokens a day, or a service where users wait for the answer, use the API and keep the local setup for experiments. The code stays the same either way, so you can start with one and move to the other later. For more on the self-hosting side, see what DeepInfer means for self-hosting; to try DeepSeek through the API, see CheapTokens DeepSeek models.