使用带 OCR scope 的服务端 Developer API Key 鉴权,一次提交一个文件、公开图片 URL 或 Base64 内容,并获得标准化 OCR 输出。识别成功后扣除 Processing Credits,有效 key 的调用都会写入日志,方便统计用量。
POST https://your-domain.com/api/v1/ocr
Authorization: Bearer YOUR_API_KEY
OpenAPI: GET /api/v1/openapicurl -X POST https://your-domain.com/api/v1/ocr \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: invoice-001" \
-F "[email protected]" \
-F "mode=formatted"// 请在你的后端运行,不要放到浏览器 JavaScript 中。
const res = await fetch('https://your-domain.com/api/v1/ocr', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.DEVELOPER_API_KEY}`,
'Idempotency-Key': 'scan-001',
'Content-Type': 'application/json'
},
body: JSON.stringify({
image_url: 'https://example.com/scan.png',
mode: 'simple'
})
});
const data = await res.json();import base64
import requests
with open('receipt.jpg', 'rb') as f:
encoded = base64.b64encode(f.read()).decode('utf-8')
res = requests.post(
'https://your-domain.com/api/v1/ocr',
headers={'Authorization': 'Bearer YOUR_API_KEY'},
json={
'base64': encoded,
'mime_type': 'image/jpeg',
'file_name': 'receipt.jpg',
'mode': 'formatted'
},
timeout=120,
)
print(res.json())返回 success、request_id、elapsed_ms、markdown、text、pages 和 usage。
API Key 缺失、无效或已禁用。
Key 所属用户 Processing Credits 不足,无法覆盖预计页数和识别模式。
同一个 Idempotency-Key 已经被不同 OCR 输入使用。
输入已处理,但没有识别到可读文字。
触发每日 API 限制、页数限制或最小请求间隔。
API 使用与网页产品一致的 OCR 规范化、Processing Credit 规则和限制体系。
用户可以创建带 OCR scope 的 Developer API Key。完整密钥只显示一次,应保存在服务端。
Simple 和 Formatted 按页消耗 Processing Credits,识别成功后才扣除。
有效 key 的请求会记录 request_id、状态、耗时、Processing Credits、来源类型、IP 和 User-Agent。
API 日志保存计量元数据,用于监控和滥用检测。OCR 输出返回给调用方,识别失败不扣积分。
开发者关心的鉴权、扣费和响应格式。