DeepSeek through one OpenAI-compatible gateway
Call DeepSeek’s low-cost models with your OpenAI SDK through Routeplane — with fallback, in-data-plane guardrails, residency routing, and cost attribution.
DeepSeek serves an OpenAI-compatible API. Routeplane’s adapter handles the small differences — notably DeepSeek’s flat cache-hit token accounting — and lifts them into the canonical usage block so your cost tracking is correct.
DeepSeek’s pricing makes it a strong choice as a cost-first primary; the gateway falls back to a broader provider when you need one.
Drop in your OpenAI client
Point your existing OpenAI SDK at the gateway and add two headers — your virtual key and the provider. Nothing else about your code changes.
curl https://api.routeplane.ai/v1/chat/completions \
-H "content-type: application/json" \
-H "x-routeplane-api-key: rp_your_gateway_key" \
-H "x-routeplane-provider: deepseek" \
-d '{"model":"deepseek-chat","messages":[{"role":"user","content":"Hello!"}]}'
import openai
client = openai.OpenAI(
api_key="rp_your_gateway_key",
base_url="https://api.routeplane.ai/v1",
default_headers={
"x-routeplane-api-key": "rp_your_gateway_key",
"x-routeplane-provider": "deepseek", # route to DeepSeek
},
)
resp = client.chat.completions.create(
model="deepseek-chat",
messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'rp_your_gateway_key',
baseURL: 'https://api.routeplane.ai/v1',
defaultHeaders: {
'x-routeplane-api-key': 'rp_your_gateway_key',
'x-routeplane-provider': 'deepseek', // route to DeepSeek
},
});
const completion = await client.chat.completions.create({
model: 'deepseek-chat',
messages: [{ role: 'user', content: 'Hello!' }],
});
console.log(completion.choices[0]?.message.content);
Or use the Routeplane SDK
The Routeplane SDKs subclass the official OpenAI clients, wire up the x-routeplane-* headers for you, and add typed access to routing metadata and the non-OpenAI surfaces.
pip install routeplane
from routeplane import Routeplane
client = Routeplane(
api_key="rp_your_gateway_key",
provider="deepseek", # route to DeepSeek
)
resp = client.chat.completions.create(
model="deepseek-chat",
messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)
npm i @routeplane/sdk
import { Routeplane } from '@routeplane/sdk';
const client = new Routeplane({
apiKey: process.env.ROUTEPLANE_API_KEY!, // rp_...
provider: 'deepseek', // route to DeepSeek
});
const completion = await client.chat.completions.create({
model: 'deepseek-chat',
messages: [{ role: 'user', content: 'Hello!' }],
});
console.log(completion.choices[0]?.message.content);
Add a fallback chain
Try DeepSeek first for cost; fall back to OpenAI. Make the provider header a comma-separated list and the gateway walks it in order, skipping any provider whose circuit is open.
curl https://api.routeplane.ai/v1/chat/completions \
-H "content-type: application/json" \
-H "x-routeplane-api-key: rp_your_gateway_key" \
-H "x-routeplane-provider: deepseek,openai" \
-d '{"model":"deepseek-chat","messages":[{"role":"user","content":"Hello!"}]}'
DeepSeek on the gateway
The adapter supports chat completions and native streaming. Embeddings requests return a clean 422 — route them to a provider that offers them.
Cache-hit tokens preserved
DeepSeek reports cache hits as a flat prompt_cache_hit_tokens field; the adapter lifts that into canonical cached-token usage so your accounting reflects the discount.
Cost-first routing
Pair DeepSeek with x-routeplane-strategy: cost to order eligible providers cheapest-first, keeping DeepSeek at the head where it wins on price.
DeepSeek model pricing
List prices for the DeepSeek models you can call through the gateway — click any model for its per-token cost page.
Sovereign routing
Sovereign routing works with DeepSeek the same way it works everywhere: add x-routeplane-residency to a request, and when the gateway classifies regulated personal data in it, only providers resident in the requested region stay eligible — a hard constraint that overrides the provider header. Declare where DeepSeek runs by setting DEEPSEEK_REGION.
Keep reading
- Quickstart — send your first request in a few minutes.
- Providers & routing strategy — how eligibility, fallback, and strategies work.
- Python SDK and TypeScript SDK — the full typed clients.
- All providers — every model provider behind the gateway.
Frequently asked questions
Is Routeplane a drop-in replacement for calling DeepSeek directly?
Yes. The gateway is OpenAI-compatible, so switching is a base-URL change — point your existing OpenAI SDK at https://api.routeplane.ai/v1 and set the x-routeplane-provider header to deepseek. You keep your code and gain automatic fallback, in-data-plane PII guardrails, sovereign routing, and per-team cost attribution.
Which DeepSeek models can I use through Routeplane?
Any DeepSeek model the provider serves. See the list prices linked above for the ones we publish.
Can I enforce data residency on DeepSeek requests?
Yes. Add the x-routeplane-residency header (for example IN) and, when a request carries regulated personal data, the gateway restricts routing to providers eligible in that region — overriding the provider header if it has to. The DeepSeek adapter reads DEEPSEEK_REGION to declare where it is resident.
Route your first request this week.
Point your existing OpenAI-compatible client at Routeplane, set one header, and get fallback, guardrails, and sovereign routing across every provider.