AI coding tools
DeepSeek FIM Completion: The Autocomplete Endpoint, Explained
Short answer
DeepSeek's FIM (Fill-in-the-Middle) endpoint completes code between a prefix you provide and a suffix that comes after it. It runs non-thinking mode only, caps each completion at 4K tokens, and requires switching your base URL to https://api.deepseek.com/beta. There is no separate FIM price — completions bill at the normal model rate, and deepseek-flash output runs $0.60/M tokens off-peak.
Most "how to use the DeepSeek API" tutorials cover the chat endpoint. But if you're building an autocomplete-style feature — the kind that sees def fib(a): before your cursor and return fib(a-1) + fib(a-2) after it, and fills in the middle — there's a dedicated endpoint for exactly that. We re-checked its behavior against DeepSeek's own docs on September 18, 2026, and several details have quietly changed since the tutorials were written.
What FIM completion actually does
FIM stands for Fill-in-the-Middle. You send a prompt (the code before the cursor) and an optional suffix (the code after it), and the model returns just the text that belongs in between. DeepSeek's own example is a one-liner: give it def fib(a): as the prefix and return fib(a-1) + fib(a-2) as the suffix, and it writes the body of the Fibonacci function.
Two implementation details trip people up:
- It does not go through
/chat/completions. It's the old-school completions interface — in the OpenAI SDK that'sclient.completions.create()withpromptandsuffixparameters, notmessages. - The base URL must be
https://api.deepseek.com/beta. Point your client at the mainhttps://api.deepseek.comand the beta endpoint isn't there.
Two models accept FIM requests: deepseek-flash (currently DeepSeek-V4.1-Flash) and deepseek-v4-pro. Note the first name — since the September 10 V4.1-Flash release, the canonical model ID is deepseek-flash. The legacy IDs deepseek-v4-flash and deepseek-v4-flash-vision-exp are still accepted, but they're now served by V4.1-Flash and billed at Flash prices, so older code samples you copy from the internet may silently be calling a newer model than they claim.
Sources: DeepSeek's FIM completion guide, FIM API reference, and Quick Start model notes.
The three constraints that shape how you use it
4K token cap. FIM completions max out at 4K tokens. For contrast, the chat endpoint's maximum output on the same models is 384K. That gap is the point: FIM is built for filling in a function body or a few lines mid-file, not for generating long output. If your use case needs more than 4K tokens of generated text, you don't want FIM — you want chat.
No thinking mode, ever. The pricing page's feature table marks FIM Completion as "Non-thinking mode only" on both models. This is the exact opposite of the chat endpoint, where thinking is the default. If you read our guide to calling DeepSeek with the OpenAI SDK, you know the surprise there was that your old code was already thinking by default. FIM is the other surprise: it never thinks, and there's no reasoning_effort to configure. That's a feature for autocomplete — you can't afford a reasoning pass when the user wants a suggestion in a few hundred milliseconds.
Beta base URL. The /beta base URL isn't optional, and beta endpoints can change or disappear with less ceremony than the stable API. Budget accordingly.
What a completion costs
There is no FIM-specific pricing. The billing rule is the same as everywhere else on the platform — tokens × the model's rate. Current rates per 1M tokens:
| Model | Input (cache miss) | Input (cache hit) | Output | Off-peak |
|---|---|---|---|---|
deepseek-flash |
$0.30 peak / $0.15 off | $0.006 peak / $0.003 off | $1.20 peak / $0.60 off | Half of peak |
deepseek-v4-pro |
$1.32 peak / $0.66 off | $0.044 peak / $0.022 off | $3.96 peak / $1.98 off | Half of peak |
Peak hours are 01:00–04:00 and 06:00–10:00 UTC on weekdays; everything else — nights, weekends, all of it — is off-peak. We broke down the off-peak window mechanics separately.
Some arithmetic to calibrate expectations: a worst-case FIM request that actually hits the 4K output cap on deepseek-flash at peak costs 4096 × $1.20/M ≈ $0.005. A typical autocomplete response is a few dozen tokens, and IDE autocomplete sends the same file prefix over and over — that's the cache-hit input rate of $0.003/M off-peak, which is close to free. Autocomplete traffic on the Flash model is one of the cheapest sustained workloads you can run on this API. If you're pricing out autocomplete options across model families, our GLM-5.3-Flash hosting comparison covers the main alternative.
FIM doesn't have its own rate in the table above because DeepSeek doesn't publish one — the pricing page bills every endpoint by input and output tokens at the model's rate. If that ever changes, this page is wrong and the pricing page wins.
Wiring it into Continue (and one rough edge)
Continue, the VS Code autocomplete plugin, is the integration DeepSeek's own FIM guide points to. The configuration path exists: DeepSeek appears as a model provider, and an autocomplete model is just a model with the autocomplete role in your config. DeepSeek maintains a setup document in its awesome-deepseek-integration repo.
Two honest caveats. First, Continue's own autocomplete docs recommend Codestral, QwenCoder, or Mercury Coder for the autocomplete role — DeepSeek isn't on their recommended list, so you're off the beaten path. Second, a GitHub issue dated June 10, 2026 reports DeepSeek FIM autocomplete failing inside Continue while the native FIM API works fine when called directly. We could not load the full thread to check whether it was resolved — treat the Continue path as unverified until you've tested it with your own key, and expect the raw API to be the part that works.
The FIM endpoint is labeled Beta on both the guide and the API reference, and it lives behind a /beta base URL. Beta features can change without the notice cycle of the stable API — pin your integration and re-test before depending on it.
Checked September 18, 2026, against DeepSeek's own docs: the FIM guide, the FIM API reference, and the pricing page. We don't track changes after publication.