When teams in mainland China discuss the DeepSeek API, the question often gets reduced to "can we connect at all?" What actually matters in production is four things: whether the network is stable, whether payment and invoicing work, whether peak-hour rate limits are acceptable, and whether there is a fallback path when something breaks. If any one of these fails, "it connects" means very little.
This article compares three common routes: official direct access, a self-hosted proxy, and a China-based AI gateway. It also covers timeouts, retries, fallback, and how to validate a route. For current models, prices, and access details, check the model pricing page and the site documentation.
Note: DeepSeek is a trademark of its owner. This article reflects common conditions as of October 2026. Network environments and terms of service may change; the official documentation and local regulations take precedence.
1. Three routes in one table
| Dimension | Official direct | Self-hosted proxy | China-based AI gateway |
|---|---|---|---|
| Endpoint | DeepSeek's official address | Forwarding through your own server | Unified OpenAI-compatible endpoint |
| Payment | Channels supported by DeepSeek | You pay for servers and bandwidth first | Top-up on the provider's site; terms on its page |
| Model coverage | DeepSeek only | Depends on the proxy configuration | Multiple providers, subject to activation |
| Stability responsibility | Official service plus local network | Entirely on your team | Shared between provider and local network |
| Operations burden | Low | High | Medium |
| Best for | Single model, low volume, stable network | Teams with network operations skills | Multiple models, invoices, unified billing |
No route suits everyone. The order of judgment is: first, whether the business can tolerate downtime; second, whether you need multiple models and invoices; third, whether your team has the people to run infrastructure.
2. Official direct access: when it is enough
Official direct access works when you call only DeepSeek, your volume is steady, local network access is normal, you can complete payment through official channels, and the business can accept slower responses at peak times. Setup is not complicated:
- Create an API key in the DeepSeek open platform, named by project.
- Store the key in a server-side environment variable, never in front-end code or a repository.
- Make a minimal request with curl to confirm the base URL and model name.
- Set connect timeout, read timeout, and a retry ceiling in the SDK.
- Log the model, token counts, latency, and error type for every request.
export DEEPSEEK_API_KEY="sk-your-key"
curl "https://api.deepseek.com/chat/completions" \
-H "Authorization: Bearer $DEEPSEEK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-chat",
"messages": [{"role": "user", "content": "Reply with OK only"}],
"max_tokens": 16
}'
If this command sometimes times out but works on another network, the problem is more likely your local egress or DNS than the key. Record the request time and error message before deciding whether to change routes.
3. Self-hosted proxy: solves egress, not capacity
A common approach is to run a reverse proxy on a server that can reach the official API and forward requests to DeepSeek. This can fix part of the "unstable local access" problem, but it introduces new work:
- The proxy server is itself a single point of failure; if it goes down, every request fails with it.
- You must handle TLS, authentication, and access control so the proxy cannot be abused.
- You need logging, rate limiting, and monitoring, or you won't be able to diagnose incidents.
- An extra forwarding hop adds latency, and time to first token may increase for streaming responses.
- Network and compliance responsibility remain with your team.
Without people to maintain the proxy continuously, it tends to turn from a temporary workaround into long-term technical debt. It can serve as a transition, but it is not a good sole entry point.
4. AI gateway: collapse multiple models and instability into one endpoint
The value of a China-based AI gateway is not just "relaying requests." It brings key management, top-up, billing, model switching, and failure handling into one place. For teams using several models, the most immediate change is that application code talks to a single OpenAI-compatible endpoint, and switching models becomes a configuration change rather than a code change.
export ZSQH_API_KEY="sk-your-key"
curl "https://ai.zhongshangqihang.com/v1/chat/completions" \
-H "Authorization: Bearer $ZSQH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-chat",
"messages": [{"role": "user", "content": "Explain the role of a gateway in one sentence"}],
"max_tokens": 128
}'
When evaluating a gateway, confirm five things: whether it supports the models you need, whether its billing and top-up rules are clear, whether it provides usage detail, how it communicates incidents, and whether its data terms meet your compliance requirements. Don't stop at "the request goes through."
5. Stability is your job: timeouts, retries, fallback
Whichever route you choose, the client must protect itself. Configure it in this order:
- Set connect and read timeouts separately. Keep connect timeouts short and read timeouts longer; configure long-document and reasoning tasks individually.
- Retry with backoff. Retry only on 429, 5xx, and timeouts, using exponential backoff with jitter and a maximum attempt count.
- Control concurrency. Use queues to smooth batch jobs instead of saturating capacity on the hour.
- Prepare fallback models. Critical workloads should be able to switch to a backup model or channel, accepting that outputs may differ.
- Add circuit breaking. Pause requests after a failure threshold so retries don't turn into a storm.
- Keep operations idempotent. For actions with side effects, check status before resending rather than retrying blindly.
import httpx
from openai import OpenAI
client = OpenAI(
api_key="sk-your-key",
base_url="https://ai.zhongshangqihang.com/v1",
timeout=httpx.Timeout(connect=5.0, read=120.0, write=30.0, pool=10.0),
max_retries=2,
)
There is no universal set of timeout values; tune them to your business tolerance and task length. The key is to avoid unlimited waits, and to avoid firing concurrent retries the moment a request fails.
6. Validate a route over one week
| Metric | How to record it | What to watch |
|---|---|---|
| Success rate | Share of non-200 responses | Whether failures cluster at peak hours |
| Latency | p50, p95, time to first token | Whether tail latency hurts the user experience |
| Rate limiting | Count of 429s and when they occur | Quota problem or traffic spike |
| Network errors | DNS, TLS, connection timeouts | Whether the cause is local egress |
| Quality | Manual review of a fixed task set | Whether outputs stay consistent after switching routes |
Cover at least one weekday peak and one overnight low period. Running the same batch of requests at fixed times each day for seven days is more informative than a single load test.
7. Payment, invoicing, and compliance
- Teams that need corporate payment and invoices should confirm the provider's invoicing rules and settlement time in advance.
- When customer data is involved, read the data terms first and confirm whether inputs are retained or used to improve the service.
- Split keys by environment; production keys never belong in front-end code or public repositories.
- Retain request logs and bills to support finance reconciliation and security audits.
- Confirm cross-border transfer and industry-specific requirements through local regulations and your company's compliance process.
Frequently asked questions
Is direct access to DeepSeek stable in China?
It depends on the local network, time of day, and official load; there is no single answer. Don't rely on one route in production; at minimum, prepare timeouts, retries, and a backup channel.
Does a gateway add latency?
An extra forwarding hop may add some latency, but a gateway can provide a more stable entry point and failover. Test direct access and the gateway with the same batch of requests, and compare p95 and success rate rather than a single call.
Is a self-hosted proxy suitable for every team?
No. It requires ongoing network operations, security configuration, and monitoring. Without dedicated maintenance, the proxy itself becomes a new failure point.
Can one key call multiple models?
In gateway mode, usually yes; the model is specified in the request, and the available range depends on the pricing page and console. A key for official direct access can only call the models DeepSeek exposes.
How do I tell whether a problem is local or upstream?
Start with a minimal request, then test with a different network, key, and entry point. Keeping request timestamps and error messages makes it much easier to distinguish DNS, TLS, authentication, rate limiting, and upstream failures.
Next steps
Create a test key on ZSQH AI Gateway, run the same batch of requests against direct access and the gateway, and compare success rate and latency before choosing a production route. Models and prices are listed on the model pricing page.
Related reading:
