File size: 2,668 Bytes
bde2f3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
"""Model access map — who has tokens for what.

Updated whenever API keys change. Run with `python -m infra.model_map` from
the repo root, or `bash infra/model_map.sh` for a shell-only view.

ACTIVE providers (real keys):
  - openrouter  → DeepSeek, MiniMax, Gemini, Mistral, Llama (universal)
  - deepseek    → direct DeepSeek API
  - groq        → fast inference (llama-3.3-70b, llama-3.1-8b)

PLACEHOLDER (no real key, skipped):
  - gemini, zai, minimax, mistral-direct, kimi

Per v4.0 master stack: all hosted APIs are routed through LiteLLM proxy at
http://rmi-litellm:4000 with the sovereign OpenAI-compatible interface.
"""
from __future__ import annotations

import os
from dataclasses import dataclass


@dataclass
class Provider:
    name: str
    active: bool
    key_len: int
    key_prefix: str
    models: list[str]


def _read_env(name: str) -> str:
    return os.environ.get(name, "")


def _check(name: str, env_var: str, models: list[str], min_len: int = 30) -> Provider:
    key = _read_env(env_var)
    active = len(key) >= min_len
    return Provider(
        name=name,
        active=active,
        key_len=len(key),
        key_prefix=key[:8] if key else "",
        models=models,
    )


def get_model_map() -> list[Provider]:
    """Read all API keys from env. Returns provider status."""
    return [
        _check("openrouter", "OPENROUTER_API_KEY", [
            "deepseek/deepseek-chat", "MiniMax/MiniMax-M3",
            "google/gemini-2.5-flash", "mistralai/mistral-large-latest",
            "meta-llama/llama-3-70b-instruct",
        ]),
        _check("deepseek", "DEEPSEEK_API_KEY", ["deepseek-chat"], min_len=30),
        _check("groq", "GROQ_API_KEY", [
            "llama-3.3-70b-versatile", "llama-3.1-8b-instant",
        ]),
        _check("gemini", "GEMINI_API_KEY", ["gemini-2.5-flash"], min_len=30),
        _check("minimax", "MiniMax_API_KEY", ["MiniMax-M3"], min_len=30),
        _check("mistral", "MISTRAL_API_KEY", ["mistral-large-latest"], min_len=30),
        _check("kimi", "KIMI_API_KEY", ["kimi-k2-0711-preview"], min_len=30),
        _check("ollama-cloud", "OLLAMA_API_KEY", ["llama3.2", "qwen2.5"], min_len=30),
    ]


def print_map() -> None:
    """Print human-readable model access map."""
    print(f"{'PROVIDER':<14}  {'STATUS':<10}  {'LEN':<5}  MODELS")
    print("─" * 70)
    for p in get_model_map():
        status = "ACTIVE" if p.active else "PLACEHLD"
        models = ", ".join(p.models[:3])
        if len(p.models) > 3:
            models += f" +{len(p.models) - 3}"
        print(f"{p.name:<14}  {status:<10}  {p.key_len:<5}  {models}")


if __name__ == "__main__":
    print_map()