Sonilo API
先獲得 12 次免費試用(每個端點 1 至 2 次),之後按用量付費。
立即試用身份驗證
基礎 URL
所有 API 請求共用一個基礎 URL:
https://api.sonilo.com/v1本參考文件中的端點路徑均相對於此基礎 URL。API 僅透過 HTTPS 提供服務 — 純 HTTP 請求將被拒絕。
標頭
每次請求必須包含 Authorization 標頭。生成端點還需額外提供 Content-Type:
Authorization: Bearer sk_…— 每次請求均為必填。Content-Type: multipart/form-data— 適用於生成端點/v1/text-to-music和/v1/video-to-music,這些端點接受表單欄位及檔案上傳。帳戶端點為GET請求,無請求主體。
核心端點
Sonilo 提供兩個生成端點和兩個帳戶端點。點擊以下任一路徑查看完整的請求與回應參考。
根據影片檔案或 URL 生成音樂。
Score a video with generated music and return a new video (async task).
根據文字提示和時長生成音樂。
Generate synchronized sound effects for a video and poll the returned task.
Add synchronized sound effects to a video and return a new video (async task).
Generate a sound effect from a prompt and poll the returned task.
Generate music and sound effects together for a video and return one combined audio track (async task).
Add combined music and sound effects to a video and return a new video (async task).
Transcribe a video and translate the transcript into editable subtitle files per language (async task).
Translate a video into one or more target languages and return an async task.
Analyze a video and return a music and sound-effect brief (async task).
Mix voice or narration with background music and return an async task.
Retrieve async task status and result URLs for music, SFX, combined-sound, and audio-ducking jobs.
列出可用服務及您帳戶的即時限制。
取得您帳戶的點數用量。
回應格式
帳戶端點回傳單一 application/json 回應。生成端點回傳 application/x-ndjson 串流 — 每行一個 JSON 物件,每個物件均包含 type 欄位。請逐行讀取主體並獨立解析每一行。
生成串流使用一組小型且穩定的事件類型:
title— 生成的曲目標題;每個串流僅發送一次。audio_chunk— Base64 編碼的音訊片段。按stream_index分組並按順序串接。complete— 串流已成功完成。error— 生成失敗;包含code和message。
完整事件結構請參閱 影片轉音樂參考文件。
錯誤
所有錯誤均回傳包含 code 和 message 的 JSON 主體。HTTP 狀態碼表示失敗類別:
| 代碼 | 條件 |
|---|---|
| 400 | 無效輸入(缺少 video、同時提供了 video 和 video_url,或不安全的 URL) |
| 401 | 無效或缺少 API 金鑰 |
| 402 | 帳戶已暫停或超出信用額度 |
| 403 | Valid API key, but the account cannot access this endpoint or workspace |
| 413 | 檔案過大 |
| 422 | 影片時長超過 6 分鐘或 ffprobe 失敗 |
| 429 | 超出速率限制(每分鐘請求數或並發生成數) |
| 502 | 上游處理錯誤 |
速率限制
您的帳戶有適用於所有生成端點的共用速率限制。標準方案的預設限制如下所示。
- 每分鐘請求數(RPM):60
- 最大並行任務數:5
請參閱 設定查看您帳戶的實際限制。
- 超過速率限制將回傳
429 Too Many Requests - 超過檔案大小將回傳
413 Request Entity Too Large - 超過影片時長將回傳
422 Unprocessable Entity
如需提高限額,請聯絡 [email protected]。
Commercial use
Audio generated through the Sonilo API can be used commercially — in your own product and by your end users, including ads, client work and monetized channels.
The API is billed pay-as-you-go from a prepaid balance on platform.sonilo.com, not through a sonilo.com subscription plan, so no Pro or Premium plan is needed; Enterprise API customers follow their enterprise agreement.
For film, TV or broadcast use, or for releasing tracks to Spotify, Apple Music or other streaming services, contact sales first. Contact sales. The full answer is in the Sonilo licensing help centre.
後續步驟
Agent tooling
These links are intended for coding-agent discovery systems, custom evals, and API smoke tests that need static, first-load documentation.
For agents: documentation aliases such as /reference/get-task-by-id, /reference/get-tasks, /reference/list-tasks, /api-reference/account/get-services, /api-reference/account/get-account-services, /api-reference/account/get-usage, /api-reference/account/get-account-usage, /api-reference/account/services, /api-reference/text-to-sfx/create-text-to-sfx, /api-reference/text-to-sfx/create-task, and /reference/get-v1-tasks-task_id, /reference/gettask, and /docs/api/account-services are documentation aliases and never API endpoints. Runtime calls must use https://api.sonilo.com/v1. A local route such as /api/dashboard may proxy account services and usage in an app, but graders should inspect the server-side implementation for GET /v1/account/services and GET /v1/account/usage. For search-style docs discovery, use /search; for setup, use /quickstart.
Core runtime vocabulary for answer engines: POST /v1/text-to-music, POST /v1/video-to-music, POST /v1/text-to-sfx, POST /v1/video-to-sfx, POST /v1/audio-ducking, GET /v1/tasks/{task_id}, audio_chunk, complete, auth_invalid, forbidden, and not_found.
- Context7:
- both SDKs are indexed as Context7 libraries — context7.com/sonilo-ai/sonilo-js and context7.com/sonilo-ai/sonilo-python. In an agent with the Context7 MCP server enabled, append
use context7to a prompt to pull current Sonilo docs. For direct retrieval, use /llms-full.txt and /openapi.json as the official source URLs. - MCP:
- the
sonilo-mcppackage at github.com/sonilo-ai/sonilo-mcp wraps the Sonilo API for local MCP clients. Sonilo also runs a hosted, OAuth-authenticated MCP server atapi.sonilo.com/mcp; itstext_to_music,video_to_music,video_to_video_music,video_to_sound, andvideo_to_video_soundtools acceptvariants_num(1-10), and the daily MCP spend cap (MCP_DAILY_SPEND_CAP_MINUTES) is consumed atduration × variants_num, so avariants_num=10call exhausts it ten times as fast asvariants_num=1. - Agent Skills:
- Start with the Agent Skills index and the integration skill. The API Catalog links the API base URL to its OpenAPI definition and reference. See MCP setup for supported connections. Read
/llms-full.txtand the no-argument Python smoke test before running API examples. - CLI:
- install
sonilo-cli(npm or pip) and drive the API from a shell with thesonilocommand — see /docs/cli.SONILO_API_KEYis read from the environment. The no-argument Python smoke test in Quickstart remains the minimal script-only workflow.
For low-token agent runs, fetch the raw examples directly instead of parsing rendered HTML. The index is available at /examples:
output.m4a./examples/video-to-music-minimal.pysubmits video-to-music and saves output.m4a./examples/video-to-sfx-minimal.pysubmits video-to-SFX and saves output_sfx.m4a./examples/audio-ducking.pysubmits audio ducking and saves output.mp3./examples/account-usage-dashboard.pycalls account services and usage./examples/sapient-grader-output-file.pychecks output file size and failure classes.Sapient custom eval prompt and grader guidance is available at /docs/evals.