Skip to content

Chat ​

Gommo Developer client

Client Gommo Developer TypeScript — npm alias @ai-gateway/client. Gọi Gommo public API (api.gommo.net, v2.api.gommo.net).

→ Gommo public API · Roadmap

Upstream yêu cầu messages không rỗng.

Tùy chọn language (form upstream, ví dụ EN, VI). Bỏ trống → client gửi VI (giống gateway).

Chat (JSON hoặc SSE) ​

action=chat có thể trả SSE dù bạn mong JSON. Ghép choices[0].delta.content từ các dòng data: đến [DONE].

typescript
const res = await client.chat.send({
  action: 'chat',
  query: 'Hello',
  language: 'VI',
  messages: [{ role: 'user', text: 'Hello' }],
});

Tùy chọn: sessionId multi-turn; model, server, agentId.

Stream (SSE) ​

typescript
for await (const chunk of client.chat.stream({
  query: 'Tell a short story',
  language: 'VI',
  messages: [{ role: 'user', text: 'Tell a short story' }],
})) {
  process.stdout.write(chunk);
}

Danh mục model ​

typescript
const catalog = await client.chat.listModels();

Tier A: POST /api/v2/chat action=models. Gateway: GET /gateway/chat-models.

Set model ​

typescript
await client.chat.send({
  action: 'set_model',
  messages: [{ role: 'user', text: 'hi' }],
  model: 'gpt-5.5::cheap',
});

Đồng bộ session (lưu server) ​

Khác sessionId trên chat — lưu message trên Gommo:

typescript
const sessions = await client.chatSessions.listSessions({ limit: 20 });

await client.chatSessions.saveMessage({
  sessionId: '…',
  messageId: '…',
  role: 'user',
  text: 'Xin chào',
});

Xem Chat reference — Reading responses (JSON vs SSE) và Chat sessions.