使用量明細の取得
システムアクセストークンで自身のアカウントデータを取得
中国本土のユーザー向け: 中国本土のユーザーは https://toapis.cn を API エンドポイント (Base URL)としてご利用ください. 本ドキュメント内の例では https://toapis.com を https://toapis.cn に置き換えてください.
認証, ページ分割, エラーは利用ガイドを参照してください.
動作
最大範囲は 31 日です. 明細は作成時刻と ID の降順. 集計は日付昇順, モデルの UTF-8 バイト順, またはキーの null グループの後に数値 ID 昇順です. 各項目には対応する day, model, api_key_id のみ含みます. record_count はログ行数で完全なリクエスト件数ではありません. billing_phase は pre_consumed, settled, unknown で最終課金状態とは異なります. trace は元のリクエストです. 任意の追跡情報と上流合計 token は null になる場合がありますが, 金額と入出力 token は保持されます. records_mutable=true, refund_accounting=not_complete, consistency=eventual. 精算や返金で過去の行が変わり, 空の結果は消費ゼロを証明しません. 一方向同期は更新の取得を保証しません.
認証
Authorizationstringヘッダー必須Bearer YOUR_SYSTEM_ACCESS_TOKEN を使用します. モデル API キーは使用できません. X-User-Id は不要です.
パラメータ
fromstringクエリ必須タイムゾーン付き RFC 3339 の開始時刻. この時刻を含みます. to と一緒に指定します.
制約: date-time.
tostringクエリ必須タイムゾーン付き RFC 3339 の終了時刻. この時刻を含まず, from より後である必要があります.
制約: date-time.
api_key_idstringクエリ自身のモデル API キーの 10 進 ID 文字列. 他人のキーは 404. 削除済みキーでも自身の過去の使用量を絞り込めます.
制約: pattern=^[1-9][0-9]*$.
modelstringクエリモデル ID の完全一致. 使用量では空文字列は空のモデル名に一致します.
制約: maxLength=255.
limitintegerクエリデフォルト: 501 ページの最大件数.
制約: minimum=1; maximum=100; 既定値: 50.
cursorstringクエリ前の next_cursor を変更せずに渡します. フィルターを維持し, 変更時は最初から取得します.
制約: maxLength=2048.
リクエスト例
curl --request GET \
--url 'https://toapis.com/api/v1/account/usage/records?from=2026-11-01T00:00:00Z&to=2026-11-02T00:00:00Z&api_key_id=42&limit=20' \
--header 'Authorization: Bearer YOUR_SYSTEM_ACCESS_TOKEN'import requests
response = requests.get(
"https://toapis.com/api/v1/account/usage/records",
headers={"Authorization": "Bearer YOUR_SYSTEM_ACCESS_TOKEN"},
params={
"from": "2026-11-01T00:00:00Z",
"to": "2026-11-02T00:00:00Z",
"api_key_id": "42",
"limit": "20"
},
timeout=30,
)
response.raise_for_status()
print(response.json())const url = new URL("https://toapis.com/api/v1/account/usage/records");
url.search = new URLSearchParams({
"from": "2026-11-01T00:00:00Z",
"to": "2026-11-02T00:00:00Z",
"api_key_id": "42",
"limit": "20"
}).toString();
const response = await fetch(url, {
headers: { Authorization: "Bearer YOUR_SYSTEM_ACCESS_TOKEN" },
signal: AbortSignal.timeout(30_000),
});
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${await response.text()}`);
}
console.log(await response.json());レスポンスフィールド
例は架空のデータで, credits_per_usd="100" を仮定しています. 実際の換算にはレスポンスの値を使用してください.
結果は data.items にあります. has_more と next_cursor で次のページを取得します. 最終カーソルは null です. 総件数は返しません.
codeinteger結果コード. 0 は成功です.
messagestring成功時は空文字列です. エラーメッセージは翻訳されます.
dataobject今回の照会結果オブジェクトです.
data.itemsobject[]現在のページのレコード一覧. 空の場合は [] です.
data.items[].idstring消費ログのレコード ID です. 10 進 ID 文字列で返します.
data.items[].created_atstring | null作成時刻です. タイムゾーン付き RFC 3339 形式です. 不明または対象外の場合は null です.
data.items[].api_key_idstring | null関連するモデル API キーの ID. 関連なしは null です.
data.items[].key_namestring | nullログに記録された API キー名です. 不明または対象外の場合は null です.
data.items[].modelstringモデル識別子です.
data.items[].task_idstring | null関連するプラットフォームタスク ID です. 不明または対象外の場合は null です.
data.items[].recorded_cost_usdstring現在の消費ログの USD 額です. 完全な返金反映後の純支出ではありません. 精度を保持するため 10 進文字列で返します.
data.items[].recorded_creditsstring現在の消費ログに記録された credits です. 精度を保持するため 10 進文字列で返します.
data.items[].billing_phasestringログの課金段階です. タスクの最終課金状態とは異なります. 値: pre_consumed, settled, unknown.
data.items[].usageobject入力, 出力, 上流報告の token 数です.
data.items[].usage.input_tokensintegerログに記録された入力 token 数です.
data.items[].usage.output_tokensintegerログに記録された出力 token 数です.
data.items[].usage.reported_total_tokensinteger | null上流が報告した総 token 数. 不明なら null で, 入出力から補完しません.
data.items[].traceobject | null元の生成リクエストの追跡情報で, 今回の照会 ID とは異なります. 不明または対象外の場合は null です.
data.items[].trace.request_idstring | null元の生成リクエストのプラットフォーム追跡 ID です. 不明または対象外の場合は null です.
data.items[].trace.client_request_idstring | null元の生成リクエストに記録されたクライアント ID です. 不明または対象外の場合は null です.
data.has_moreboolean次のページがあるかを示します.
data.next_cursorstring | null同じ条件で cursor にそのまま渡します. 最終ページは null です.
data.metaobjectデータソース, 照会範囲, 集計基準などのメタデータです.
data.meta.scopestring照会対象の所有範囲で, 認証された自身のアカウントです. 固定値: "self".
data.meta.fromstring照会時間範囲の開始時刻を含みます. タイムゾーン付き RFC 3339 形式です.
data.meta.tostring照会時間範囲の終了時刻は含みません. タイムゾーン付き RFC 3339 形式です.
data.meta.time_basisstring時間絞り込みと日付集計は消費ログの作成時刻を使います. 固定値: "record_created_at".
data.meta.cost_basisstring金額は現在の消費ログ値で, 固定された最終請求額ではありません. 固定値: "current_consume_log_amount".
data.meta.refund_accountingstring返金反映の完全性です. not_complete は完全な純支出台帳ではないことを示します. 固定値: "not_complete".
data.meta.records_mutableboolean精算や返金で更新されるかを示し, 現在は true です.
data.meta.consistencystringeventual は結果整合性で, レコードは後で更新される場合があります. 固定値: "eventual".
data.meta.consume_logging_enabledboolean消費ログの有効状態です. 記録なしは課金ゼロを証明しません.
data.meta.credits_per_usdstring1 USD あたりの credits 数. 換算にはこの値を使います. 精度を保持するため 10 進文字列で返します.
レスポンス例
{
"code": 0,
"message": "",
"data": {
"items": [
{
"id": "9001",
"created_at": "2026-11-01T08:00:00Z",
"api_key_id": "42",
"key_name": "Example Key",
"model": "example-text-model",
"task_id": null,
"recorded_cost_usd": "0.02",
"recorded_credits": "2",
"billing_phase": "settled",
"usage": {
"input_tokens": 1000,
"output_tokens": 200,
"reported_total_tokens": 1200
},
"trace": {
"request_id": "request_example_01",
"client_request_id": "client_example_01"
}
}
],
"has_more": false,
"next_cursor": null,
"meta": {
"scope": "self",
"from": "2026-11-01T00:00:00Z",
"to": "2026-11-02T00:00:00Z",
"time_basis": "record_created_at",
"cost_basis": "current_consume_log_amount",
"refund_accounting": "not_complete",
"records_mutable": true,
"consistency": "eventual",
"consume_logging_enabled": true,
"credits_per_usd": "100"
}
}
}