[![apistore.cloud logo](https://apistore.cloud/logo-mark.png) apistore.cloud](https://apistore.cloud/zh/)

[登录](https://apistore.cloud/login)[获取 API 密钥](https://apistore.cloud/signup)

# 在 LiteLLM 中配置 DeepSeek

LiteLLM 是一个开源网关和 Python SDK，把众多模型服务商统一到一个 OpenAI 风格的 API 之后。API Store 在其中作为兼容 OpenAI 的端点使用：把 DeepSeek V4.1 加入你的配置，你的应用就能像调用其他模型一样通过 LiteLLM 调用它，并按密钥和团队统计花费。

## 开始之前

- 已安装 LiteLLM（pip install "litellm[proxy]"），或已在运行的 LiteLLM 代理
- 一个 API Store 密钥（以 sk- 开头）和一定余额

## 步骤

1. 将下方配置保存为 config.yaml。openai/ 前缀告诉 LiteLLM 该模型使用 OpenAI API，api_base 将其指向 API Store，use_chat_completions_api 让 Responses 和 Anthropic Messages 请求经由 chat completions 发送。
2. 把你的 API Store 密钥放入环境变量 APISTORE_API_KEY，然后启动代理。
3. 使用配置中的 model_name 向代理发送一个测试请求。

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.0000000042
```

启动代理

```
export APISTORE_API_KEY=sk-...
litellm --config config.yaml
```

测试请求

```
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

不使用代理时，可用相同的值直接在 Python 中调用模型。

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)
```

## 花费统计

- 这三行费用配置向 LiteLLM 提供我们的高峰时段价格，因此它的花费日志和预算会显示真实金额，而不是 $0。
- 闲时我们的收费低于 LiteLLM 记录的金额。API Store 控制台的「用量」页面显示每个请求的确切扣费。

## 选择哪个模型

- deepseek-v4-1-flash：适合日常聊天、代码和工具调用
- deepseek-v4-1-flash-economy：最看重低价时使用。复制这一项，修改两处模型名称，并从价格页面获取它的价格

## 故障排查

- 401 invalid_api_key。请确认 APISTORE_API_KEY 设置在代理运行的环境中，而不仅仅是在你的 shell 里。
- 404 model_not_found。openai/ 后面的名称必须是 API Store 的模型名称，与价格页面上完全一致。
- 花费显示为 $0。litellm_params 中缺少费用配置行。
- 在 /v1/responses 或 /v1/messages 上出现 404 Unknown path /v1/responses。请在 litellm_params 中添加 use_chat_completions_api: true。
- 402 insufficient_balance。请充值，或提高该密钥的每日上限。

## 费用

deepseek-v4-1-flash：高峰时段每百万 token 输入 US$0.21、输出 US$0.84，闲时输入 US$0.105、输出 US$0.42。从缓存读取的输入为 US$0.0042。

LiteLLM 本身不额外收费：每个请求都按上述价格从你预付的 API Store 余额中扣费。

[全部价格 →](https://apistore.cloud/zh/pricing)

[获取 API 密钥](https://apistore.cloud/signup)

配置指南: [Cursor](https://apistore.cloud/zh/docs/cursor) · [Cline](https://apistore.cloud/zh/docs/cline) · [Claude Code](https://apistore.cloud/zh/docs/claude-code) · [Docs](https://apistore.cloud/zh/docs)

[![apistore.cloud logo](https://apistore.cloud/logo-mark.png) apistore.cloud](https://apistore.cloud/zh/)

© 2026 apistore.cloud

---

Source: https://apistore.cloud/zh/docs/litellm
