> ## Documentation Index
> Fetch the complete documentation index at: https://aisa.one/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> - Base URLs: models `https://api.aisa.one/v1` (Gemini GenerateContent: `https://api.aisa.one/v1beta`); data APIs `https://api.aisa.one/apis/v1`. The `servers` of each operation in https://aisa.one/openapi.yaml is authoritative.
> - Auth: `Authorization: Bearer $AISA_API_KEY`. Never print, log, or commit the key.
> - MCP (preferred for agents): `https://mcp.aisa.one/mcp`, signed in with OAuth, so there is no key to paste.
> - Agent Skill: `npx skills add AIsa-team/agent-skills --skill aisa`. Fallback with the AIsa CLI: `aisa skills install aisa`.
> - Spending: docs, https://aisa.one/models, https://aisa.one/api, `/v1/models`, and MCP `search`, `list_categories`, `get_details`, `batch_quote`, and the `account` operation are free. Quote the exact calls before running them (MCP `batch_quote`, CLI `aisa quote --json`). If the quote reports `auto_execute_eligible: true`, run it unless the user set a tighter limit or asked only for a quote. Otherwise, tell the user in one message the planned calls, the quoted price, and a total USD budget for the task, then wait for approval. Direct HTTP calls follow the stricter rule at https://aisa.one/docs/get-started/cli.md#direct-http-fallback. Do not make paid calls to test availability. Full rule: https://aisa.one/llms.txt

# 账户用量

> 通过现有账户 API 查询汇总用量。

使用下方声明的范围与时间参数查询汇总用量。
控制台查询流程与逐笔记录请参阅[用量](https://aisa.one/docs/zh/guides/dashboard/overview.md#用量)。

## 请求规范

* **方法与路径:** GET /usage
* **请求 URL 模板:** `https://api.aisa.one/v1/usage`
* **start\_time:** query; 必填
* **end\_time:** query; 可选

[完整 OpenAPI 定义](https://aisa.one/docs/reference-contracts/zh/account.json)

有效请求声明（包括认证和引用的 schema）：

```json theme={null}
{
  "operationId": "accountUsage",
  "method": "GET",
  "path": "/usage",
  "servers": [
    {
      "url": "https://api.aisa.one/v1"
    }
  ],
  "parameters": [
    {
      "description": "Window start as a Unix timestamp in seconds.",
      "in": "query",
      "name": "start_time",
      "required": true,
      "schema": {
        "format": "int64",
        "type": "integer"
      }
    },
    {
      "description": "Window end as a Unix timestamp in seconds. Defaults to the current time.",
      "in": "query",
      "name": "end_time",
      "required": false,
      "schema": {
        "format": "int64",
        "type": "integer"
      }
    }
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "bearerFormat": "AISA API Key or OAuth access token",
        "scheme": "bearer",
        "type": "http"
      }
    }
  }
}
```


## OpenAPI

````yaml reference-contracts/zh/account.json GET /usage
openapi: 3.0.3
info:
  description: >-
    Programmatic account endpoints for balance and usage monitoring. Both accept
    an AIsa API key (Bearer) or an OAuth access token, so unattended production
    callers can read balance and usage for cost monitoring and alerting.


    All monetary values are integer micro-USD (1 USD = 1,000,000 micros).
  title: AIsa Account & Usage API
  version: 1.0.0
servers:
  - url: https://api.aisa.one/v1
security:
  - BearerAuth: []
paths:
  /usage:
    get:
      summary: Account Usage
      description: >-
        Return request and spend usage over a time window, split into daily
        buckets. Accepts either an API key or an OAuth access token. The scope
        reflects the credential used (e.g. a single key vs the whole account).
      operationId: accountUsage
      parameters:
        - description: Window start as a Unix timestamp in seconds.
          in: query
          name: start_time
          required: true
          schema:
            format: int64
            type: integer
        - description: >-
            Window end as a Unix timestamp in seconds. Defaults to the current
            time.
          in: query
          name: end_time
          required: false
          schema:
            format: int64
            type: integer
      responses:
        '200':
          content:
            application/json:
              example:
                bucket_width: 1d
                buckets:
                  - cache_read_tokens: 0
                    cache_write_tokens: 0
                    charged_micros_usd: 5123400
                    end_time: 1785600000
                    failed_requests: 3
                    input_tokens: 8123
                    output_tokens: 210
                    requests: 42
                    start_time: 1785513600
                    usage_value_micros_usd: 5123400
                currency: USD
                end_time: 1787760000
                scope: key
                start_time: 1785513600
                totals:
                  cache_read_tokens: 0
                  cache_write_tokens: 0
                  charged_micros_usd: 128398109
                  failed_requests: 401
                  input_tokens: 206393
                  output_tokens: 5031
                  requests: 1162
                  usage_value_micros_usd: 128398109
              schema:
                properties:
                  bucket_width:
                    description: Bucket granularity (e.g. 1d).
                    type: string
                  buckets:
                    description: Per-bucket usage, ordered by time.
                    items:
                      properties:
                        cache_read_tokens:
                          format: int64
                          type: integer
                        cache_write_tokens:
                          format: int64
                          type: integer
                        charged_micros_usd:
                          format: int64
                          type: integer
                        end_time:
                          format: int64
                          type: integer
                        failed_requests:
                          format: int64
                          type: integer
                        input_tokens:
                          format: int64
                          type: integer
                        output_tokens:
                          format: int64
                          type: integer
                        requests:
                          format: int64
                          type: integer
                        start_time:
                          format: int64
                          type: integer
                        usage_value_micros_usd:
                          format: int64
                          type: integer
                      type: object
                    type: array
                  currency:
                    description: ISO currency code (always USD).
                    type: string
                  end_time:
                    description: Echoed window end (Unix seconds).
                    format: int64
                    type: integer
                  scope:
                    description: >-
                      Aggregation scope implied by the credential (e.g. key or
                      account).
                    type: string
                  start_time:
                    description: Echoed window start (Unix seconds).
                    format: int64
                    type: integer
                  totals:
                    description: Aggregate totals across the whole window.
                    properties:
                      cache_read_tokens:
                        format: int64
                        type: integer
                      cache_write_tokens:
                        format: int64
                        type: integer
                      charged_micros_usd:
                        description: Amount actually charged in micro-USD.
                        format: int64
                        type: integer
                      failed_requests:
                        format: int64
                        type: integer
                      input_tokens:
                        format: int64
                        type: integer
                      output_tokens:
                        format: int64
                        type: integer
                      requests:
                        format: int64
                        type: integer
                      usage_value_micros_usd:
                        description: Metered value of usage in micro-USD.
                        format: int64
                        type: integer
                    type: object
                type: object
          description: Usage totals and per-day buckets over the window.
        '400':
          content:
            application/json:
              example:
                error: start_time must be a positive Unix timestamp
          description: >-
            Invalid or missing time window (e.g. start_time not a positive Unix
            timestamp).
components:
  securitySchemes:
    BearerAuth:
      bearerFormat: AISA API Key or OAuth access token
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.