当前本地集成契约;不是旧版v1服务。Cookie控制台与Bearer应用接口分开鉴权。不要在此页输入密钥。
POST /api/developer/license-usesAuthorization: Bearer(应用私有API Key);POST使用Content-Type: application/json。网页登录Cookie不能代替应用Key。
JSON必填:licenseId(UUID)、scene(short_drama/advertisement/education/game)、purpose(image/video)、channel(online/offline)、territory(CN/GLOBAL)、training(boolean)、idempotencyKey(1–128位字母数字_-)。全部范围须被有效许可允许,训练单独判断。
data.id为Use ID,关联licenseId、orderId、faceId、applicationId、requestId。成功扣一次许可次数;同应用同参数同幂等键返回原凭据,不再扣次。Use不是生成任务。
许可暂停或过期后的同请求重放仅返回历史凭据,不重新授权使用。
成功:{data, requestId};失败:{code, message, requestId, details?}。HTTP失败不要当作业务成功。
401 UNAUTHENTICATED;404 NOT_FOUND;409 LICENSE_NOT_ACTIVE / LICENSE_QUOTA_EXHAUSTED / IDEMPOTENCY_CONFLICT;422 LICENSE_SCOPE_DENIED / INVALID_INPUT。 服务内部错误返回安全错误,不显示数据库诊断。记录requestId用于排查。
先下载客户端,在私有进程配置环境变量。许可使用会扣次;只用自己的有效许可与允许范围。FACEPIC_USE_IDEMPOTENCY_KEY须预先保存,网络失败重试不能换新值。
import {FacePickClient} from './facepick-client.mjs';
const client = new FacePickClient({
baseUrl: process.env.FACEPIC_BASE_URL ?? 'http://127.0.0.1:3110',
apiKey: process.env.FACEPIC_API_KEY,
});
try {
const result = await client.useLicense({
licenseId: process.env.FACEPIC_LICENSE_ID,
purpose: 'image', channel: 'online', territory: 'CN', training: false, scene: 'education',
idempotencyKey: process.env.FACEPIC_USE_IDEMPOTENCY_KEY,
});
console.log(JSON.stringify({requestId: result.requestId}));
} catch (error) {
console.error(JSON.stringify({code: error.code ?? 'CLIENT_ERROR', status: error.status ?? 0, requestId: error.requestId ?? null}));
process.exitCode = 1;
}