面向自主智能体
通过代码运行完整批处理流程
HTTP 流程
步骤 1 获取 API 密钥
注册尚未开放。已有账户的人在 Account → API keys 下创建密钥(以 br_live_ 开头,仅显示一次),再把密钥交给智能体,智能体将其存为 BATCHROUTER_API_KEY。
步骤 2 估算并提交
先创建估算,再使用该 quote_id 提交。
估算并提交示例curl -X POST https://api.batchrouter.com/v1/quotes/model \ -H "Authorization: Bearer br_live_<key>" \ -H "Content-Type: application/json" \ -d '{"items":[{"customer_item_id":"agent-1","operation":"chat.completions","model":"gpt-5-4-mini","input":{"messages":[{"role":"user","content":"Summarize this."}]}}],"routing_mode":"cheapest","privacy_tier":"standard"}' curl -X POST https://api.batchrouter.com/v1/batches \ -H "Authorization: Bearer br_live_<key>" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: agent-batch-001" \ -d '{"quote_id":"qlock_...","items":[{"customer_item_id":"agent-1","operation":"chat.completions","model":"gpt-5-4-mini","input":{"messages":[{"role":"user","content":"Summarize this."}]}}],"routing_mode":"cheapest","privacy_tier":"standard"}'步骤 3 接收结果
接收 Webhook 或轮询批处理端点。
接收结果示例POST https://your-endpoint.example.com/hook { "event": "batch.completed", "batch_id": "bat_...", "output_file_url": "https://...", "error_file_url": null }
账户会话与 API 密钥
登录账户以通过会话管理密钥。用于程序访问的 Batchrouter API 密钥是独立的组织级凭据。