Smart Batch のコストを見積もる
SmartBatch 上に残っている終了状態ではないすべての行について、実行前のクレジット見積もりを計算します。レスポンスでは、バッチの BatchConfiguration で有効になっているステップごとの内訳を示し、予測コストとクライアントアカウントの利用可能クレジット残高を比較します。
このエンドポイントを呼び出してもカタログ照会は実行されず、クレジットも一切消費されません。
エンドポイント
GET https://api.verifik.co/v2/smart-batches/{id}/estimate
このエンドポイントは、クライアント単位の Authorization: Bearer <VERIFIK_JWT> を使用することで Smart-Agent プロキシ(https://ai.verifik.co/v2/smart-batches/{id}/estimate)経由でもアクセスできます。共有 x402 実行は 403 Forbidden でブロックされます。
ヘッダー
| 名前 | 値 | 説明 |
|---|---|---|
Content-Type | application/json | リクエストペイロード形式。 |
Authorization | Bearer <VERIFIK_JWT> | クライアントスコープの JWT(authUser.clientId)。 |
パラメータ
| 名前 | 型 | 必須 | 説明 |
|---|---|---|---|
id | string | はい | 見積もり対象の SmartBatch ObjectId。 |
リクエスト
- Node.js
- PHP
- Python
- Go
- cURL
import axios from "axios";
const run = async () => {
const batchId = "6801a2b3c4d5e6f7a8b9c0d3";
const { data } = await axios.get(`https://api.verifik.co/v2/smart-batches/${batchId}/estimate`, {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.VERIFIK_JWT}`,
},
});
console.log(data);
};
run();
<?php
$batchId = "6801a2b3c4d5e6f7a8b9c0d3";
$ch = curl_init("https://api.verifik.co/v2/smart-batches/" . $batchId . "/estimate");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer " . getenv("VERIFIK_JWT"),
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
import os
import requests
batch_id = "6801a2b3c4d5e6f7a8b9c0d3"
url = f"https://api.verifik.co/v2/smart-batches/{batch_id}/estimate"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {os.getenv('VERIFIK_JWT')}",
}
response = requests.get(url, headers=headers)
print(response.json())
package main
import (
"encoding/json"
"fmt"
"net/http"
"os"
)
func main() {
batchID := "6801a2b3c4d5e6f7a8b9c0d3"
req, _ := http.NewRequest("GET", "https://api.verifik.co/v2/smart-batches/"+batchID+"/estimate", nil)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+os.Getenv("VERIFIK_JWT"))
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
var out map[string]interface{}
json.NewDecoder(resp.Body).Decode(&out)
fmt.Println(out)
}
curl -X GET "https://api.verifik.co/v2/smart-batches/6801a2b3c4d5e6f7a8b9c0d3/estimate" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $VERIFIK_JWT"
レスポンス
- 200 OK
- 401
- 403
- 404
- 409
- 422
{
"data": {
"itemCount": 25,
"creditsPerItem": 0.12,
"totalCredits": 3,
"breakdown": [
{
"sequence": 1,
"featureCode": "co-cedula",
"price": 0.04,
"total": 1
},
{
"sequence": 2,
"featureCode": "co-procuraduria",
"price": 0.08,
"total": 2
}
],
"pendingRows": 25,
"totalRows": 25,
"availableCredits": 10.5,
"sufficientCredits": true,
"shortfall": 0
}
}
{
"message": "Unauthorized",
"code": "Unauthorized"
}
{
"message": "Shared x402 execution is forbidden on this endpoint",
"code": "Forbidden"
}
{
"message": "batch_not_found",
"code": "NotFound"
}
{
"message": "batch_configuration_has_no_steps",
"code": "Conflict"
}
{
"message": "UnprocessableEntity",
"code": "UnprocessableEntity"
}
補足
itemCountとpendingRowsには、まだ終了状態の行ステータス(completed、failed、またはpartial)になっていない行のみが反映されます。availableCreditsはクライアントアカウントのcreditsとextraCreditsを合算した値です。sufficientCreditsがfalseの場合、shortfallは追加で必要なクレジット数を示します。- ステップごとの価格計算では、該当する場合にクライアントアカウントの
ClientFeatureスナップショット価格が使用されます。