API ReferenceUsage & Reporting

Reporting Access Key

Reporting Access Key は、利用量の照合に使うダッシュボード管理の読み取り専用キーです。通常のモデル API キーを公開せずに、社内のレポーティングサービス、会計ワークフロー、BI パイプラインから API キー情報、トークン使用量、タスク履歴、コストデータを参照できます。

1. 利用シーン

次のようなケースで使用します。

  • Reconcile invoice totals with task-level usage records
  • Export usage data to internal BI, FinOps, or monitoring systems
  • Track token consumption and cost by API key, model, task type, status, or day
  • Investigate individual task records without sharing operational dashboard access

これはモデル呼び出し用のキーではありません。利用できるのは /api/open/v1/* のレポーティング API のみです。

2. キーの作成と管理

ダッシュボードで次のページを開きます。

/dashboard/apikeys

In the Reporting Access Key card:

  1. Click Generate to create the key.
  2. Copy the key and store it in a secure secret manager.
  3. Use Copy when you need to retrieve the full value again.
  4. Use Revoke to disable the current key.

セキュリティ仕様:

  • The page shows only a masked key by default.
  • The full key is fetched only when you click Copy.
  • The full key should not be stored in localStorage, analytics, screenshots, tickets, or client logs.
  • Each user currently has at most one active Reporting Access Key.
  • Revoked keys stop working immediately and are not hard-deleted.

3. 認証

Authorization ヘッダーに Reporting Access Key を指定します。

Authorization: Bearer <REPORTING_ACCESS_KEY>
Accept: application/json

レスポンスは共通のエンベロープ形式です。

{
  "code": 200,
  "msg": "",
  "data": {}
}

4. エンドポイント

EndpointPurposeMax date range
GET /api/open/v1/apikeysList visible API keys and their last usage timeNot applicable
GET /api/open/v1/usage/summaryAggregate requests, tokens, credits, and USD amount31 days
GET /api/open/v1/usage/dailyDaily usage breakdown, optionally grouped by API key and model31 days
GET /api/open/v1/usage/tasksPaginated task-level usage records7 days
GET /api/open/v1/usage/tasks/{task_id}Single task detailNot applicable

Base URL:

https://reachapi.ai/api/open/v1

ローカル開発では次を使用できます。

http://localhost:3000/api/open/v1

5. API キー一覧

curl -sS "https://reachapi.ai/api/open/v1/apikeys?page=1&page_size=20&status=active" \
  -H "Authorization: Bearer <REPORTING_ACCESS_KEY>"

Query parameters:

FieldTypeRequiredDescription
pageintegerNoPage number. Default: 1
page_sizeintegerNoPage size. Default: 50, maximum: 200
statusstringNoFilter API keys by status, for example active

Example response:

{
  "code": 200,
  "msg": "",
  "data": {
    "total": 3,
    "page": 1,
    "page_size": 20,
    "items": [
      {
        "apikey_id": "ak_123",
        "apikey_name": "Production gateway",
        "status": "active",
        "created_at": "2026-06-27T08:00:00.000Z",
        "last_used_at": "2026-06-27T09:15:00.000Z",
        "hourly_limit_usd": "5.00000000",
        "daily_limit_usd": "20.00000000",
        "total_limit_usd": "100.00000000",
        "quota_timezone": "Asia/Shanghai"
      }
    ]
  }
}

各項目の内容:

フィールド説明
apikey_idAPI key ID
apikey_nameAPI key 名
statusAPI key の状態(active / deleted
created_at作成日時
last_used_at最終利用日時(未使用の場合は null
hourly_limit_usd時間あたり利用上限(USD)、未設定の場合は null
daily_limit_usd日次利用上限(USD)、未設定の場合は null
total_limit_usd累計利用上限(USD)、未設定の場合は null
quota_timezone上限ウィンドウのタイムゾーン(デフォルト Asia/Shanghai

6. 利用量サマリー

curl -sS "https://reachapi.ai/api/open/v1/usage/summary?start_date=2026-06-01&end_date=2026-06-07&timezone=Asia/Shanghai" \
  -H "Authorization: Bearer <REPORTING_ACCESS_KEY>"

Query parameters:

FieldTypeRequiredDescription
start_datestringYesDate in YYYY-MM-DD format
end_datestringYesDate in YYYY-MM-DD format. Maximum 31-day range
timezonestringNoIANA timezone. Default: UTC
apikey_idstringNoFilter by one visible API key
modelstringNoFilter by model ID
task_typestringNoFilter by task type
statusstringNoFilter by task status
finance_statusstringNoFilter by billing status
provider_job_idstringNoFilter by upstream provider job ID

The response includes request counts, success/error counts, token buckets, actual_credits, and total_amount in USD string format.

7. 日次集計

curl -sS "https://reachapi.ai/api/open/v1/usage/daily?start_date=2026-06-01&end_date=2026-06-07&group_by=apikey,model" \
  -H "Authorization: Bearer <REPORTING_ACCESS_KEY>"

group_by supports:

ValueDescription
noneOne row per day
apikeyGroup by day and API key
modelGroup by day and model
apikey,modelGroup by day, API key, and model

8. タスク一覧

curl -sS "https://reachapi.ai/api/open/v1/usage/tasks?start_date=2026-06-01&end_date=2026-06-07&page=1&page_size=50" \
  -H "Authorization: Bearer <REPORTING_ACCESS_KEY>"

The task list supports the same filters as usage/summary. The date range is limited to 7 days to keep reconciliation queries predictable.

Each item includes:

FieldDescription
task_idInternal task ID
created_at, completed_atTask timestamps
model, task_typeModel and workload type
apikey_id, apikey_nameAPI key attribution
provider_job_idUpstream provider job ID when available
status, finance_statusExecution and billing state
token fieldsInput, output, cache, reasoning, image, audio, and video token usage
total_amount, actual_creditsUSD amount string and internal credit amount

9. タスク詳細

curl -sS "https://reachapi.ai/api/open/v1/usage/tasks/task_123" \
  -H "Authorization: Bearer <REPORTING_ACCESS_KEY>"

The detail endpoint returns one task with amount, token, and error information. It is useful when reconciling a single customer ticket, provider job, or billing row.

10. エラー

HTTP statusmsg exampleScenario
401UnauthorizedMissing, malformed, invalid, or revoked Reporting Access Key
400Invalid paginationpage or page_size is not a positive integer
400Invalid start_date / Invalid end_dateDate format is not YYYY-MM-DD
400Date range is too largeDate range exceeds the endpoint limit
400Invalid group_byUnsupported daily grouping value
403ForbiddenThe requested apikey_id is not visible to this Reporting Access Key
404Task not foundTask does not exist or is not visible

11. アクセスログ

Customer calls made with a Reporting Access Key are written to a dedicated access-key usage log on the server.

The log is designed for operational review and does not store secrets. It records only redacted request metadata such as event name, request ID, key prefix, user ID, method, path, safe query parameters, status code, duration, IP, user agent, and error code.

It does not record full access keys, Authorization headers, cookies, passwords, key hashes, ciphertext, or database connection strings.

On this page