/api/gateway/usage/importImport historical local usage
Attributes per-turn token counts from local Codex or Claude Code logs (metadata only) to your organization, priced at current catalog list rates. Never charged and never deducted from credits. Idempotent per record identity; unknown models are kept at zero cost and listed in unmatched_models.
認証: AuthorizationヘッダーにBearer形式のAPIキー
リクエストボディ
batch_idstring必須Groups the run; replaying the same records inserts nothing.
recordsarray<object>必須records
modelstring必須Model id as the local log names it.
input_tokensinteger必須Fresh (non-cached) input.
output_tokensinteger必須Output including reasoning.
cached_tokensintegerCached input.
reasoning_tokensintegerReasoning subset of output, for display.
timestampstring必須ISO 8601 turn time; naive values read as UTC.
sourceenum必須event_idstring | nullThe log's stable per-turn id, folded into the dedupe hash.
org_idstring | nullIgnored for API keys: a key always imports into its own organization.
レスポンス
201Imported.
レスポンス
batch_idstring必須receivedinteger必須importedinteger必須Newly inserted records.
duplicatesinteger必須Records already imported before.
unmatched_modelsarray<string>必須by_modelarray<object>必須The organization's whole imported attribution after this batch.
by_model
sourceenum必須modelstring必須Catalog slug when matched, else the raw model id.
model_matchedboolean必須False when the model is outside the catalog (priced at 0).
request_countinteger必須input_tokensinteger必須output_tokensinteger必須cached_input_tokensinteger必須reasoning_tokensinteger必須cost_usdnumber必須Historical attribution at current list rates, dollars. Never charged.
totalsobject必須totals
request_countinteger必須input_tokensinteger必須output_tokensinteger必須cost_usdnumber必須Dollars, attribution only.
400Empty batch, more than 10,000 records, or a bad timestamp.
レスポンス
errorstring必須Human-readable message.
codestringStable machine reason, when the route defines one (for example
pro_required).actionstringStable remediation action, when the route defines one.
detailsobjectCustomer-safe string facts the caller needs to act (for example a suggested identifier).
401Missing, unknown or revoked API key.
レスポンス
errorstring必須Human-readable message.
codestringStable machine reason, when the route defines one (for example
pro_required).actionstringStable remediation action, when the route defines one.
detailsobjectCustomer-safe string facts the caller needs to act (for example a suggested identifier).
403Not called with an organization API key.
レスポンス
errorstring必須Human-readable message.
codestringStable machine reason, when the route defines one (for example
pro_required).actionstringStable remediation action, when the route defines one.
detailsobjectCustomer-safe string facts the caller needs to act (for example a suggested identifier).
422The body or query failed validation.
レスポンス
detailarray<object>必須detail
typestringlocarray<string | integer>msgstring
リクエスト
curl -X POST https://api.experientiallabs.ai/api/gateway/usage/import \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"batch_id": "laptop-2026-11-18",
"records": [
{
"model": "claude-sonnet-4-6",
"input_tokens": 1840,
"output_tokens": 622,
"cached_tokens": 41200,
"reasoning_tokens": 0,
"timestamp": "2026-11-12T18:04:11Z",
"source": "claude-code",
"event_id": "msg_01Hq8Xc2"
},
{
"model": "gpt-5.5-codex",
"input_tokens": 3120,
"output_tokens": 904,
"cached_tokens": 12800,
"reasoning_tokens": 512,
"timestamp": "2026-11-13T09:41:52Z",
"source": "codex",
"event_id": "sess-7f2a:14"
}
]
}'レスポンス
{
"batch_id": "laptop-2026-11-18",
"received": 2,
"imported": 2,
"duplicates": 0,
"unmatched_models": [],
"by_model": [
{
"source": "claude-code",
"model": "claude-sonnet-4.6",
"model_matched": true,
"request_count": 1,
"input_tokens": 1840,
"output_tokens": 622,
"cached_input_tokens": 41200,
"reasoning_tokens": 0,
"cost_usd": 0.027
},
{
"source": "codex",
"model": "gpt-5.5-codex",
"model_matched": true,
"request_count": 1,
"input_tokens": 3120,
"output_tokens": 904,
"cached_input_tokens": 12800,
"reasoning_tokens": 512,
"cost_usd": 0.0167
}
],
"totals": {
"request_count": 2,
"input_tokens": 4960,
"output_tokens": 1526,
"cost_usd": 0.0437
}
}https://api.experientiallabs.ai/api/gateway/usage/import