โหมดการเชื่อมต่อ
Advanced / operator docs
ซ่อนจาก sidebar Models & routing เริ่มต้น — ลิงก์จาก Deploy → Self-host ขั้นสูง Integrator Tier A ใช้ Gommo public API (Mode A) เท่านั้น
สามวิธีเข้าถึง Gommo โหมด A Direct (แนะนำ) เรียก v2.api.gommo.net และ api.gommo.net โดยตรง โหมด B/C ผ่าน self-host Gommo Developer — ทางเลือกสำหรับ dev, portal billing หรือ BYOK
เปรียบเทียบเร็ว
| โหมด A Direct | โหมด B REST | โหมด C Proxy | |
|---|---|---|---|
| Base URL | v2.api.gommo.net / api.gommo.net | {gateway}/gateway | {gateway} |
| Auth | Bearer / form upstream | Authorization: Bearer | ส่งต่อ headers + body |
| Domain ฝั่ง client | ต้องมีใน form | ทางเลือก (เซิร์ฟเวอร์ GOMMO_API_DOMAIN) | ต้องมีใน form |
| ซ่อน URL upstream | ไม่ | ใช่ | ใช่ |
| Poll / wrap | ทำเอง | wait: true ในตัว | Gommo envelope ดิบ |
| รูปแบบ response | Gommo native | { success, data, message, code } | Gommo native |
| เหมาะสำหรับ | Production — แนะนำ | Self-host JSON REST | FE Gommo legacy drop-in |
{gateway} = http://localhost:3001 (dev) หรือ URL API production
โหมด A — Direct Gommo
เรียกโฮสต์ upstream โดยตรงจาก backend ที่เชื่อถือได้ ไม่มี gateway ในเส้นทาง
งานมีเดีย V2:
POST https://v2.api.gommo.net/ai/jobs/image/{modelSlug}
Authorization: Bearer {token}
Content-Type: application/x-www-form-urlencoded
domain={GOMMO_API_DOMAIN}&project_id=default&prompt=...&ratio=...Auth, แชท, เสียง:
POST https://api.gommo.net/api/apps/go-mmo/auth/login
POST https://api.gommo.net/api/apps/go-mmo/ai/me
POST https://api.gommo.net/api/v2/chat
POST https://api.gommo.net/ai/audioใช้เมื่อไม่พึ่ง gateway — เช่น แอปมือถือที่มี backend เอง หรือบริการภายในที่เชื่อม Gommo แล้ว
คุณต้อง poll เอง
Gommo ไม่ webhook เมื่องานเสร็จ ทำ poll (ช่วง 3.5s ~80 ครั้ง) หรือใช้โหมด B wait: true
โหมด B — Gateway REST
Coming to Gommo platform
โหมด B (/gateway/*, wait: true, JSON REST) เป็น preview บน repo นี้ integrator production ควรใช้ โหมด A (host public Gommo) โหมด B จะรวมเข้า API แพลตฟอร์ม Gommo อย่างเป็นทางการ
JSON API บน /gateway/* gateway แปล REST body เป็น form call upstream และ poll ทางเลือก
เติม domain อัตโนมัติ: ถ้า client ไม่ส่ง domain gateway inject GOMMO_API_DOMAIN จาก env เซิร์ฟเวอร์
| Gateway endpoint | เทียบเท่า upstream |
|---|---|
GET /gateway/models?type= | POST /ai/models (v2) |
POST /gateway/jobs/:type | POST /ai/jobs/:type/:slug |
GET /gateway/jobs/:id?media= | poll งาน |
POST /gateway/upload/image | POST /ai/upload/image |
POST /gateway/upload/video | POST /ai/upload/video |
POST /gateway/chat | POST /api/v2/chat |
POST /gateway/audio/voices | POST /ai/audio |
POST /gateway/audio/tts | TTS ผ่าน platform |
GET /gateway/audio/lists | รายการเสียง |
Auth: Authorization: Bearer {user_access_token}
ตัวอย่างสร้างงาน:
POST /gateway/jobs/image
Authorization: Bearer {token}
Content-Type: application/json
{
"modelSlug": "flux-dev",
"wait": true,
"fields": {
"prompt": "A sunset",
"ratio": "16:9"
}
}ข้อผิดพลาด:
{ "success": false, "message": "…", "code": "VALIDATION_ERROR" }ทางเลือกเมื่อ self-host gateway — JSON REST, wait: true, portal billing
โหมด C — Gateway proxy
ส่งต่อโปร่งใส — path เดียวกับ Gommo แต่ base URL เป็น gateway
| Mount บน gateway | Upstream | หมายเหตุ |
|---|---|---|
/th/v2/* | GOMMO_API_BASE_URL | ตัด /th/v2 |
/th/ai/* | GOMMO_AUTH_BASE_URL | |
/th/api/v2/* | GOMMO_AUTH_BASE_URL | Stream สำหรับ /th/chat หรือ SSE |
/th/api/apps/go-mmo/* | GOMMO_AUTH_BASE_URL | Login, me, balances |
ตัวอย่าง map URL:
POST /v2/ai/jobs/image/flux-dev → POST https://v2.api.gommo.net/ai/jobs/image/flux-dev
POST /api/v2/chat → POST https://api.gommo.net/api/v2/chat
POST /api/apps/go-mmo/auth/login → POST https://api.gommo.net/api/apps/go-mmo/auth/login- ขีด body 50 MB (raw)
- Pipe stream สำหรับแชท / SSE
- Form body ต้องมี
domain— ใช้GOMMO_API_DOMAIN(ตรงโดเมนลงทะเบียนผู้ใช้)
ใช้เมื่อย้าย FE Gommo ที่มีอยู่: เปลี่ยน base URL เป็น gateway คง path และ form body
Auth ข้ามโหมด
| ตระกูล route | สไตล์ token |
|---|---|
งาน V2 (/th/v2, /gateway/jobs) | Authorization: Bearer |
| Route form platform | access_token ใน form (+ Bearer บน /th/api/v2 เมื่อต้องการ) |
| Login | ไม่มี token — คืน access_token |
แคตตาล็อกและกฎเดียวกัน
ทั้งสามโหมด:
- ลิสต์โมเดลก่อนสร้างงาน — ห้ามเดา
ratio/mode/resolution/duration - ใช้ Gommo
access_tokenของผู้ใช้ - เคารพ semantics งาน async (poll หรือ
wait: true)
