AiCredits
Pricing Mechanics

DeepSeek API Pricing 2026: Peak and Off-Peak Rates Explained

DeepSeek API pricing in 2026 runs on a peak/off-peak clock. Learn how the two-rate model works and get Python code to schedule jobs and cache prompts.

Published 2026-09-20 Updated 2026-09-20 8 min

Most teams treat DeepSeek pricing as a number they look up once and forget. In 2026 it behaves more like a two-dimensional problem: which model you call, and when the request lands. Both deepseek-v4-flash and deepseek-v4-pro have a peak rate and a lower off-peak rate, and prompt caching sits on top of both. Get the clock right and the same nightly batch you ran at 2pm becomes cheaper at 3am — identical code, identical prompts, different bill.

This article is about the mechanics, not the numbers. Current rates and the exact off-peak window live at aicreditsapi.com/pricing; what follows is how the two-rate model actually behaves and how to write code that takes advantage of it.

How the peak / off-peak clock actually works

Off-peak is a scheduled window, quoted in UTC, covering the provider's low-traffic hours. Peak is everything outside it. This is a billing schedule, not a capacity limit — you can call the API at any hour, you simply pay the peak rate outside the window.

Three consequences trip people up in production.

  • The window is defined in UTC, so your local off-peak may land in the middle of your working day. Convert once, then store the window in UTC so daylight-saving changes never shift your schedule.

  • Treat the boundary as a hard edge. A batch that starts ten minutes before the window closes is safest budgeted entirely at peak rates.

  • Off-peak is not a queue you join. Requests are served immediately, at whatever rate is in force when they are processed.

Five levers that move the bill more than the model choice does

  • Model tier. Pro costs more than flash in both windows. Escalating late is cheaper than escalating first.

  • Time of day. The same prompt in the off-peak window is billed at the lower rate. This is the single easiest lever you have, because it requires no prompt engineering.

  • Cache reuse. Prompts that share a long, byte-identical prefix can be served partly from cache, and cached input is cheaper than fresh input. This stacks with off-peak pricing rather than replacing it.

  • Output length. On hosted APIs, generated tokens are the expensive half. Cap max_tokens, ask for structured output, and stop the model from narrating its reasoning unless you need it.

  • Retries. A retry is a brand-new call, billed like one. Deduplicate failed prompts before you re-send them in a loop — runaway retry loops are the most common cause of surprising invoices.

Lever one in code: make cache hits the default

Cache hits depend on prefix stability. Anything that changes between calls — a timestamp, a request ID, a shuffled instruction list — invalidates everything after it. Build your system prompt as a constant, put variable content in the user turn, and never interpolate into the prefix.

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["AICREDITS_API_KEY"],
    base_url="https://api.aicreditsapi.com/v1",
)

# This prefix is byte-identical on every call, so the provider can serve it
# from cache instead of re-processing it. Keep it first in the message list
# and never interpolate variable data into it.
STABLE_PREFIX = """You are a code review assistant for a Python monorepo.
Rules:
1. Report only defects that would change runtime behaviour.
2. Cite the line number and the input that triggers the defect.
3. Never propose stylistic rewrites.
4. If the snippet is clean, reply with exactly: OK
"""


def review(snippet: str) -> str:
    response = client.chat.completions.create(
        model="deepseek-v4-flash",
        messages=[
            {"role": "system", "content": STABLE_PREFIX},
            {"role": "user", "content": snippet},
        ],
        temperature=0.2,
    )
    return response.choices[0].message.content


if __name__ == "__main__":
    print(review("def add(a, b):\n    return a - b\n"))

Note that the rules are numbered and ordered. Reordering them between releases is a silent cache miss, so treat that block as a versioned artefact and check the cache-hit counters whenever you edit it.

Lever two in code: drip-feed batch jobs into the off-peak window

Not all work is urgent. Re-indexing, nightly linting, doc generation, test summarisation and bulk classification can all wait. The pattern below holds jobs until the off-peak window opens, waking every few minutes so a restart or a clock change doesn't strand the queue. Set the window from the current schedule on the pricing page rather than hard-coding it — it's the one value in this article that changes.

import os
import time
from datetime import datetime, timedelta, timezone

from openai import OpenAI

client = OpenAI(
    api_key=os.environ["AICREDITS_API_KEY"],
    base_url="https://api.aicreditsapi.com/v1",
)

# Off-peak hours are published in UTC. Copy the current window from
# aicreditsapi.com/pricing into these env vars instead of hard-coding it.
OFFPEAK_START = int(os.environ.get("OFFPEAK_START_UTC", "0"))  # inclusive
OFFPEAK_END = int(os.environ.get("OFFPEAK_END_UTC", "8"))      # exclusive


def in_offpeak(now=None) -> bool:
    now = now or datetime.now(timezone.utc)
    if OFFPEAK_START <= OFFPEAK_END:
        return OFFPEAK_START <= now.hour < OFFPEAK_END
    return now.hour >= OFFPEAK_START or now.hour < OFFPEAK_END  # wraps midnight


def wait_for_offpeak(max_wait_seconds: int = 6 * 3600) -> bool:
    waited = 0.0
    while not in_offpeak() and waited < max_wait_seconds:
        now = datetime.now(timezone.utc)
        nxt = (now + timedelta(hours=1)).replace(minute=0, second=0, microsecond=0)
        nap = min((nxt - now).total_seconds(), 600)
        time.sleep(nap)
        waited += nap
    return in_offpeak()


def batch(prompts, model="deepseek-v4-flash"):
    wait_for_offpeak()
    results = []
    for prompt in prompts:
        resp = client.chat.completions.create(
            model=model,
            messages=[{"role": "user", "content": prompt}],
        )
        results.append(resp.choices[0].message.content)
    return results

Run this from a scheduler with a generous timeout, and log which window each job actually landed in. That log is what tells you whether the waiting was worth it, or whether the job would have been fine running immediately.

Flash vs pro: when the cheaper model is the more expensive choice

The cheapest call is the one you don't have to repeat. If flash needs three attempts, a parse failure and a human review to resolve an ambiguous spec, then pro at a higher rate on the first try was the better deal — in both windows.

Dimensiondeepseek-v4-flashdeepseek-v4-pro
Best forHigh-volume, well-specified work: extraction, classification, formatting, lint fixesMulti-step reasoning, ambiguous specs, long-context analysis
Relative rateThe lower-cost tier in both windowsCosts more than flash in both windows
Retry riskMay need a second pass on hard promptsUsually resolves hard prompts in one call
Off-peak benefitLarge relative saving on big batchesSame scheduling logic, applied to a bigger base
Pipeline roleDefault call for everythingEscalation tier after a failed validation or retry

A workable default: route everything to flash, validate the output, and escalate to pro when validation fails twice or the task is genuinely multi-step. Escalation should be the exception you measure, not the architecture you start with.

What to run at peak, and where AiCredits fits

Interactive traffic is usually worth peak rates. A user waiting on a response notices latency far more than they notice a rate change, so keep the user-facing path on deepseek-v4-flash at peak and move everything else — backfills, nightly jobs, bulk re-processing — into the off-peak window. If a batch is large, split it into chunks with a stable output format so a single failure costs you one chunk rather than the whole run.

AiCredits is built for developers outside China who want DeepSeek credits without a Chinese phone number or bank account: you top up with a card or PayPal, get one key that works for both deepseek-v4-flash and deepseek-v4-pro, and point the OpenAI SDK at a single base URL. Aggregators like OpenRouter are a good fit when you need to route across many providers' models; if you've decided on DeepSeek, buying credits directly keeps the billing surface small. The account also ships code-linting tools, which is quietly relevant to cost: catching obvious defects before they reach your review prompt means fewer tokens spent explaining bugs the linter would have flagged. Current peak and off-peak rates are on the pricing page.

FAQ

Does the off-peak rate apply to both models?

Yes — both deepseek-v4-flash and deepseek-v4-pro have an off-peak rate that is lower than their peak rate. The window is the same for both; only the base rate differs, with pro costing more than flash in each window. Check aicreditsapi.com/pricing for the current schedule.

Is it always worth waiting for off-peak?

No. If a job blocks a release, feeds a user-facing feature, or costs more in engineer time than it saves in tokens, run it now. Off-peak makes sense for deferrable, high-volume work: re-indexing, bulk classification, nightly linting, documentation passes.

Do cached tokens and off-peak pricing stack?

They are separate mechanisms. Caching reduces the amount of fresh input you're billed for; off-peak lowers the rate applied. A cache-friendly prompt submitted during the off-peak window benefits from both.

What happens if a batch starts in peak and finishes off-peak?

Requests are billed at the rate in force when they are processed, so the batch effectively straddles two rates. For budgeting, assume peak and treat any saving as a bonus — or simply don't start a large job within the final minutes of a window.

Am I charged for failed requests?

A request that errors before the model produces any output doesn't consume tokens. A retry, however, is a brand-new call and is billed like one, which is why deduplicating failed prompts before re-sending matters.

Try Lint in 2 seconds

Wrote something? Paste it here for a free grammar check. No account needed.

More Tools →

Related Tools

💻Code Explainer

Was this article helpful?

| Share on X Reddit Copy link

服务器宕机了?别等用户告诉你

Wakeless 梦哨 帮你 30 秒监控网站 / API / SSL 证书,宕机秒级告警到邮箱、飞书、Slack。免费档 30 个监控,永久免费,无需信用卡。

免费开始监控 →
💬
反馈意见 / Feedback ×