File size: 2,141 Bytes
bdf8f9d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# backend/config/ai_pricing.py
# DeepSeek V4 API Pricing Configuration
# TODO: Review pricing after 2026-05-31

from datetime import datetime, timezone

DEEPSEEK_PRICING = {
    "deepseek-v4-pro": {
        "promotional": {
            "active": True,
            "expires_utc": datetime(2026, 5, 31, 15, 59, 0, tzinfo=timezone.utc),
            "input_cache_hit_per_1m": 0.003625,
            "input_cache_miss_per_1m": 0.435,
            "output_per_1m": 0.87,
        },
        "full_price": {
            "input_cache_hit_per_1m": 0.0145,
            "input_cache_miss_per_1m": 1.74,
            "output_per_1m": 3.48,
        },
    },
    "deepseek-v4-flash": {
        "input_cache_hit_per_1m": 0.0028,
        "input_cache_miss_per_1m": 0.14,
        "output_per_1m": 0.28,
    },
}


def get_active_pricing(model_id: str) -> dict:
    """Returns the currently active pricing tier for a given model."""
    model = DEEPSEEK_PRICING.get(model_id)
    if not model:
        raise ValueError(f"Unknown model: {model_id}")
    if "promotional" in model:
        promo = model["promotional"]
        if promo["active"] and datetime.now(timezone.utc) < promo["expires_utc"]:
            return {
                "input_cache_hit_per_1m": promo["input_cache_hit_per_1m"],
                "input_cache_miss_per_1m": promo["input_cache_miss_per_1m"],
                "output_per_1m": promo["output_per_1m"],
                "is_promotional": True,
                "promo_expires_utc": promo["expires_utc"].isoformat(),
            }
        return {**model["full_price"], "is_promotional": False}
    return {**model, "is_promotional": False}


def get_full_pricing(model_id: str) -> dict:
    """Returns the full (non-promotional) pricing for a model."""
    model = DEEPSEEK_PRICING.get(model_id)
    if not model:
        raise ValueError(f"Unknown model: {model_id}")
    if "full_price" in model:
        return model["full_price"]
    return {
        "input_cache_hit_per_1m": model["input_cache_hit_per_1m"],
        "input_cache_miss_per_1m": model["input_cache_miss_per_1m"],
        "output_per_1m": model["output_per_1m"],
    }