SDK client Gommo
Gommo Developer client
Client Gommo Developer TypeScript — npm alias @ai-gateway/client. Tích hợp qua Gommo public API (api.gommo.net, v2.api.gommo.net).
Gommo Developer client cung cấp helper có type và poll job trên host public Gommo.
npm alias
Trên npm: @ai-gateway/client. Class client: GommoClient. Sẽ đổi sang @gommo/client khi có org @gommo trên npm.
| Host | Dùng cho |
|---|---|
https://v2.api.gommo.net | Models, media jobs, upload |
https://api.gommo.net | Login, profile, chat, audio, billing |
→ Quickstart · Vòng đời request · Authentication
Lộ trình 5 phút (TypeScript)
Cùng đường vàng với Quickstart: token → models → một job ảnh → URL kết quả. Client chạy vòng poll trên v2.api.gommo.net (3.5s, max 80) — Tier A không webhook job (Webhooks).
| Bước | Việc |
|---|---|
| 1 | npm install @ai-gateway/client (bên dưới) |
| 2 | Env server: GOMMO_ACCESS_TOKEN + domain đăng ký — API credentials |
| 3 | client.models.list({ type: 'image' }) — chỉ dùng ratio / mode từ catalog |
| 4 | client.jobs.createAndWait({ ... }) — create + poll client đến resultUrl |
| 5 | Xử lý lỗi: Lỗi thường gặp · poll thủ công: Jobs |
REST: Quickstart bước 4 · Cookbook job async + poll.
Cài đặt
| Ngôn ngữ | Package | Trạng thái |
|---|---|---|
| TypeScript / JavaScript | @ai-gateway/client | v1.0.0 trên npm |
| Python | — | Dùng OpenAPI generate |
| Go | — | Dự kiến |
npm install @ai-gateway/clientCần Node 18+ hoặc truyền fetch tùy chỉnh.
Contributors (repo này)
Source: packages/gateway-client. Dev local: npm run client:build rồi npm install ./packages/gateway-client.
Khi nào dùng client
- App Gommo — client có type trên Gommo public API (xem Authentication cho login và
baseUrl) - HTTP thuần — Gommo public API với
fetchhoặc OpenAPI
Agent SDK
Multi-turn agents: dùng client.chat + orchestration, hoặc MCP & agents cho Cursor IDE.
Recipe không cần package: Cookbook.
Ví dụ nhanh (bước 4)
import { GommoClient, modelSlug, parseModelsList, pickFirstRatio } from '@ai-gateway/client';
const client = new GommoClient({
accessToken: process.env.GOMMO_ACCESS_TOKEN,
domain: process.env.GOMMO_DOMAIN ?? 'YOUR_REGISTRATION_DOMAIN',
});
const catalog = await client.models.list({ type: 'image' });
const models = parseModelsList(catalog);
const m = models[0];
const job = await client.jobs.createAndWait({
type: 'image',
modelSlug: modelSlug(m),
fields: { prompt: 'A red apple', ratio: pickFirstRatio(m) },
});
console.log(job.data?.resultUrl);createAndWait = create({ wait: true }): create async trên Gommo, SDK pollUntilDone mặc định 3500ms / 80 lần.
Auth và chat dùng api.gommo.net — xem Authentication.
TypeScript SDK
| Guide | Nội dung |
|---|---|
| Tổng quan | Bản đồ resources |
| Installation | npm, env, baseUrl |
| Authentication | login, register (gateway), đổi mật khẩu, Bearer, me |
| Models | list, catalog helpers |
| Jobs | create, wait, poll |
| Chat | send, stream SSE |
| Upload | image, video multipart |
| Audio | voices, TTS, lists |
| Billing | Self-host /billing/* — Sắp có trên Gommo |
| Errors | GatewayError, codes |
