1. Count characters and estimate cost from an uploaded file
Use action=token_estimate before quoting or accepting a full run. For pilot file uploads, send estimated_chars as the prepaid-credit guard; the completed task returns system-side statistics such as source characters and estimated tokens.
Poll https://xsfyj.com/api/b2b/v1/tasks/{task_id}. Completed estimate tasks may include total_characters, estimated_tokens, detected_language, and estimated credits depending on file type.
curl https://xsfyj.com/api/b2b/v1/tasks \
-H "Authorization: Bearer nt_live_xxxxxxxxxxxxxxxxx" \
-H "Idempotency-Key: partner-estimate-001" \
-F "action=token_estimate" \
-F "target_lang=en" \
-F "estimated_chars=120000" \
-F "[email protected]"{
"success": true,
"data": {
"task_id": "TSK_EST_01HV8W...",
"status": "pending",
"action": "token_estimate",
"file_name": "novel.txt",
"target_lang": "en",
"char_count": 120000,
"estimated_credits": 120000,
"created_at": "2026-06-16T10:30:00Z"
}
}