เลือกโหมด integration
เลือกโหมดครั้งเดียวต่อ client surface ทุกโหมดใช้ token และ catalog เดียวกัน
Decision tree
มี FE Gommo ที่ใช้ /v2 และ /api/v2 อยู่แล้ว?
├─ ใช่ → โหมด C (เปลี่ยนแค่ base URL ของ gateway)
└─ ไม่
├─ เรียก Gommo upstream โดยตรงได้? (แนะนำ)
│ ├─ ได้ → โหมด A Direct (v2.api.gommo.net + api.gommo.net)
│ └─ ไม่ได้
│ └─ ต้องการ billing, BYOK หรือ wait: true บน self-host?
│ ├─ ใช่ → โหมด B REST (/gateway/*)
│ └─ ไม่ → โหมด A Direct (ง่ายสุด — ไม่พึ่ง gateway)ตาม use case
| Use case | แนะนำ | เหตุผล |
|---|---|---|
| แอป/backend ใหม่ | โหมด A | Public API ไม่พึ่ง gateway |
| Mobile ผ่าน backend | โหมด A | Direct upstream; poll เอง |
| Script batch | โหมด A หรือ B | A = ไม่มี infra; B = wait: true self-host |
| FE site-ai / Gommo legacy | โหมด C | เปลี่ยน base URL น้อยที่สุด |
| ต้องการ billing/BYOK gateway | โหมด B | โอนเงินผ่านธนาคาร, BYOK, JSON errors |
| Playground dev | โหมด A หรือ B/C | Playground แสดง public URL; dev อาจ proxy |
| Browser cross-origin + self-host | โหมด B + CORS | REST + GATEWAY_CORS_ORIGIN |
| Agent / automation | โหมด A หรือ Gommo MCP | HTTP direct หรือ MCP hosted |
Trade-offs
โหมด A — Direct (แนะนำ)
ข้อดี: ไม่พึ่ง gateway; latency ต่ำ; host Gommo อย่างเป็นทางการ
ข้อเสีย: สอง hostname; poll เอง; domain ในทุก form
โหมด B — REST
ข้อดี: prefix เดียว; JSON; poll ในตัว; inject domain; billing/BYOK
ข้อเสีย: ต้อง self-host gateway; shape ต่างจาก Gommo raw
โหมด C — Proxy
ข้อดี: drop-in FE Gommo; คง envelope upstream
ข้อเสีย: client ยังส่ง domain; ไม่มี wait: true
เปลี่ยนโหมดภายหลัง
| จาก → ไป | ความพยายาม |
|---|---|
| A → B | ปานกลาง — ชี้ gateway, JSON body |
| C → B | ปานกลาง — เขียนใหม่ /gateway/* |
| B → A | ต่ำ — public hosts, form + poll client |
| B → C | ต่ำสำหรับ media — map REST กลับ /th/v2 |
Token และ slug เหมือนกันทุกโหมด
Checklist
- [ ] list models และ copy
ratioจาก response - [ ] ยืนยัน
domainส่งที่ไหน (form client สำหรับโหมด A) - [ ] วางแผน poll (3.5s × 80 หรือ gateway
wait: true) - [ ] CORS เฉพาะเมื่อ browser เรียก self-host gateway (โหมด B)
- [ ] merchant token ไม่อยู่ client
