Gommo client SDKs
Gommo Developer client
Client Gommo Developer TypeScript — npm alias @ai-gateway/client เรียก Gommo public API (api.gommo.net, v2.api.gommo.net)
Gommo Developer client ให้ helper แบบ typed และ poll job บน host public ของ Gommo
npm alias
บน npm: @ai-gateway/client class หลัก: GommoClient จะเปลี่ยนเป็น @gommo/client เมื่อมี org @gommo บน npm
| Host | ใช้สำหรับ |
|---|---|
https://v2.api.gommo.net | Models, media jobs, upload |
https://api.gommo.net | Login, profile, chat, audio, billing |
→ Quickstart · วงจร request · Authentication
เส้นทาง 5 นาที (TypeScript)
เส้นทางเดียวกับ Quickstart: token → models → งานรูปหนึ่งงาน → URL ผลลัพธ์ client รัน poll บน v2.api.gommo.net (3.5s สูงสุด 80) — Tier A ไม่มี webhook งาน (Webhooks)
| ขั้น | ทำอะไร |
|---|---|
| 1 | npm install @ai-gateway/client (ด้านล่าง) |
| 2 | env บน server: GOMMO_ACCESS_TOKEN + domain ลงทะเบียน — API credentials |
| 3 | client.models.list({ type: 'image' }) — ใช้ ratio / mode จากแคตตาล็อกเท่านั้น |
| 4 | client.jobs.createAndWait({ ... }) — create + poll ฝั่ง client จนได้ resultUrl |
| 5 | แก้ปัญหา: ข้อผิดพลาดที่พบบ่อย · poll เอง: Jobs |
REST: Quickstart ขั้น 4 · Cookbook async + poll
การติดตั้ง
| ภาษา | Package | สถานะ |
|---|---|---|
| TypeScript / JavaScript | @ai-gateway/client | v1.0.0 บน npm |
| Python | — | ใช้ generate จาก OpenAPI |
| Go | — | วางแผน |
npm install @ai-gateway/clientต้องการ Node 18+ (fetch ในตัว) หรือส่ง custom fetch ใน options
ผู้มีส่วนร่วม (repo นี้)
ซอร์ส: packages/gateway-client Dev ในเครื่อง: npm run client:build แล้ว npm install ./packages/gateway-client ในแอป
เมื่อใช้ client
- แอป Gommo — client แบบ typed บน Gommo public API (ดู Authentication สำหรับ login และ
baseUrl) - HTTP ตรง — Gommo public API กับ
fetchหรือ OpenAPI
Agent SDK
Multi-turn agents: ใช้ client.chat + orchestration ของคุณ หรือ MCP & agents สำหรับ tools ใน Cursor IDE
สำหรับสูตร copy-paste ไม่ใช้ package ดู Cookbook
ตัวอย่างเร็ว (ขั้น 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 slug = modelSlug(m);
const ratio = pickFirstRatio(m);
const job = await client.jobs.createAndWait({
type: 'image',
modelSlug: slug,
fields: { prompt: 'A red apple', ratio },
});
console.log(job.data?.resultUrl);createAndWait = create({ wait: true }): create แบบ async บน Gommo แล้ว SDK pollUntilDone ค่าเริ่มต้น 3500ms / 80 ครั้ง
Auth และ chat ใช้ api.gommo.net — ดู Authentication
TypeScript SDK
| คู่มือ | หัวข้อ |
|---|---|
| Overview | แผนที่ resources |
| Installation | npm, env, baseUrl |
| Authentication | login, register (gateway), เปลี่ยนรหัส, 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/* — Coming to Gommo platform |
| Errors | GatewayError, codes |
Client SDKs vs Cookbook
| Client SDK | Cookbook | |
|---|---|---|
| โฟกัส | Typed Gommo API surface | งาน end-to-end |
| ใช้เมื่อ | สร้างแอป | เรียนรู้ / script ครั้งเดียว |
| ภาษา | TypeScript (npm) | curl + PowerShell |
| Poll helpers | ในตัว | loop เอง |
ขั้นตอนถัดไป
- วงจร request · อ้างอิงมีเดีย
- Cookbook — สูตรงาน
- Gommo public API — HTTP reference
- คู่มือ integrator (Tier A)
- Playground
