開發者
SpeakNotes API 快速入門
建立金鑰,在沙盒中進行第一次呼叫,然後切換到正式環境。四個步驟,全程使用 curl。
1. 建立金鑰
開啟「設定」中的「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": 24. 上傳檔案
較長的媒體會在背景執行。建立上傳任務,將檔案 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 不需要憑證,並會回傳資源、範圍、速率限制、點數成本以及如何進行驗證。這是代理程式自我定位最快的方式。
curl https://api.speaknotes.io/v1 # Returns the resources, scopes, rate limits, credit costs, # and how to authenticate. No credential required.
下一步:驗證與範圍、錯誤代碼,以及每個操作的成本。