Why LiteLLM Belongs in Front of Chinese Model APIs
Chinese model providers usually expose an OpenAI-compatible endpoint. That gives you a familiar SDK shape, but it does not make providers interchangeable. Authentication headers, base URLs, model IDs, rate-limit errors, streaming quirks, tool-call formatting, and token accounting still differ. LiteLLM proxy sits between your app and those APIs, gives you one OpenAI-style surface, and centralizes the ugly parts: keys, aliases, fallbacks, retries, and logs.
Provider families such as DeepSeek via AiCredits, Alibaba DashScope, Zhipu, Moonshot, and MiniMax all offer OpenAI-compatible access, but their model IDs and feature support are not identical. Treat compatibility as a starting point, not a guarantee.
Use LiteLLM when you have more than one upstream or more than one team calling models. If you only call one model from one script, direct SDK calls are simpler. The proxy earns its keep when you need to change providers without shipping app code, or when you want one place to enforce budgets and observe failures.
One upstream in this setup is AiCredits: it serves DeepSeek models to international developers with card or PayPal payment, no Chinese phone number or bank account required. That makes it a practical first route while you wire the rest of the proxy.
What LiteLLM solves — and what it does not
Solves: key isolation, OpenAI-compatible request shape, model aliases, retries, fallbacks, basic spend tracking, and a single base URL for apps.
Does not solve: provider-specific feature gaps. If one provider's tool calling is weak, the proxy cannot invent a reliable tool call.
Does not solve: tokenizer differences. Budgets and context estimates can drift between providers.
Does not solve: data residency. You still choose which provider receives which prompt.
Does not solve: model quality. Routing to a cheaper model is not free if you have to re-run the task.
Step 1: Verify the DeepSeek upstream directly
Before adding a proxy layer, prove the upstream works from your environment. This uses the OpenAI SDK against AiCredits and the fast default model. Run it with AICREDITS_API_KEY set.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ['AICREDITS_API_KEY'],
base_url='https://api.aicreditsapi.com/v1',
)
response = client.chat.completions.create(
model='deepseek-v4-flash',
messages=[
{'role': 'system', 'content': 'You are a terse API debugging assistant.'},
{'role': 'user', 'content': 'List three common causes of 429 responses in a model proxy.'},
],
temperature=0.2,
)
print(response.choices[0].message.content)
If that returns text, the key, base URL, and model name are correct. Keep this script as a smoke test. When the proxy misbehaves, run it again to separate an upstream failure from a proxy configuration mistake.
Step 2: Add the route to LiteLLM
A minimal LiteLLM config with two DeepSeek routes. The fast model is the default; the pro model is for harder tasks where the extra cost is justified. Pricing is qualitative here: pro costs more than flash, off-peak requests cost less, and cache hits are cheaper. Check aicreditsapi.com/pricing for current rates.
model_list:
- model_name: deepseek-v4-flash
litellm_params:
model: openai/deepseek-v4-flash
api_base: https://api.aicreditsapi.com/v1
api_key: os.environ/AICREDITS_API_KEY
- model_name: deepseek-v4-pro
litellm_params:
model: openai/deepseek-v4-pro
api_base: https://api.aicreditsapi.com/v1
api_key: os.environ/AICREDITS_API_KEY
litellm_settings:
drop_params: true
general_settings:
master_key: os.environ/LITELLM_MASTER_KEY
Run it with litellm --config config.yaml --port 4000 or the equivalent container command. The drop_params setting matters when you route the same request across providers: if one provider rejects an OpenAI parameter it does not support, LiteLLM can drop it instead of failing the request. Do not rely on that as a substitute for testing each provider's supported features.
To add another Chinese provider, duplicate a block. Keep the public model_name as a stable alias your app calls, and put the provider's real model ID under litellm_params.model with the provider's OpenAI-compatible api_base and key. Use aliases like general-fast, general-pro, or code-review so application code does not encode vendor names. When you swap providers, the alias stays the same.
Step 3: Call the proxy without changing app code
The OpenAI SDK can point at LiteLLM's OpenAI-compatible endpoint. The script below defaults to AiCredits so it runs as written, but it accepts OPENAI_BASE_URL and OPENAI_API_KEY so the same file works against the proxy. In production, set those environment variables to the proxy URL and virtual key.
import os
from openai import OpenAI
base_url = os.environ.get('OPENAI_BASE_URL', 'https://api.aicreditsapi.com/v1')
api_key = os.environ.get('OPENAI_API_KEY', os.environ.get('AICREDITS_API_KEY'))
if not api_key:
raise SystemExit('Set OPENAI_API_KEY or AICREDITS_API_KEY')
client = OpenAI(api_key=api_key, base_url=base_url)
response = client.chat.completions.create(
model='deepseek-v4-flash',
messages=[
{'role': 'system', 'content': 'Return only valid JSON. No markdown.'},
{'role': 'user', 'content': 'Extract invoice_id, due_date, and total from: Invoice 1042, due 2026-08-01, total 19.50 USD'},
],
temperature=0.1,
)
print(response.choices[0].message.content)
This works because LiteLLM exposes the same chat-completions shape. If your app already uses the OpenAI SDK, moving from direct AiCredits calls to the proxy is mostly an environment-variable change. Keep the model alias deepseek-v4-flash stable and let the proxy decide which upstream serves it.
Routing patterns that hold up
Route by task, not vendor. Use
deepseek-v4-flashfor extraction, classification, and short summaries. Reservedeepseek-v4-profor multi-step reasoning, code review, or cases where a failed cheap call would cost more than the stronger model.Set fallbacks explicitly. A fallback is only useful if the fallback model is tested on the same prompts. Log which route answered.
Put rate limits per provider, not only per app. One noisy service can exhaust a shared provider quota.
Keep a direct smoke-test path. When the proxy returns a 500, you need to know whether the upstream key expired or the proxy config is wrong.
Normalize errors before they reach users. Map provider-specific rate-limit and context-length errors into a small set of app-level responses.
Do not proxy sensitive prompts through providers you have not reviewed. The proxy centralizes traffic, which also centralizes risk.
Pin model aliases in config, not in application strings. Otherwise a provider rename becomes a code change.
| Concern | Direct provider SDKs | LiteLLM proxy |
|---|---|---|
| Key handling | One key per provider in each service | Keys live in proxy config or secret manager |
| Model changes | App code changes when model IDs change | Alias stays; config changes |
| Fallbacks | Custom retry code | Built-in routing and fallback config |
| Observability | Per-service logs | One request log across providers |
| Provider quirks | Handled in every app | Handled once, with drop_params and tests |
| Vendor lock-in | Higher at app layer | Lower at app layer, higher at proxy layer |
Compatibility is a request format, not a guarantee. Test the features you actually use.
A practical rollout order
Start with one provider and one alias. Add a second provider only when you have a concrete reason: a capability gap, a rate-limit ceiling, a region requirement, or a cost tradeoff you can measure. Add fallbacks after you have a baseline. Add budget caps before you expose the proxy to a team. Add caching only for repetitive prompts where stale answers are acceptable.
Keep the proxy boring. A short config, one master key, per-team virtual keys, a health check, and request logs are enough for most teams. Complexity in routing rules is easy to add and hard to debug.
FAQ
Often yes, but test the exact features you need. LiteLLM has provider-specific adapters, and OpenAI-compatible endpoints are the simplest path. Tool calling, JSON mode, streaming, and image inputs are the usual failure points, so test them with real prompts rather than assuming compatibility.
Use flash as the default route for high-volume, low-ambiguity tasks. Use pro when the task needs more reasoning or when a wrong cheap answer creates rework. Measure both on your own prompts; do not route by model reputation alone.
AiCredits is one upstream for DeepSeek models, aimed at international developers who want card or PayPal payment without a Chinese phone or bank account. Add it as a LiteLLM route like any OpenAI-compatible provider, and check aicreditsapi.com/pricing for current rates.
It adds a network hop and some routing overhead. The tradeoff is centralized auth, fallbacks, and logs. If you are latency-sensitive, measure the proxy path against the direct path with your own payloads; do not assume either is free.