Chat
Gommo Developer client
Client Gommo Developer TypeScript — npm alias @ai-gateway/client เรียก Gommo public API (api.gommo.net, v2.api.gommo.net)
Upstream ต้องการ messages ไม่ว่าง
ทางเลือก language (form upstream เช่น EN, VI) — ไม่ส่ง → client ใช้ VI (เหมือน gateway)
Chat (JSON หรือ SSE)
action=chat อาจได้ SSE แม้คาด JSON — รวม choices[0].delta.content จากบรรทัด data: จน [DONE]
typescript
const res = await client.chat.send({
action: 'chat',
query: 'Hello',
language: 'EN',
messages: [{ role: 'user', text: 'Hello' }],
});ทางเลือก: sessionId, model, server, agentId
Stream (SSE)
typescript
for await (const chunk of client.chat.stream({
query: 'Tell a short story',
language: 'EN',
messages: [{ role: 'user', text: 'Tell a short story' }],
})) {
process.stdout.write(chunk);
}แคตตาล็อกโมเดล
typescript
const catalog = await client.chat.listModels();Tier A: POST /api/v2/chat action=models — Gateway: GET /gateway/chat-models
ตั้งโมเดล
typescript
await client.chat.send({
action: 'set_model',
messages: [{ role: 'user', text: 'hi' }],
model: 'gpt-5.5::cheap',
});ซิงค์ session (เก็บบนเซิร์ฟเวอร์)
typescript
const sessions = await client.chatSessions.listSessions({ limit: 20 });
await client.chatSessions.saveMessage({
sessionId: '…',
messageId: '…',
role: 'user',
text: 'Hello',
});ดู Chat reference — Reading responses (JSON vs SSE) และ Chat sessions
