นักพัฒนา

เริ่มต้นใช้งาน SpeakNotes API

สร้างคีย์ ทำการเรียกใช้ครั้งแรกในแซนด์บ็อกซ์ แล้วเปลี่ยนไปใช้โหมดจริง สี่ขั้นตอนง่ายๆ ด้วย curl

1. สร้างคีย์

เปิดการตั้งค่า (Settings) ไปที่คีย์ API และสร้างคีย์ เลือกแซนด์บ็อกซ์ในขณะที่คุณกำลังพัฒนา: คีย์แซนด์บ็อกซ์จะส่งคืนผลลัพธ์ที่คงที่ ไม่เสียเครดิต และเขียนลงในไลบรารีแยกต่างหากที่คุณสามารถลบทิ้งได้

2. สรุปเนื้อหาในแซนด์บ็อกซ์

ทุกเส้นทางทำงานได้ด้วยคีย์แซนด์บ็อกซ์ รูปแบบการตอบกลับจะเหมือนกับโหมดจริง ดังนั้นคุณจึงสามารถสร้างและทดสอบได้อย่างมั่นใจ

curl -X POST https://api.speaknotes.io/v1/summaries \
  -H "Authorization: Bearer sn_test_YOUR_SANDBOX_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "We agreed to ship the billing fix on Friday. Sam owns the migration.",
    "styleId": "meeting-notes"
  }'

# {
#   "title": "Sandbox meeting notes",
#   "summary": "## Decisions\n- Sandbox mode confirmed working ...",
#   "styleId": "meeting-notes",
#   "creditsCharged": 0,
#   "notice": "Sandbox response: fixed output, no credits charged."
# }

3. เปลี่ยนไปใช้คีย์จริง

คำขอเดิม แต่ใช้คีย์ที่ต่างออกไป คีย์นี้จะรันโมเดลจริงและหักเครดิต โดยการตอบกลับจะแจ้งให้คุณทราบว่าใช้ไปเท่าใดและเหลือเท่าใด

curl -X POST https://api.speaknotes.io/v1/summaries \
  -H "Authorization: Bearer sn_live_YOUR_LIVE_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text": "...", "styleId": "meeting-notes"}'

# Response headers include:
#   X-Credits-Remaining: 1998
# Response body includes:
#   "creditsCharged": 2

4. อัปโหลดไฟล์

สื่อที่มีความยาวจะทำงานในเบื้องหลัง ให้สร้างการอัปโหลด ทำ PUT ไฟล์ไปยัง URL ที่ลงนามไว้ ทำเครื่องหมายว่าเสร็จสิ้น จากนั้นให้รอตรวจสอบโน้ตจนกว่าสถานะจะเป็น Done

# 1. create the note and get a signed upload URL
curl -X POST https://api.speaknotes.io/v1/uploads \
  -H "Authorization: Bearer $SPEAKNOTES_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"fileName": "standup.m4a", "contentType": "audio/mp4", "styleId": "meeting-notes"}'

# 2. upload the file straight to the signed URL
curl -X PUT "$UPLOAD_URL" -H "Content-Type: audio/mp4" --data-binary @standup.m4a

# 3. tell SpeakNotes the upload finished (this is where credits are charged)
curl -X POST https://api.speaknotes.io/v1/uploads/$NOTE_ID/complete \
  -H "Authorization: Bearer $SPEAKNOTES_API_KEY"

# 4. poll until status is Done, then read the note
curl https://api.speaknotes.io/v1/notes/$NOTE_ID/status \
  -H "Authorization: Bearer $SPEAKNOTES_API_KEY"

curl https://api.speaknotes.io/v1/notes/$NOTE_ID \
  -H "Authorization: Bearer $SPEAKNOTES_API_KEY"

การสำรวจ API

GET /v1 ไม่จำเป็นต้องใช้ข้อมูลประจำตัวและจะส่งคืนทรัพยากร ขอบเขต (scopes) ขีดจำกัดอัตรา ค่าใช้จ่ายเครดิต และวิธีการตรวจสอบสิทธิ์ นี่เป็นวิธีที่เร็วที่สุดสำหรับเอเจนต์ในการทำความเข้าใจระบบ

curl https://api.speaknotes.io/v1

# Returns the resources, scopes, rate limits, credit costs,
# and how to authenticate. No credential required.

ถัดไป: การตรวจสอบสิทธิ์และขอบเขต รหัสข้อผิดพลาด และค่าใช้จ่ายของแต่ละการดำเนินการ