POST /v1/users公开
创建用户 创建用户账户(BFF 内部调用)。
请求示例 {
"email": "dev@example.com",
"name": "BatchIn Team",
"password": "secure_password_123"
}响应示例 {
"id": "f6e2c67b-90cf-4f4e-b1e5-31d45f3b1b0a",
"email": "dev@example.com",
"name": "BatchIn Team",
"credit_balance_cents": 0
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Content-Type"] = "application/json"
response = requests.request(
"POST",
"https://batchin-api.onrender.com/v1/users",
headers=headers,
json={
"email": "dev@example.com",
"name": "BatchIn Team",
"password": "secure_password_123"
}
)
print(response.json())参数表 Name Type 必填 说明 email string(email) 是 用户邮箱 name string 是 显示名称 password string 是 登录密码
错误码 Code HTTP 信息 处理建议 conflict 409 该邮箱已注册 改用登录流程或更换邮箱。
前往 Try it POST /v1/users/login公开
用户登录 通过邮箱与密码登录。
请求示例 {
"email": "dev@example.com",
"password": "secure_password_123"
}响应示例 {
"id": "f6e2c67b-90cf-4f4e-b1e5-31d45f3b1b0a",
"email": "dev@example.com",
"name": "BatchIn Team",
"credit_balance_cents": 10000
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Content-Type"] = "application/json"
response = requests.request(
"POST",
"https://batchin-api.onrender.com/v1/users/login",
headers=headers,
json={
"email": "dev@example.com",
"password": "secure_password_123"
}
)
print(response.json())参数表 Name Type 必填 说明 email string(email) 是 登录邮箱 password string 是 登录密码
错误码 Code HTTP 信息 处理建议 invalid_credentials 401 邮箱或密码错误 确认账户信息后重试。
前往 Try it GET /v1/users/meBearer
当前用户信息 获取当前 API Key 对应用户信息。
响应示例 {
"id": "f6e2c67b-90cf-4f4e-b1e5-31d45f3b1b0a",
"email": "dev@example.com",
"name": "BatchIn Team",
"credit_balance_cents": 10000
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
response = requests.request(
"GET",
"https://batchin-api.onrender.com/v1/users/me",
headers=headers,
)
print(response.json())错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。
前往 Try it GET /v1/users/by-email?email={email}公开
按邮箱查询用户 按邮箱查询用户信息(登录前检查)。
响应示例 {
"id": "f6e2c67b-90cf-4f4e-b1e5-31d45f3b1b0a",
"email": "dev@example.com",
"name": "BatchIn Team",
"credit_balance_cents": 10000
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
response = requests.request(
"GET",
"https://batchin-api.onrender.com/v1/users/by-email?email={email}",
headers=headers,
)
print(response.json())参数表 Name Type 必填 说明 email query:string(email) 是 目标邮箱
错误码 Code HTTP 信息 处理建议 not_found 404 用户不存在 先完成注册。
前往 Try it POST /v1/keysBearer
创建 API Key 创建新 API Key,可设置速率与月预算。
请求示例 {
"name": "Production Key",
"rate_limit_rpm": 120,
"monthly_budget_cents": 500000
}响应示例 {
"id": "f40cf8b0-c367-4764-92e3-cbd358fa3d76",
"key": "batchin_api_xxx",
"key_prefix": "batchin_api",
"name": "Production Key",
"rate_limit_rpm": 120,
"monthly_budget_cents": 500000,
"created_at": "2026-04-08T18:00:00Z"
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
headers["Content-Type"] = "application/json"
response = requests.request(
"POST",
"https://batchin-api.onrender.com/v1/keys",
headers=headers,
json={
"name": "Production Key",
"rate_limit_rpm": 120,
"monthly_budget_cents": 500000
}
)
print(response.json())参数表 Name Type 必填 说明 name string 否 密钥名称 rate_limit_rpm number 否 每分钟请求上限 monthly_budget_cents number 否 月预算(美分)
错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。
前往 Try it GET /v1/keysBearer
列出 API Keys 返回当前用户全部 API Keys。
响应示例 [
{
"id": "f40cf8b0-c367-4764-92e3-cbd358fa3d76",
"key_prefix": "batchin_api",
"name": "Production Key",
"rate_limit_rpm": 120,
"is_active": true,
"created_at": "2026-04-08T18:00:00Z"
}
]代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
response = requests.request(
"GET",
"https://batchin-api.onrender.com/v1/keys",
headers=headers,
)
print(response.json())错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。
前往 Try it DELETE /v1/keys/{id}Bearer
删除 API Key 删除指定 API Key。
代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
response = requests.request(
"DELETE",
"https://batchin-api.onrender.com/v1/keys/{id}",
headers=headers,
)
print(response.json())参数表 Name Type 必填 说明 id path:uuid 是 API Key ID
错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。 not_found 404 API Key 不存在 确认 key id 后重试。
前往 Try it POST /v1/chat/completionsBearer
聊天补全 用于文本/多轮对话,支持 SSE 流式输出。
请求示例 {
"model": "qwen3-32b",
"messages": [{"role":"user","content":"Explain attention in 3 bullets"}],
"temperature": 0.7,
"stream": false
}响应示例 {
"id": "chatcmpl_xxx",
"object": "chat.completion",
"model": "qwen3-32b",
"choices": [{"index":0,"message":{"role":"assistant","content":"..."}}],
"usage": {"prompt_tokens": 22, "completion_tokens": 90, "total_tokens": 112}
}响应头 Header 说明 traceparent W3C trace 上下文,可用于把请求串到外部追踪系统。 X-BatchIn-Run-Id 本次运行的 BatchIn run id。 X-BatchIn-Route-Id 命中的路由 id。 X-BatchIn-Provider 实际命中的 provider。 X-BatchIn-Environment 运行所在环境。 X-BatchIn-Prompt-Version 绑定到本次运行的 prompt version。 X-VaaS-Record-Id 审计证据记录 id。 X-VaaS-Signature 审计证据签名。 X-VaaS-PublicKey 审计验签公钥。
代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
headers["Content-Type"] = "application/json"
response = requests.request(
"POST",
"https://batchin-api.onrender.com/v1/chat/completions",
headers=headers,
json={
"model": "qwen3-32b",
"messages": [{"role":"user","content":"Explain attention in 3 bullets"}],
"temperature": 0.7,
"stream": false
}
)
print(response.json())参数表 Name Type 必填 说明 model string 是 模型 ID messages array 是 对话消息数组 temperature number 否 采样温度 max_tokens number 否 最大输出 tokens stream boolean 否 是否流式返回
错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。 payment_required 402 余额不足或预算超限 充值或提高月预算后重试。
前往 Try it POST /v1/responsesBearer
Responses 接口 最小兼容版 Responses API,返回 response 对象与运行时回执头。
请求示例 {
"model": "qwen3-32b",
"input": "Explain batch inference in 3 bullets",
"max_output_tokens": 256
}响应示例 {
"id": "resp_chatcmpl_xxx",
"object": "response",
"model": "qwen3-32b",
"output": [
{
"type": "message",
"role": "assistant",
"content": [{"type":"output_text","text":"..."}]
}
],
"usage": {"input_tokens": 12, "output_tokens": 10, "total_tokens": 22}
}响应头 Header 说明 traceparent W3C trace 上下文,可用于把请求串到外部追踪系统。 X-BatchIn-Run-Id 本次运行的 BatchIn run id。 X-BatchIn-Route-Id 命中的路由 id。 X-BatchIn-Provider 实际命中的 provider。 X-BatchIn-Environment 运行所在环境。 X-BatchIn-Prompt-Version 绑定到本次运行的 prompt version。 X-VaaS-Record-Id 审计证据记录 id。 X-VaaS-Signature 审计证据签名。 X-VaaS-PublicKey 审计验签公钥。
代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
headers["Content-Type"] = "application/json"
response = requests.request(
"POST",
"https://batchin-api.onrender.com/v1/responses",
headers=headers,
json={
"model": "qwen3-32b",
"input": "Explain batch inference in 3 bullets",
"max_output_tokens": 256
}
)
print(response.json())参数表 Name Type 必填 说明 model string 是 模型 ID input string|array 是 输入文本或消息数组 max_output_tokens number 否 最大输出 tokens stream boolean 否 是否流式返回(当前未实现)
错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。 not_implemented 501 流式 Responses 还未实现 先使用非流式 /v1/responses 或 /v1/chat/completions。
前往 Try it POST /v1/completionsBearer
文本补全 / FIM 兼容 OpenAI completions,并支持 prefix/suffix 形式的 FIM 请求。
请求示例 {
"model": "qwen3-32b",
"prompt": "Complete this sentence: Batch processing helps",
"suffix": "for large workloads.",
"max_tokens": 128
}响应示例 {
"id": "cmpl_xxx",
"object": "text_completion",
"choices": [{"index":0,"text":"reduce manual toil at scale.","finish_reason":"stop"}],
"usage": {"prompt_tokens": 24, "completion_tokens": 12, "total_tokens": 36}
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
headers["Content-Type"] = "application/json"
response = requests.request(
"POST",
"https://batchin-api.onrender.com/v1/completions",
headers=headers,
json={
"model": "qwen3-32b",
"prompt": "Complete this sentence: Batch processing helps",
"suffix": "for large workloads.",
"max_tokens": 128
}
)
print(response.json())参数表 Name Type 必填 说明 model string 是 补全模型 ID prompt string|array 是 输入前缀或文本 suffix string 否 FIM 后缀 max_tokens number 否 最大输出 tokens
错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。
前往 Try it POST /v1/embeddingsBearer
向量嵌入 将文本转换为向量表示。
请求示例 {
"model": "bge-m3",
"input": ["batch inference", "retrieval augmented generation"]
}响应示例 {
"object": "list",
"data": [
{"index":0,"embedding":[0.012,-0.043,...]},
{"index":1,"embedding":[0.021,-0.011,...]}
]
}响应头 Header 说明 traceparent W3C trace 上下文。 X-BatchIn-Run-Id 本次 embedding 运行的 run id。 X-BatchIn-Prompt-Version 绑定到本次运行的 prompt version。 X-VaaS-Record-Id 审计证据记录 id。
代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
headers["Content-Type"] = "application/json"
response = requests.request(
"POST",
"https://batchin-api.onrender.com/v1/embeddings",
headers=headers,
json={
"model": "bge-m3",
"input": ["batch inference", "retrieval augmented generation"]
}
)
print(response.json())参数表 Name Type 必填 说明 model string 是 嵌入模型 ID input string|array 是 待向量化文本
错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。
前往 Try it POST /v1/audio/speechBearer
语音合成 使用 CosyVoice / TTS 模型把文本转换为音频响应。
请求示例 {
"model": "cosyvoice",
"input": "Welcome to BatchIn",
"voice": "alloy",
"response_format": "mp3"
}响应示例 Binary audio payload (audio/mpeg)代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
headers["Content-Type"] = "application/json"
response = requests.request(
"POST",
"https://batchin-api.onrender.com/v1/audio/speech",
headers=headers,
json={
"model": "cosyvoice",
"input": "Welcome to BatchIn",
"voice": "alloy",
"response_format": "mp3"
}
)
print(response.content)参数表 Name Type 必填 说明 model string 是 语音模型 ID input string 是 待合成文本 voice string 否 音色 response_format string 否 返回格式
错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。
前往 Try it POST /v1/video/generateBearer
视频生成 使用 Wan 2.2 等模型发起视频生成任务。
请求示例 {
"model": "wan-2.2",
"prompt": "Create a product teaser for an AI cloud launch",
"duration_seconds": 6
}响应示例 {
"id": "video_xxx",
"object": "video.generation",
"status": "queued",
"duration_seconds": 6,
"output_url": "https://batchin-api.onrender.com/v1/files/file_video_xxx/content"
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
headers["Content-Type"] = "application/json"
response = requests.request(
"POST",
"https://batchin-api.onrender.com/v1/video/generate",
headers=headers,
json={
"model": "wan-2.2",
"prompt": "Create a product teaser for an AI cloud launch",
"duration_seconds": 6
}
)
print(response.json())参数表 Name Type 必填 说明 model string 是 视频模型 ID prompt string 是 视频提示词 duration_seconds number 否 视频秒数 aspect_ratio string 否 画幅比例
错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。
前往 Try it POST /v1/images/generationsBearer
图像生成 文本生成图像。
请求示例 {
"model": "flux-schnell",
"prompt": "A futuristic city at sunrise",
"size": "1024x1024"
}响应示例 {
"created": 1775671200,
"data": [{"url":"https://batchin.tech/images/generated/abc.png"}]
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
headers["Content-Type"] = "application/json"
response = requests.request(
"POST",
"https://batchin-api.onrender.com/v1/images/generations",
headers=headers,
json={
"model": "flux-schnell",
"prompt": "A futuristic city at sunrise",
"size": "1024x1024"
}
)
print(response.json())参数表 Name Type 必填 说明 model string 是 图像模型 ID prompt string 是 图像提示词 size string 否 输出尺寸
错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。
前往 Try it GET /v1/models公开
模型列表 返回模型状态、价格、上下文与许可证信息。
响应示例 {
"object": "list",
"data": [
{
"id":"qwen3-32b",
"status":"always_on",
"context_length":131072,
"pricing":{"std_input":0.02,"std_output":0.08}
}
]
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
response = requests.request(
"GET",
"https://batchin-api.onrender.com/v1/models",
headers=headers,
)
print(response.json())错误码 Code HTTP 信息 处理建议 service_unavailable 503 模型服务不可用 查看状态页并稍后重试。
前往 Try it POST /v1/batchesBearer
创建批处理 提交批处理任务(支持混合模型与优先级)。
请求示例 {
"priority": "fill",
"webhook_url": "https://your-domain.com/webhooks/batchin",
"tasks": [
{"custom_id":"task-1","model":"qwen3-32b","request_body":{"messages":[{"role":"user","content":"translate this"}]}},
{"custom_id":"task-2","model":"deepseek-r1","request_body":{"messages":[{"role":"user","content":"summarize this"}]}}
]
}响应示例 {
"id":"0b0db2a6-0baf-4ec4-a5e7-bce60da57db6",
"status":"pending",
"priority":"fill",
"total_tasks":2,
"completed_tasks":0,
"failed_tasks":0
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
headers["Content-Type"] = "application/json"
response = requests.request(
"POST",
"https://batchin-api.onrender.com/v1/batches",
headers=headers,
json={
"priority": "fill",
"webhook_url": "https://your-domain.com/webhooks/batchin",
"tasks": [
{"custom_id":"task-1","model":"qwen3-32b","request_body":{"messages":[{"role":"user","content":"translate this"}]}},
{"custom_id":"task-2","model":"deepseek-r1","request_body":{"messages":[{"role":"user","content":"summarize this"}]}}
]
}
)
print(response.json())参数表 Name Type 必填 说明 tasks array 是 任务数组(每项可指定 model) priority string(high|low|fill) 否 调度优先级 webhook_url string(url) 否 回调地址
错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。 payload_too_large 413 批任务 JSON 超过 2MB 拆分批次或减少单批任务数。
前往 Try it GET /v1/batchesBearer
列出批处理 列出当前用户批处理任务。
响应示例 [
{
"id":"0b0db2a6-0baf-4ec4-a5e7-bce60da57db6",
"status":"completed",
"priority":"fill",
"total_tasks":2,
"completed_tasks":2,
"failed_tasks":0
}
]代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
response = requests.request(
"GET",
"https://batchin-api.onrender.com/v1/batches",
headers=headers,
)
print(response.json())错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。
前往 Try it GET /v1/batches/{id}Bearer
获取批处理详情 获取批处理任务与子任务详情。
响应示例 {
"id":"0b0db2a6-0baf-4ec4-a5e7-bce60da57db6",
"status":"completed",
"tasks":[{"custom_id":"task-1","status":"completed"}]
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
response = requests.request(
"GET",
"https://batchin-api.onrender.com/v1/batches/{id}",
headers=headers,
)
print(response.json())参数表 Name Type 必填 说明 id path:uuid 是 批处理 ID
错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。 not_found 404 批处理不存在 确认 batch id 是否正确。
前往 Try it POST /v1/batches/{id}/cancelBearer
取消批处理 取消进行中的批处理任务。
响应示例 {
"id":"0b0db2a6-0baf-4ec4-a5e7-bce60da57db6",
"status":"cancelled"
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
response = requests.request(
"POST",
"https://batchin-api.onrender.com/v1/batches/{id}/cancel",
headers=headers,
)
print(response.json())参数表 Name Type 必填 说明 id path:uuid 是 批处理 ID
错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。
前往 Try it POST /v1/topup/stripe/checkoutBearer
创建 Stripe Checkout 创建充值支付会话。
请求示例 {
"amount_cents": 5000
}响应示例 {
"checkout_url":"https://buy.stripe.com/9B65kD4US2fLeEF4zweME00",
"session_id":"cs_test_xxx"
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
headers["Content-Type"] = "application/json"
response = requests.request(
"POST",
"https://batchin-api.onrender.com/v1/topup/stripe/checkout",
headers=headers,
json={
"amount_cents": 5000
}
)
print(response.json())参数表 Name Type 必填 说明 amount_cents number 是 充值金额(美分)
错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。
前往 Try it GET /v1/topup/historyBearer
充值历史 查询充值记录。
响应示例 [
{
"id":"1544d6df-8fca-46f3-9091-95f81dc37efa",
"amount_cents":5000,
"source":"stripe",
"reference_id":"cs_test_xxx"
}
]代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
response = requests.request(
"GET",
"https://batchin-api.onrender.com/v1/topup/history",
headers=headers,
)
print(response.json())错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。
前往 Try it GET /v1/topup/usdc/chainsBearer
USDC 链路信息 获取 USDC 充值链与地址。
响应示例 {
"chains":[
{"chain":"ethereum","deposit_address":"0x...","required_confirmations":12},
{"chain":"polygon","deposit_address":"0x...","required_confirmations":12}
]
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
response = requests.request(
"GET",
"https://batchin-api.onrender.com/v1/topup/usdc/chains",
headers=headers,
)
print(response.json())错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。
前往 Try it GET /v1/usage/logs?limit=50&offset=0Bearer
使用日志 查询请求级别使用日志。
响应示例 [
{
"id":"e73f9476-00ea-491f-ba6f-899602247a15",
"model":"qwen3-32b",
"input_tokens":120,
"output_tokens":88,
"cost_cents":2
}
]代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
response = requests.request(
"GET",
"https://batchin-api.onrender.com/v1/usage/logs?limit=50&offset=0",
headers=headers,
)
print(response.json())参数表 Name Type 必填 说明 limit query:number 否 返回条数(1-500) offset query:number 否 偏移量
错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。
前往 Try it GET /v1/usage/summaryBearer
用量汇总 获取总请求、tokens 与成本统计。
响应示例 {
"total_requests": 1304,
"total_input_tokens": 2341122,
"total_output_tokens": 1111400,
"total_cost_cents": 18640
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
response = requests.request(
"GET",
"https://batchin-api.onrender.com/v1/usage/summary",
headers=headers,
)
print(response.json())错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。 payment_required 402 API Key 月预算已超限 提高月预算或更换 key。
前往 Try it GET /v1/usage/by-modelBearer
按模型聚合 按模型维度统计用量。
响应示例 [
{
"model":"qwen3-32b",
"total_requests": 880,
"total_input_tokens": 1620012,
"total_output_tokens": 801202,
"total_cost_cents": 9900
}
]代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
response = requests.request(
"GET",
"https://batchin-api.onrender.com/v1/usage/by-model",
headers=headers,
)
print(response.json())错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。
前往 Try it POST /v1/vaasBearer
创建审计记录 创建可验证审计记录并返回签名。
请求示例 {
"input_text": "What is a zero-knowledge proof?",
"output_text": "A cryptographic method...",
"model_id": "qwen3-32b",
"gpu_id": "gpu-42"
}响应示例 {
"audit_id":"ee3cc19e-710d-4a2d-bf01-0edca0c5fdf4",
"input_hash":"9a5f...",
"output_hash":"2f1b...",
"carbon_grams_co2e":0.0126,
"energy_wh":0.2107,
"energy_source":"Renewable grid mix",
"carbon_offset_vs_us_cloud":0.0717,
"signature":"bfc4..."
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
headers["Content-Type"] = "application/json"
response = requests.request(
"POST",
"https://batchin-api.onrender.com/v1/vaas",
headers=headers,
json={
"input_text": "What is a zero-knowledge proof?",
"output_text": "A cryptographic method...",
"model_id": "qwen3-32b",
"gpu_id": "gpu-42"
}
)
print(response.json())参数表 Name Type 必填 说明 input_text string 是 输入文本 output_text string 是 输出文本 model_id string 是 模型 ID gpu_id string 否 GPU 标识
错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。
前往 Try it GET /v1/vaas/{id}公开
查询审计记录 按 audit_id 获取审计详情。
响应示例 {
"audit_id":"ee3cc19e-710d-4a2d-bf01-0edca0c5fdf4",
"input_hash":"9a5f...",
"output_hash":"2f1b...",
"carbon_grams_co2e":0.0126,
"energy_wh":0.2107,
"energy_source":"Renewable grid mix",
"carbon_offset_vs_us_cloud":0.0717,
"signature":"bfc4..."
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
response = requests.request(
"GET",
"https://batchin-api.onrender.com/v1/vaas/{id}",
headers=headers,
)
print(response.json())参数表 Name Type 必填 说明 id path:uuid 是 审计 ID
错误码 Code HTTP 信息 处理建议 not_found 404 审计记录不存在 检查 audit_id。
前往 Try it GET /v1/vaas/{id}/verify公开
验证审计签名 验证审计记录签名是否合法。
响应示例 {
"audit_id":"ee3cc19e-710d-4a2d-bf01-0edca0c5fdf4",
"valid": true
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
response = requests.request(
"GET",
"https://batchin-api.onrender.com/v1/vaas/{id}/verify",
headers=headers,
)
print(response.json())参数表 Name Type 必填 说明 id path:uuid 是 审计 ID
前往 Try it GET /v1/vaas/{id}/evidence公开
导出证据包 返回浏览器验签和合规导出使用的 audit evidence pack。
响应示例 {
"record_id":"vaas_xxx",
"run_id":"run_xxx",
"trace_id":"0123456789abcdef0123456789abcdef",
"route_id":"default-route",
"provider":"api-relay",
"environment":"development",
"prompt_version_id":"default",
"verification_method":"Ed25519Signature2020",
"public_key":"ed25519:pk_xxx",
"signature":"ed25519:xxx",
"payload": {"record_id":"vaas_xxx","input_hash":"sha256:...","output_hash":"sha256:..."}
}响应头 Header 说明 Content-Type JSON evidence pack,可直接保存或交给 /verify。
代码示例 Python JavaScript cURL
import os
import requests
headers = {}
response = requests.request(
"GET",
"https://batchin-api.onrender.com/v1/vaas/{id}/evidence",
headers=headers,
)
print(response.json())参数表 Name Type 必填 说明 id path:uuid 是 审计 ID
前往 Try it GET /v1/vaas/pubkey/current公开
获取当前公钥 获取浏览器验签所需公钥。
响应示例 {
"verify_key_hex":"1fbd9285..."
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
response = requests.request(
"GET",
"https://batchin-api.onrender.com/v1/vaas/pubkey/current",
headers=headers,
)
print(response.json())前往 Try it GET /v1/traces?limit=20Bearer
列出运行追踪 返回原生 runtime trace 列表,关联 route、prompt version 与 审计记录。
响应示例 {
"items": [
{
"trace_id":"0123456789abcdef0123456789abcdef",
"run_id":"run_xxx",
"record_id":"vaas_xxx",
"route_id":"default-route",
"provider":"api-relay",
"environment":"development",
"prompt_version_id":"default",
"model_id":"qwen3-32b"
}
]
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
response = requests.request(
"GET",
"https://batchin-api.onrender.com/v1/traces?limit=20",
headers=headers,
)
print(response.json())参数表 Name Type 必填 说明 limit query:number 否 返回条数(1-100)
错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。
前往 Try it GET /v1/traces/{trace_id}Bearer
获取单条追踪 按 trace_id 获取单条 runtime trace。
响应示例 {
"trace_id":"0123456789abcdef0123456789abcdef",
"run_id":"run_xxx",
"record_id":"vaas_xxx",
"route_id":"default-route",
"provider":"api-relay",
"environment":"development",
"prompt_version_id":"default",
"model_id":"qwen3-32b"
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
response = requests.request(
"GET",
"https://batchin-api.onrender.com/v1/traces/{trace_id}",
headers=headers,
)
print(response.json())参数表 Name Type 必填 说明 trace_id path:string 是 Trace ID
错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。 not_found 404 Trace 不存在 确认 trace_id 后重试。
前往 Try it GET /v1/promptsBearer
提示词注册表 返回 prompt 注册表、已提升版本、最新观测版本与版本明细。
响应示例 {
"status":"ready",
"docs":"/docs/prompts",
"items":[
{
"registry_id":"support",
"display_name":"support",
"source":"auto_backfill",
"latest_version_id":"support@v2",
"promoted_version_id":"support@v2",
"total_runs":4,
"versions":[
{
"version_id":"support@v1",
"status":"observed",
"total_runs":2
},
{
"version_id":"support@v2",
"status":"promoted",
"total_runs":2
}
]
}
]
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
response = requests.request(
"GET",
"https://batchin-api.onrender.com/v1/prompts",
headers=headers,
)
print(response.json())错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。
前往 Try it GET /v1/prompt-regressionsBearer
Prompt Regression 结果 返回自动 sampled replay 的 regression 结果、样本数、相似度与延迟汇总。
响应示例 {
"status":"ready",
"docs":"/docs/experiments",
"items":[
{
"regression_id":"preg_demo",
"registry_id":"support",
"baseline_prompt_version_id":"support@v1",
"candidate_prompt_version_id":"support@v2",
"status":"passed",
"judge":"deterministic_replay",
"sample_count":3,
"pass_count":3,
"fail_count":0,
"avg_similarity":1,
"baseline_avg_latency_ms":420,
"candidate_avg_latency_ms":390
}
]
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
response = requests.request(
"GET",
"https://batchin-api.onrender.com/v1/prompt-regressions",
headers=headers,
)
print(response.json())错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。
前往 Try it GET /v1/experimentsBearer
实验控制面 返回候选 prompt version 的自动实验、回放状态与自动提升结果。
响应示例 {
"status":"ready",
"docs":"/docs/experiments",
"items":[
{
"experiment_id":"pexp_demo",
"registry_id":"support",
"baseline_prompt_version_id":"support@v1",
"candidate_prompt_version_id":"support@v2",
"status":"passed",
"promotion_status":"promoted",
"sample_count":3,
"pass_rate":1
}
]
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
response = requests.request(
"GET",
"https://batchin-api.onrender.com/v1/experiments",
headers=headers,
)
print(response.json())错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。
前往 Try it POST /v1/otlp/tracesBearer
OTLP Trace Ingest 接收 OTLP/HTTP JSON 或 protobuf trace,并把 span 合并进统一 trace 控制面。
请求示例 {
"resourceSpans": []
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
headers["Content-Type"] = "application/json"
response = requests.request(
"POST",
"https://batchin-api.onrender.com/v1/otlp/traces",
headers=headers,
json={
"resourceSpans": []
}
)
print(response.json())错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。
前往 Try it GET /v1/otlp/exportBearer
OTLP Trace Export 把统一 trace 控制面中的 span 导出为 OTLP protobuf 或 JSON。
响应示例 {
"resourceSpans":[]
}代码示例 Python JavaScript cURL
import os
import requests
headers = {}
headers["Authorization"] = f"Bearer {os.environ['BATCHIN_API_KEY']}"
response = requests.request(
"GET",
"https://batchin-api.onrender.com/v1/otlp/export",
headers=headers,
)
print(response.json())错误码 Code HTTP 信息 处理建议 unauthorized 401 API Key 无效或缺失 检查 Authorization: Bearer <API_KEY>。
前往 Try it GET /health公开
系统健康检查 服务健康状态探活端点。
代码示例 Python JavaScript cURL
import os
import requests
headers = {}
response = requests.request(
"GET",
"https://batchin-api.onrender.com/health",
headers=headers,
)
print(response.json())前往 Try it