starter · one page
เริ่ม ONEORIGIN ในหน้าเดียว
สร้างโปรเจกต์ด้วย CLI, เรียก agent ผ่าน SDK, และใช้ API ฝั่งเซิร์ฟเวอร์ที่รันอยู่บน Base44 จริง ไม่มี mock ไม่มีปุ่มตาย
เริ่มต้นใน 3 คำสั่ง
ขึ้นเว็บจริงด้วย npx wrangler login แล้ว npm run deploy
SDK
ติดตั้ง @one.origin/sandbox แล้วเรียก agent จากหลังบ้าน คีย์ไม่หลุดไปเบราว์เซอร์
import { createSandbox } from '@one.origin/sandbox';
const sandbox = createSandbox({ apiKey: process.env.OPENAI_API_KEY });
const { reply } = await sandbox.chat('สรุปยอดขายเมื่อวาน');
console.log(reply);
| ค่า | ความหมาย |
|---|---|
| apiKey | คีย์ของผู้ให้บริการ เก็บฝั่งเซิร์ฟเวอร์เท่านั้น |
| provider | openai (ค่าเริ่มต้น) หรือ base44 |
| onDelta | รับข้อความแบบสตรีมทีละท่อน |
เซิร์ฟเวอร์บน Base44
API ทำงานจริงแล้วบน Base44 เรียกได้จากโดเมนไหนก็ได้ ผ่านคีย์ oo_live_...
| Endpoint | Method | ต้องมีคีย์ | ผลลัพธ์ |
|---|---|---|---|
/functions/ooHealth | GET, POST | ไม่ | สถานะบริการและเวอร์ชัน |
/functions/ooApi?resource=items | GET | ใช่ | รายการล่าสุด 50 รายการ |
/functions/ooApi?resource=items | POST | ใช่ | สร้างรายการใหม่ (title, body, status) |
curl -X POST "https://superagent-c3244e9b.base44.app/functions/ooApi?resource=items" \
-H "Authorization: Bearer oo_live_..." \
-H "content-type: application/json" \
-d '{"title":"รายการแรก","status":"active"}'
ข้อมูลเก็บใน entity StarterItem คีย์เก็บเป็น hash ใน StarterKey ยกเลิกได้ด้วยการตั้ง revoked: true
องค์ประกอบที่ได้
CLI
create-oneorigin-app สร้างเว็บพร้อม wrangler และสคริปต์ deploy
SDK
@one.origin/sandbox เรียก agent พร้อมสตรีมและ types
Server
Base44 functions พร้อมคีย์และฐานข้อมูล ไม่ต้องตั้งเซิร์ฟเวอร์เอง
เริ่ม deploy ของคุณ
กดปุ่มด้านล่างเพื่อเปิด Base44 แล้วเริ่มจากชุดนี้ได้ทันที ทั้ง entity, function และคีย์ถูกวางไว้แล้ว