Skip to main content

DeepSeek

Route your DeepSeek API calls through AI SpendOps for automatic usage tracking and cost attribution.

Configuration

SettingValue
Route/v1/deepseek/*
Upstreamhttps://api.deepseek.com
Auth headerAuthorization: Bearer ...
Streaming usageAuto-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

FieldDescription
prompt_tokensInput tokens, including any cache hits
completion_tokensOutput tokens
prompt_cache_hit_tokensPortion of prompt_tokens served from cache
prompt_cache_miss_tokensPortion 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

FieldPopulated
cache_read_tokensYes, from prompt_cache_hit_tokens
cache_write_tokensNo. DeepSeek caching is automatic with no separate write charge
reasoning_tokensYes for reasoning models, via completion_tokens_details
provider_costNo. 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.