DeepSeek
Route your DeepSeek API calls through AI SpendOps for automatic usage tracking and cost attribution.
Configuration
| Setting | Value |
|---|---|
| Route | /v1/deepseek/* |
| Upstream | https://api.deepseek.com |
| Auth header | Authorization: Bearer ... |
| Streaming usage | Auto-injected (stream_options.include_usage) |
SDK base URL
https://proxy.aispendops.com/v1/deepseek/v1
Example
curl https://proxy.aispendops.com/v1/deepseek/v1/chat/completions \
-H "Authorization: Bearer your-deepseek-key" \
-H "X-ASO-API-Key: aso_k_yourkey.secret" \
-H "Content-Type: application/json" \
-d '{"model":"deepseek-chat","messages":[{"role":"user","content":"Hello"}]}'
Usage fields
| Field | Description |
|---|---|
prompt_tokens | Input tokens, including any cache hits |
completion_tokens | Output tokens |
prompt_cache_hit_tokens | Portion of prompt_tokens served from cache |
prompt_cache_miss_tokens | Portion of prompt_tokens that was not cached |
Cache token accounting
DeepSeek is the only supported provider that reports caching as a hit and miss
pair. The two values sum to prompt_tokens, so a cache hit is a breakdown
inside the prompt total rather than a separate category alongside it.
AI SpendOps maps prompt_cache_hit_tokens onto its own cache_read_tokens field
and subtracts it from prompt_tokens before pricing, so the cached portion is
charged once at the cache-read rate rather than at the full input rate.
prompt_cache_miss_tokens needs no special handling, since it is simply the
remainder.
That puts DeepSeek in the same family as OpenAI and Google Gemini, which also report cached tokens inclusively, and makes it the opposite of Anthropic, where cache tokens are separate non-overlapping categories and nothing is subtracted.
If you are reconciling a DeepSeek invoice by hand, note that adding
prompt_tokens and prompt_cache_hit_tokens together double counts the cached
input.
What AI SpendOps records
| Field | Populated |
|---|---|
cache_read_tokens | Yes, from prompt_cache_hit_tokens |
cache_write_tokens | No. DeepSeek caching is automatic with no separate write charge |
reasoning_tokens | Yes for reasoning models, via completion_tokens_details |
provider_cost | No. Cost is calculated from token counts and the current DeepSeek rate card |
Notes
- DeepSeek caching is automatic. There is no cache control parameter to set and no separate cache write cost, unlike Anthropic.
- The proxy injects
stream_options: { include_usage: true }on streaming requests, so streamed calls report real token counts rather than a character-based estimate. See Streaming. - Full field definitions are in the usage event field reference.