🤖 AI Tools
· 5 min read
Last updated on

How to Use DeepSeek V4 on OpenRouter: Setup and Configuration Guide (2026)


DeepSeek V4 is one of the strongest open-weight model families available in 2026. Running it through OpenRouter gives you a single API key that works with V4 Pro, V4 Flash, and 300+ other models from OpenAI, Anthropic, Google, and more. This guide walks through setup, model IDs, pricing, coding tool integration, and fallback routing.

Why Use DeepSeek V4 Through OpenRouter

Accessing DeepSeek V4 directly through the DeepSeek API works fine, but OpenRouter adds several practical advantages:

  • One API key for everything. Switch between DeepSeek V4 Pro, V4 Flash, Claude, GPT, Gemini, and Kimi K2.6 without managing separate accounts.
  • Fallback routing. If one provider goes down or hits rate limits, OpenRouter can automatically route your request to a backup model.
  • Unified billing. One dashboard, one invoice, one credit balance across all models.
  • Provider diversity. OpenRouter aggregates multiple hosting providers for the same model, improving uptime and reducing latency by picking the fastest available endpoint.
  • OpenAI-compatible API. Drop-in replacement for any tool or library that supports the OpenAI chat completions format.

If you already use OpenRouter for other models, adding V4 takes about 30 seconds.

DeepSeek V4 Model IDs on OpenRouter

OpenRouter distinguishes concrete model routes from rolling family aliases. Checked September 16, 2026, the Pro Latest alias resolves to V4 Pro 0813 and the Flash Latest alias resolves to V4.1 Flash. These are not two new foundation models.

ChoiceOpenRouter IDCurrent destinationAdvertised context
Concrete Pro routedeepseek/deepseek-v4-pro-0813V4 Pro 08131,048,576 tokens
Concrete Flash routedeepseek/deepseek-v4.1-flashV4.1 Flash1,048,576 tokens
Rolling Pro family~deepseek/deepseek-pro-latestV4 Pro 0813 todayDestination-dependent
Rolling Flash family~deepseek/deepseek-flash-latestV4.1 Flash todayDestination-dependent

Use a concrete route for evaluation baselines and controlled production upgrades. Use Latest only when automatically following the family is intentional. A concrete model ID does not freeze provider infrastructure or guarantee bit-for-bit outputs. Log the requested ID, returned model, provider where available, token usage and date; rerun your LLM regression tests before accepting a changed destination.

The examples below use the current concrete routes rather than a rolling Latest alias. OpenRouter aliases and the direct DeepSeek API are separate routing systems. An announcement about direct-API retirement does not prove that every third-party hosted route has retired.

Setup: API Key and First Request

Step 1: Get Your OpenRouter API Key

  1. Create an account at openrouter.ai.
  2. Navigate to Keys in your dashboard.
  3. Click Create Key and copy the value. Store it securely.

Step 2: Set Your Environment Variable

export OPENROUTER_API_KEY="sk-or-v1-your-key-here"

Step 3: Make a Request with Python

OpenRouter uses the same format as the OpenAI API. You can use the openai Python package directly:

from openai import OpenAI

client = OpenAI(
    base_url="https://openrouter.ai/api/v1",
    api_key="sk-or-v1-your-key-here",
)

response = client.chat.completions.create(
    model="deepseek/deepseek-v4-pro-0813",
    messages=[
        {"role": "user", "content": "Explain Python generators in 3 sentences."}
    ],
)

print(response.choices[0].message.content)

To use V4 Flash instead, swap the model ID to deepseek/deepseek-v4.1-flash. Everything else stays the same.

cURL Example

curl https://openrouter.ai/api/v1/chat/completions \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek/deepseek-v4-pro-0813",
    "messages": [
      {"role": "user", "content": "Write a Rust function to reverse a string."}
    ]
  }'

Pricing: OpenRouter vs Direct DeepSeek API

The model pages currently advertise the following USD rates per million tokens. These are OpenRouter rates, not a universal direct-API comparison:

Current alias destinationInputOutputCache read
V4 Pro 0813$0.66$1.98$0.022
V4.1 Flash$0.15$0.60$0.015

Prices can vary with the selected provider and alias destination. Do not infer a blanket 10% per-token markup or copy direct DeepSeek peak/off-peak rates into this table. Compare the current route and account charges using OpenRouter versus direct APIs, and inspect the provider listing before budgeting cached requests. Cache pricing does not guarantee a cache hit.

Using DeepSeek V4 with Coding Tools

Aider

Aider supports OpenRouter natively. Set the base URL and model:

export OPENAI_API_BASE=https://openrouter.ai/api/v1
export OPENAI_API_KEY=sk-or-v1-your-key-here

aider --model openrouter/deepseek/deepseek-v4-pro-0813

For faster iteration on smaller edits, use V4 Flash:

aider --model openrouter/deepseek/deepseek-v4.1-flash

Continue.dev

Add this to your Continue configuration file (~/.continue/config.json):

{
  "models": [
    {
      "title": "DeepSeek V4 Pro (OpenRouter)",
      "provider": "openrouter",
      "model": "deepseek/deepseek-v4-pro-0813",
      "apiKey": "sk-or-v1-your-key-here"
    }
  ]
}

OpenCode

Set the environment variables and point OpenCode at the OpenRouter endpoint:

export OPENAI_API_BASE=https://openrouter.ai/api/v1
export OPENAI_API_KEY=sk-or-v1-your-key-here

opencode --model deepseek/deepseek-v4-pro-0813

Fallback Configuration: V4 Flash Primary, V4 Pro Backup

OpenRouter’s route-level fallback can try Pro when a Flash request fails. It does not judge whether a successful Flash answer is too weak for a complex task. Implement explicit application routing or evaluation gates if quality should trigger escalation.

Send this in your request body:

{
  "model": "deepseek/deepseek-v4.1-flash",
  "route": "fallback",
  "models": [
    "deepseek/deepseek-v4.1-flash",
    "deepseek/deepseek-v4-pro-0813"
  ],
  "messages": [
    {"role": "user", "content": "Refactor this module to use dependency injection."}
  ]
}

OpenRouter will try V4 Flash first. If it fails (rate limit, timeout, provider outage), the request automatically retries with V4 Pro. You can also mix in models from other providers:

"models": [
  "deepseek/deepseek-v4.1-flash",
  "deepseek/deepseek-v4-pro-0813",
  "anthropic/claude-sonnet-4"
]

This gives you a three-tier fallback chain across two completely different model providers.

FAQ

Is my data private when using DeepSeek V4 through OpenRouter?

OpenRouter acts as a proxy. Your prompts are forwarded to the underlying provider hosting the model. Review both OpenRouter’s and DeepSeek’s privacy policies. For sensitive workloads, consider self-hosting V4 since it is open-weight.

Can I use OpenRouter’s free tier with DeepSeek V4?

OpenRouter occasionally offers free credits for new accounts and may provide free access to select models. V4 Flash is more likely to appear on free tiers than V4 Pro due to lower compute costs. Check the OpenRouter dashboard for current free model availability.

How does latency compare to the direct DeepSeek API?

OpenRouter adds a small routing overhead, typically 50 to 200ms on the first token. For streaming responses, the difference is negligible after the initial token. If you need the absolute lowest latency, the direct API will be marginally faster, but OpenRouter’s provider aggregation can sometimes find a faster endpoint than the default.

Wrapping Up

Running DeepSeek V4 Pro and V4 Flash through OpenRouter is the most flexible way to access these models. You get unified billing, fallback routing, and compatibility with tools like Aider out of the box. The setup takes minutes, and switching between V4 and any other model on the platform is a one-line change.