การยืนยันตัวตน
Gommo Developer client
Client Gommo Developer TypeScript — npm alias @ai-gateway/client เรียก Gommo public API (api.gommo.net, v2.api.gommo.net)
Login
import { GommoClient } from '@ai-gateway/client';
const client = new GommoClient({ domain: process.env.GOMMO_DOMAIN ?? 'YOUR_REGISTRATION_DOMAIN' });
const { access_token } = await client.auth.login({
email: '[email protected]',
password: 'secret',
});
// Token ถูกเก็บบน client อัตโนมัติToken ที่มีอยู่แล้ว
const client = new GommoClient({
accessToken: process.env.GOMMO_ACCESS_TOKEN,
domain: process.env.GOMMO_DOMAIN ?? 'YOUR_REGISTRATION_DOMAIN',
});Login และ me() เรียก api.gommo.net; media jobs ใช้ v2.api.gommo.net โดยอัตโนมัติ
User profile + credits
const me = await client.auth.me(process.env.GOMMO_DOMAIN ?? 'YOUR_REGISTRATION_DOMAIN');
const credits = me.balancesInfo?.credits_ai;
const username = me.userInfo?.username ?? me.data?.username;ใช้ username สำหรับ Billing topup เมื่อใช้ billing บน self-hosted gateway
Manual token update
client.setAccessToken(newToken);สมัคร (gateway self-host)
ต้องตั้ง env merchant บน gateway domain มาจากเซิร์ฟเวอร์ — ไม่ส่งใน body JSON
const client = new GommoClient({
transport: 'gateway',
gatewayBaseUrl: process.env.GATEWAY_URL,
});
await client.auth.register({
email: '[email protected]',
password: 'secret12',
phone: '0900000000',
});auth.register() ใช้ได้เมื่อ transport: 'gateway' เท่านั้น
เปลี่ยนรหัส login
Public API (form บน api.gommo.net):
await client.auth.changePassword({
currentPassword: process.env.CURRENT_PASSWORD!,
newPassword: process.env.NEW_PASSWORD!,
language: 'TH',
});Self-hosted gateway (transport: 'gateway'):
await client.auth.changePassword({
currentPassword: '…',
newPassword: '…',
});ไม่ใช่ set_password ของ AI project ดู การตั้งค่าบัญชี — เปลี่ยนรหัสผ่าน
โอน credit (P2P)
Gommo public API (form):
await client.auth.transferCredits({
username: 'recipient_username',
value: 10_000,
message: 'Transfer note',
language: 'EN',
});Gateway self-host (transport: 'gateway', Bearer):
await client.auth.transferCredits({
username: 'recipient_username',
value: 10_000,
message: 'Transfer note',
});Upstream อาจ HTTP 200 + { error: 1, message: "…" } — ตรวจ error / success บน envelope ที่ได้ ไม่ใช่ merchant /admin/credits/send ดู โอน credit
ประวัติธุรกรรม (ledger)
Gommo public API (form):
const ledger = await client.auth.listPaymentsHistory({
limit: 500,
time_start: 0,
time_end: 0,
language: 'EN',
});
// ledger.data — แถวในอาร์เรย์; รวม plus/minus ฝั่ง clientGateway self-host (transport: 'gateway', Bearer):
await client.auth.listPaymentsHistory({ limit: 500, source: 'sendBalances' });ไม่ใช่ /api/v2/usage-history ดู ประวัติธุรกรรม
อุปกรณ์เซสชัน
Public API (form บน api.gommo.net):
const sessions = await client.auth.listDevices({
language: 'TH',
current_device_id: deviceId,
device_id: deviceId,
device_name: 'Browser 1',
});Self-hosted gateway:
await client.auth.registerDevice({ language: 'TH' });
await client.auth.renameDevice({ device_id: '…', device_name: 'Work laptop' });
await client.auth.disableDevice({ device_id: '…' });ตั๋วซัพพอร์ต
await client.auth.listSupportTickets({ language: 'TH' });
await client.auth.createSupportTicket({
subject: 'หัวข้อ',
issue_type: 'bug',
description: 'รายละเอียด…',
});
await client.auth.getSupportTicketDetail({ ticket_id_base: 'SUP-20260925-7022' });
await client.auth.replySupportTicket({
ticket_id_base: 'SUP-20260925-7022',
content: 'ข้อความตอบ…',
});ดู ตั๋วซัพพอร์ต
โปรแกรมพาร์ทเนอร์
await client.auth.getPartnerProgramStatus({ language: 'TH', lang: 'th' });
await client.auth.applyPartnerProgram({
bank_name: '…',
account_name: '…',
account_number: '…',
contact: '…',
email: '[email protected]',
reason: '…',
accept_rules: 1,
});Creator Rewards
await client.auth.getCreatorRewardsStatus({ language: 'TH' });
await client.auth.getCreatorRewardsPool({ language: 'TH' });
await client.auth.applyCreatorRewards({
payout_pref: 'credit',
contact: '…',
email: '[email protected]',
reason: '…',
accept_rules: 1,
});