Gateway เป็น infrastructure provider — ลูกค้าตัดสินใจฝั่งระบบของลูกค้าเองว่าจะ pay tier ไหน, แล้วคำนวณค่าใช้จ่ายต่อ call จากตัวเลขในหน้านี้ × token counts ใน usage.per_step[] ของ response. คุณ markup เท่าไหร่กับ end-user ของคุณก็ไม่ใช่เรื่องของ gateway.
| Tier | Backend | Input $/M tok | Output $/M tok | Speed (judge p95) | PDPA |
|---|---|---|---|---|---|
"standard" | cloud-fast (Ollama Cloud GPT-OSS 120B) | 0.00 | 0.00 | variable, 3-32s | NONE · REDACTABLE · SENSITIVE (pinned local) |
"premium" | Gemini 2.5 Flash (Google AI) | 0.075 | 0.30 | ~2-5s reliable | NONE · REDACTABLE (PII redacted) |
"frontier" | Claude Haiku 4.5 (Anthropic) | 0.80 | 4.00 | ~1.7-4s | NONE 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 ที่ซ้ำๆ.
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
| Surface | Cost | Why free |
|---|---|---|
| Embeddings (BGE-M3 Thai) | ฿0 | Local model on DGX, no token bill |
| Charts render (matplotlib) | ฿0 | Deterministic Python, no LLM |
| Tools (web_search / read_url / read_file) | ฿0 | SearXNG private + local fetch; only API surface is rate-limited |
| Knowledge query / list packs | ฿0 | Local BGE-M3 + disk read |
| Health / models / audit | ฿0 | Metadata only |
| Standard tier judge (cloud-fast) | ฿0 | Free Ollama Cloud, variable performance |