# 現在のトークンログ API

Use your **API Call Token (`sk-xxx`)** to query call logs, cost/token summaries, and async task records generated by the current token.

> [!IMPORTANT]
> - **Base URL**: `https://ai.artsmcp.com`
> - **Auth Header**: `Authorization: Bearer sk-your_api_token` (also supports `x-api-key`, `x-goog-api-key`)
> - **Pagination & Rate Limits**: Online pagination supports up to the first `20,000` records; `/v1/logs` is rate-limited to `30 req/min` and `/v1/task_logs` to `60 req/min`; timestamps use the **site operating timezone**

---

### 1. List Current Token Call Logs

Paginated query of model requests made by the current `sk-xxx` token. Summary stats (`total_cost`, `success_count`, `total_tokens`, etc.) are computed on `page=1` only (defaulting to the past 30 calendar days when `start_date` is omitted) and return `0` on `page > 1`.

* **Path**: `GET /v1/logs`
* **Query Parameters**:

| Parameter | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| `page` | `integer` | `1` | Page number (starting from `1`) |
| `per_page` | `integer` | `20` | Items per page (`1..100`) |
| `model` | `string` | All | Fuzzy filter by model ID (e.g., `gpt-4o`) |
| `status` | `string` | All | Filter by status: `success`, `fail`, `processing` |
| `status_code` | `integer` | All | Filter by exact HTTP status code (e.g., `200`, `429`) |
| `action_type` | `string` | All | Filter by type: `chat`, `image`, `video`, `audio`, `embedding`, `rerank`, `vision`, `other` |
| `log_id` | `string` | None | Exact lookup by `log_id` |
| `task_id` | `string` | None | Exact lookup by async `task_id` |
| `start_date` | `string` | None | Start time (`YYYY-MM-DD` or `YYYY-MM-DD HH:mm:ss` in site operating timezone) |
| `end_date` | `string` | None | End time (`YYYY-MM-DD` or `YYYY-MM-DD HH:mm:ss` in site operating timezone) |
| `has_video` | `integer` | All | Filter by video input (`1` yes, `0` no) |

* **Example (Curl)**:

```bash
curl -s "https://ai.artsmcp.com/v1/logs?page=1&per_page=20&status=success" \
  -H "Authorization: Bearer sk-your_api_token"
```

* **Response Example**:

```json
{
  "data": [
    {
      "log_id": "log_01jdxyz1234567890abcdef",
      "token_kid": "086421",
      "token_name": "prod-sub-key",
      "model": "gpt-4o",
      "endpoint": "/v1/chat/completions",
      "action_type": "chat",
      "prompt_tokens": 128,
      "completion_tokens": 256,
      "cached_tokens": 0,
      "cost": 0.0042,
      "pre_deduct_gift": 0.0,
      "latency_ms": 860,
      "status_code": 200,
      "is_stream": 1,
      "is_completed": 1,
      "has_video": 0,
      "created_at": "2026-11-29 21:25:10 (UTC+8)"
    }
  ],
  "total": 1,
  "page": 1,
  "per_page": 20,
  "total_cost": 0.0042,
  "total_system_cost": 0.0042,
  "total_gift_cost": 0.0,
  "success_count": 1,
  "fail_count": 0,
  "total_tokens": 384,
  "total_prompt_tokens": 128,
  "total_completion_tokens": 256
}
```

* **Response Fields**:

| Field | Type | Description |
| :--- | :--- | :--- |
| `data` | `array` | Call log records on the current page |
| `data[].log_id` | `string` | Unique log identifier |
| `data[].token_kid` / `data[].token_name` | `string` | Token `kid` and name |
| `data[].model` / `data[].endpoint` | `string` | Model ID and request path |
| `data[].action_type` | `string` | Request category (e.g., chat, image, video, audio) |
| `data[].prompt_tokens` / `data[].completion_tokens` / `data[].cached_tokens` | `integer` | Input, output, and cached token counts |
| `data[].cost` / `data[].pre_deduct_gift` | `number` | Settled total cost and gift balance portion |
| `data[].latency_ms` | `integer` | Request latency in milliseconds |
| `data[].status_code` | `integer` | HTTP status code (`0` while processing) |
| `data[].is_stream` / `data[].is_completed` / `data[].has_video` | `integer` | Streaming flag, completion flag, and video-input flag (`1` yes, `0` no) |
| `data[].created_at` | `string` | Creation timestamp in site operating timezone |
| `total` / `page` / `per_page` | `integer` | Total matching records, current page, and page size |
| `total_cost` / `total_system_cost` / `total_gift_cost` | `number` | Total, cash, and gift cost summaries (`page=1` only) |
| `success_count` / `fail_count` | `integer` | Succeeded and failed request counts (`page=1` only) |
| `total_tokens` / `total_prompt_tokens` / `total_completion_tokens` | `integer` | Total, input, and output token summaries (`page=1` only) |

---

### 2. List Current Token Async Tasks

Paginated query of video/image async generation tasks and preview URLs initiated by the current `sk-xxx` token. For real-time polling or cancellation of a single task, use the corresponding protocol endpoint (such as `GET /v1/video/generations/{task_id}` or `DELETE /v1/video/generations/{task_id}`).

* **Path**: `GET /v1/task_logs`
* **Query Parameters**:

| Parameter | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| `page` | `integer` | `1` | Page number (starting from `1`) |
| `per_page` | `integer` | `20` | Items per page (`1..100`) |
| `model` | `string` | All | Fuzzy filter by model ID |
| `status` | `string` | All | Filter by status: `success`, `fail`, `processing` |
| `action_type` | `string` | All | Filter by task type (e.g., `image`, `video`, `audio`) |
| `log_id` | `string` | None | Exact lookup by `log_id` |
| `task_id` | `string` | None | Exact lookup by async `task_id` |
| `start_date` | `string` | None | Start time (`YYYY-MM-DD` or `YYYY-MM-DD HH:mm:ss`) |
| `end_date` | `string` | None | End time (`YYYY-MM-DD` or `YYYY-MM-DD HH:mm:ss`) |

* **Example (Curl)**:

```bash
curl -s "https://ai.artsmcp.com/v1/task_logs?page=1&per_page=20" \
  -H "Authorization: Bearer sk-your_api_token"
```

* **Response Example**:

```json
{
  "data": [
    {
      "log_id": "log_01jdvideo9876543210abcd",
      "task_id": "cgt-20261129210000-xxxxx",
      "token_kid": "086421",
      "token_name": "prod-sub-key",
      "model": "doubao-seedance-1-0-pro-250528",
      "endpoint": "/v1/video/generations",
      "action_type": "video",
      "prompt_tokens": 0,
      "completion_tokens": 108000,
      "cached_tokens": 0,
      "cost": 1.5,
      "latency_ms": 42000,
      "status_code": 200,
      "is_completed": 1,
      "has_video": 0,
      "preview_urls": [
        "https://example-cdn.com/videos/output.mp4"
      ],
      "created_at": "2026-11-29 21:10:00 (UTC+8)"
    }
  ],
  "total": 1,
  "page": 1,
  "per_page": 20
}
```

* **Response Fields**:

| Field | Type | Description |
| :--- | :--- | :--- |
| `data` | `array` | Async task records on the current page |
| `data[].log_id` / `data[].task_id` | `string` | Log ID and async task ID |
| `data[].token_kid` / `data[].token_name` | `string` | Token `kid` and name |
| `data[].model` / `data[].endpoint` | `string` | Model ID and submission path |
| `data[].action_type` | `string` | Task type (e.g., video, image) |
| `data[].prompt_tokens` / `data[].completion_tokens` / `data[].cached_tokens` | `integer` | Input, output, and cached token counts |
| `data[].cost` / `data[].latency_ms` | `number` / `integer` | Settled task cost and latency (ms) |
| `data[].status_code` / `data[].is_completed` | `integer` | Terminal HTTP status code and completion flag (`1` done, `0` processing) |
| `data[].preview_urls` | `string[]` | Output preview URLs once completed |
| `data[].created_at` | `string` | Task submission timestamp in site operating timezone |
| `total` / `page` / `per_page` | `integer` | Total records, current page, and page size |
