แชท (agent)
Upstream: POST https://api.gommo.net/api/v2/chat (form urlencoded)
Playground
Playground — worker Platform → Chat (ค้นหา chat) หรือ sidebar เมื่อ ?dev=1 · UI แชท: /th/app/chat/
| การดำเนินการ | Gommo public API |
|---|---|
| Chat agent | POST https://api.gommo.net/api/v2/chat action=chat |
| Chat stream | POST https://api.gommo.net/api/v2/chat action=stream (SSE) |
| Set model | POST https://api.gommo.net/api/v2/chat action=set_model |
Form fields (Direct)
| Field | หมายเหตุ |
|---|---|
action | chat, stream, set_model, models |
access_token | User token (หรือ Bearer header) |
domain | โดเมนที่สมัคร เช่น <registration-domain> |
query | ข้อความผู้ใช้ |
messages | JSON array — ต้องไม่ว่าง สำหรับ action=chat |
language | ทางเลือก — locale upstream (capture VI, EN) |
chat_id | UUID session (form upstream; gateway JSON ใช้ sessionId) |
ฟิลด์ขั้นสูง: model, server, agent_id, chat_tools, device_* — gateway เติมค่าเริ่มต้นเมื่อไม่ส่ง
WARNING
Upstream action=chat ต้องมี messages ไม่ว่าง ส่งอย่างน้อย { "role": "user", "text": "..." }
action=stream → response SSE
Chat (agent)
curl.exe -X POST "https://api.gommo.net/api/v2/chat" ^
-H "Content-Type: application/x-www-form-urlencoded" ^
-d "action=chat&access_token=%TOKEN%&domain=%REGISTRATION_DOMAIN%&query=Hello&messages=[{\"role\":\"user\",\"text\":\"Hello\"}]"$d = $env:GOMMO_API_DOMAIN; if (-not $d) { throw 'Set GOMMO_API_DOMAIN to the user registration domain (dealer)' }
$messages = '[{"role":"user","text":"Hello"}]'
$form = "action=chat&access_token=$env:TOKEN&domain=$d&query=Hello&messages=$messages"
Invoke-RestMethod -Method POST -Uri "https://api.gommo.net/api/v2/chat" `
-ContentType "application/x-www-form-urlencoded" -Body $formStream
curl.exe -N -X POST "https://api.gommo.net/api/v2/chat" ^
-H "Content-Type: application/x-www-form-urlencoded" ^
-d "action=stream&access_token=%TOKEN%&domain=%REGISTRATION_DOMAIN%&query=Tell a short story&messages=[{\"role\":\"user\",\"text\":\"Tell a short story\"}]"รายการ model (action=models)
POST …/api/v2/chat — action=models · response JSON catalog · ใช้ id กับ set_model
Mode B: GET {gateway}/gateway/chat-models
Set model
action=set_model + chat_id + model
อ่าน response (JSON vs SSE)
stream (และบางครั้ง chat) คืน SSE — รวม choices[0].delta.content จนถึง [DONE] ไม่มี field "text" เต็มประโยคในบody เดียว
Chat sessions (sync server)
POST …/api/v2/ai-chat-sessions — action: save_message | list_sessions | get_messages | get_session
Mode B: POST {gateway}/gateway/chat-sessions JSON (sessionId → session_id)
Self-host (operator เท่านั้น)
POST {gateway}/gateway/chat JSON — Bearer; language ทางเลือก (ค่าเริ่มต้น gateway VI) Playground Chat มีช่อง language
