Skip to content

Xác thực ​

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

Login ​

typescript
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 được lưu trên client tự động

Token có sẵn ​

typescript
const client = new GommoClient({
  accessToken: process.env.GOMMO_ACCESS_TOKEN,
  domain: process.env.GOMMO_DOMAIN ?? 'YOUR_REGISTRATION_DOMAIN',
});

Login và me() gọi api.gommo.net; media jobs dùng v2.api.gommo.net tự động.

User profile + credits ​

typescript
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;

Dùng username cho Billing topup khi dùng billing trên self-hosted gateway.

Manual token update ​

typescript
client.setAccessToken(newToken);

Đăng ký (gateway self-host) ​

Cần env merchant trên gateway. Domain do server điền — không gửi trong body JSON.

typescript
const client = new GommoClient({
  transport: 'gateway',
  gatewayBaseUrl: process.env.GATEWAY_URL,
});

await client.auth.register({
  email: '[email protected]',
  password: 'secret12',
  phone: '0900000000',
});

auth.register() chỉ có khi transport: 'gateway'.

→ Tài khoản — đăng ký

Đổi mật khẩu đăng nhập ​

API public (form trên api.gommo.net):

typescript
await client.auth.changePassword({
  currentPassword: process.env.CURRENT_PASSWORD!,
  newPassword: process.env.NEW_PASSWORD!,
  language: 'VI',
});

Self-hosted gateway (transport: 'gateway'):

typescript
await client.auth.changePassword({
  currentPassword: '…',
  newPassword: '…',
});

Khác set_password trên AI project. Xem Cài đặt tài khoản — đổi mật khẩu.

Chuyển credit (P2P) ​

Gommo public API (form):

typescript
await client.auth.transferCredits({
  username: 'recipient_username',
  value: 10_000,
  message: 'Ghi chú chuyển',
  language: 'VI',
});

Gateway self-host (transport: 'gateway', Bearer):

typescript
await client.auth.transferCredits({
  username: 'recipient_username',
  value: 10_000,
  message: 'Ghi chú chuyển',
});

Upstream có thể HTTP 200 + { error: 1, message: "…" } — kiểm tra error / success trên envelope trả về. Không phải merchant /admin/credits/send. Xem Chuyển credit.

Lịch sử giao dịch (ledger) ​

Gommo public API (form):

typescript
const ledger = await client.auth.listPaymentsHistory({
  limit: 500,
  time_start: 0,
  time_end: 0,
  language: 'VI',
});
// ledger.data — mảng dòng; cộng plus/minus phía client

Gateway self-host (transport: 'gateway', Bearer):

typescript
await client.auth.listPaymentsHistory({ limit: 500, source: 'sendBalances' });

Không phải /api/v2/usage-history. Xem Lịch sử giao dịch.

Thiết bị đăng nhập ​

typescript
const sessions = await client.auth.listDevices({
  language: 'VI',
  current_device_id: deviceId,
  device_id: deviceId,
  device_name: 'Browser 1',
});
await client.auth.renameDevice({ device_id: '…', device_name: 'Máy làm việc' });
await client.auth.disableDevice({ device_id: '…' });

Xem Thiết bị đăng nhập.

Ticket hỗ trợ ​

typescript
await client.auth.listSupportTickets({ language: 'VI' });
await client.auth.createSupportTicket({
  subject: 'Tiêu đề',
  issue_type: 'bug',
  description: 'Mô tả…',
});
await client.auth.getSupportTicketDetail({ ticket_id_base: 'SUP-20260925-7022' });
await client.auth.replySupportTicket({
  ticket_id_base: 'SUP-20260925-7022',
  content: 'Nội dung trả lời…',
});

Xem Ticket hỗ trợ.

Chương trình đối tác ​

typescript
await client.auth.getPartnerProgramStatus({ language: 'EN', lang: 'en' });
await client.auth.applyPartnerProgram({
  bank_name: '…',
  account_name: '…',
  account_number: '…',
  contact: '…',
  email: '[email protected]',
  reason: '…',
  accept_rules: 1,
});

Xem Chương trình đối tác.

Creator Rewards ​

typescript
await client.auth.getCreatorRewardsStatus({ language: 'EN' });
await client.auth.getCreatorRewardsPool({ language: 'EN' });
await client.auth.applyCreatorRewards({
  payout_pref: 'credit',
  contact: '…',
  email: '[email protected]',
  reason: '…',
  accept_rules: 1,
});

Xem Creator Rewards.