Sonilo API
先获得 12 次免费试用(每个端点 1 到 2 次),之后按用量付费。
立即试用认证
Sonilo API 使用 API 密钥对请求进行认证。在 API 密钥 页面生成和管理密钥。密钥以 sk_ 开头,创建时仅显示一次——请立即复制。在每次请求中以 Bearer 令牌形式传入密钥:
curl https://api.sonilo.com/v1/account/services \
-H "Authorization: Bearer sk_your_api_key_here"请像对待密码一样保管密钥:仅在服务器端使用,并从环境变量中加载——切勿将其提交到代码仓库或包含在客户端代码中。如果密钥泄露,请在 API 密钥 页面立即撤销并创建新密钥。撤销立即生效,后续任何使用该密钥的请求均会返回 401。
基础 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。
请参阅 视频转音乐 参考文档以了解完整的事件 Schema。
错误
所有错误均返回包含 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]。
下一步
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.