Set up DeepSeek in LiteLLM
LiteLLM is an open-source gateway and Python SDK that puts many model providers behind one OpenAI-style API. API Store works in it as an OpenAI-compatible endpoint: add DeepSeek V4.1 to your config and your apps call it through LiteLLM like any other model, with spend tracked per key and per team.
Before you start
- LiteLLM installed (pip install "litellm[proxy]"), or a LiteLLM proxy you already run
- An API Store key (it starts with sk-) and some balance
Steps
- Save the config below as config.yaml. The openai/ prefix tells LiteLLM the model speaks the OpenAI API, api_base points it at API Store, and use_chat_completions_api sends Responses and Anthropic Messages requests through chat completions.
- Put your API Store key in the APISTORE_API_KEY environment variable and start the proxy.
- Send a test request to the proxy with the model_name from the config.
config.yaml
model_list:
- model_name: deepseek-v4-1-flash
litellm_params:
model: openai/deepseek-v4-1-flash
api_base: https://api.apistore.cloud/v1
api_key: os.environ/APISTORE_API_KEY
use_chat_completions_api: true
input_cost_per_token: 0.00000021
output_cost_per_token: 0.00000084
cache_read_input_token_cost: 0.0000000042Start the proxy
export APISTORE_API_KEY=sk-... litellm --config config.yaml
Test request
curl http://localhost:4000/v1/chat/completions \
-H "Authorization: Bearer $LITELLM_MASTER_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "deepseek-v4-1-flash", "messages": [{"role": "user", "content": "Say hello"}]}'Python SDK
Without the proxy, call the model straight from Python with the same values.
Python
import os
from litellm import completion
response = completion(
model="openai/deepseek-v4-1-flash",
api_base="https://api.apistore.cloud/v1",
api_key=os.environ["APISTORE_API_KEY"],
messages=[{"role": "user", "content": "Say hello"}],
)
print(response.choices[0].message.content)Spend tracking
- The three cost lines give LiteLLM our peak-hour prices, so its spend logs and budgets show real numbers instead of $0.
- Off-peak we charge less than LiteLLM records. The Usage page in your API Store dashboard shows the exact charge of every request.
Which model to pick
- deepseek-v4-1-flash for everyday chat, code and tool calls
- deepseek-v4-1-flash-economy when the lowest price matters most: copy the entry, change both model names, and take its prices from the pricing page
Troubleshooting
- 401 invalid_api_key. Check that APISTORE_API_KEY is set where the proxy runs, not only in your shell.
- 404 model_not_found. The name after openai/ must be an API Store model name, exactly as on the pricing page.
- Spend shows $0. The cost lines are missing from litellm_params.
- 404 Unknown path /v1/responses on /v1/responses or /v1/messages. Add use_chat_completions_api: true to litellm_params.
- 402 insufficient_balance. Top up, or raise the key's daily cap.
What it costs
deepseek-v4-1-flash: $0.21 input and $0.84 output per 1M tokens in peak hours, $0.105 and $0.42 off-peak. Input read from cache costs $0.0042.
LiteLLM adds no fee of its own: each request is billed to your prepaid API Store balance at the price above.
Setup guides: Cursor · Cline · Claude Code · Docs
