💰 Pricing — Upstream rate reference

Gateway เป็น infrastructure provider — ลูกค้าตัดสินใจฝั่งระบบของลูกค้าเองว่าจะ pay tier ไหน, แล้วคำนวณค่าใช้จ่ายต่อ call จากตัวเลขในหน้านี้ × token counts ใน usage.per_step[] ของ response. คุณ markup เท่าไหร่กับ end-user ของคุณก็ไม่ใช่เรื่องของ gateway.

⚠️ Rates ในตารางนี้คือ rate ของ upstream provider (Google AI, Anthropic, Ollama Cloud) ตามที่เราเสีย — ไม่ใช่ rate ที่ gateway เก็บกับคุณ. Provider เปลี่ยน rate ของเขาเมื่อไหร่ ตัวเลขจะอัพเดตที่นี่. โดย default เราไม่ markup — คุณจ่ายเท่า upstream rate × token usage ของคุณ. (Negotiate ดีลกับ admin ถ้าต้องการ enterprise rate / discount.)

Per-tier rates (USD per million tokens)

TierBackendInput $/M tokOutput $/M tokSpeed (judge p95)PDPA
"standard"cloud-fast (Ollama Cloud GPT-OSS 120B)0.000.00variable, 3-32sNONE · REDACTABLE · SENSITIVE (pinned local)
"premium"Gemini 2.5 Flash (Google AI)0.0750.30~2-5s reliableNONE · REDACTABLE (PII redacted)
"frontier"Claude Haiku 4.5 (Anthropic)0.804.00~1.7-4sNONE only (highest tier offshore)

Equivalent THB rates (approximate, exchange rate variable): Premium ~฿2.6 input + ฿10.5 output per million tokens · Frontier ~฿28 input + ฿140 output per million tokens (at ฿35/USD).

🗲 Prompt cache (Frontier only, auto): เมื่อ system prefix (รวม knowledge-pack chunks) ≥ 3,500 chars, gateway จะแนบ cache_control: ephemeral ให้อัตโนมัติ. Response header X-Gateway-Prompt-Cache: applied = ทำแล้ว. ค่าใช้จ่ายจริง: cache write ครั้งแรก ~125% ของ input rate, cache read ครั้งถัดไป ~10% (5-min TTL). Effective Frontier input rate ลงเหลือ ~$0.08/M tokens (จาก $0.80) สำหรับ prefix ที่ซ้ำๆ.

How to compute cost per call (client-side)

Every wizard / smart / compose response includes a usage block with per-backend token counts. Multiply by the rates above, sum, done.

// Response shape
{
  "polished_text": "...",
  "compose": { ... },
  "usage": {
    "prompt_tokens": 2184,
    "completion_tokens": 1329,
    "total_tokens": 3513,
    "per_step": [
      {"public_id": "local-writer-th", "tier": "local",
       "prompt_tokens": 962, "completion_tokens": 255},
      {"public_id": "frontier-gemini", "tier": "frontier",
       "prompt_tokens": 1222, "completion_tokens": 1074}
    ]
  }
}
# Python — sum upstream cost across paid steps
RATES = {
  "frontier-gemini":  {"in": 0.075/1e6, "out": 0.30/1e6},
  "frontier-claude":  {"in": 0.80/1e6,  "out": 4.00/1e6},
}
def upstream_cost_usd(resp):
    total = 0.0
    for step in resp["usage"]["per_step"]:
        r = RATES.get(step["public_id"])
        if r:  # local/cloud-fast steps cost nothing
            total += (step["prompt_tokens"] * r["in"]
                      + step["completion_tokens"] * r["out"])
    return total

# Charge YOUR user whatever multiple of this fits your business
your_charge = upstream_cost_usd(resp) * YOUR_MARKUP_FACTOR

Free tier (no token-billed surfaces)

SurfaceCostWhy free
Embeddings (BGE-M3 Thai)฿0Local model on DGX, no token bill
Charts render (matplotlib)฿0Deterministic Python, no LLM
Tools (web_search / read_url / read_file)฿0SearXNG private + local fetch; only API surface is rate-limited
Knowledge query / list packs฿0Local BGE-M3 + disk read
Health / models / audit฿0Metadata only
Standard tier judge (cloud-fast)฿0Free Ollama Cloud, variable performance

Rate limits (not pricing — separate)