> ## 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 Key 实际可用的额度。

查询当前钱包余额，以及发起请求的 API Key 实际可用的额度。该接口为只读接口，
不接受查询参数。

## 请求

```bash curl theme={null}
curl -sS https://api.aisa.one/v1/credits/balance \
  -H "Authorization: Bearer $AISA_API_KEY"
```

接口要求在 `Authorization` 请求头中提供标准 AIsa API Key，不接受 MPP 支付授权。

## 响应

```json theme={null}
{
  "currency": "USD",
  "account_balance_micros_usd": 3250000,
  "available_balance_micros_usd": 1750000,
  "go_to_market_balance_micros_usd": 750000,
  "gtm": {
    "active": true,
    "balance_micros_usd": 750000,
    "trial_balance_micros_usd": 250000,
    "trial_expires_at": "2026-10-31T12:00:00Z",
    "subscription_balance_micros_usd": 400000,
    "subscription_addon_balance_micros_usd": 100000,
    "subscription_addon_available_micros_usd": 100000,
    "subscription_addon_frozen_micros_usd": 0,
    "expires_at": "2026-10-31T12:00:00Z"
  },
  "media_promo": {
    "balance_micros_usd": 200000,
    "next_expires_at": "2026-10-31T12:00:00Z"
  },
  "api_key": {
    "unlimited": false,
    "remaining_micros_usd": 1000000,
    "used_micros_usd": 300000
  },
  "as_of": "2026-10-12T12:00:00Z"
}
```

所有金额均使用整数微美元。一美元等于 `1,000,000` 微美元，以避免自动化客户端
出现浮点舍入误差。

### 顶层字段

| 字段 | 类型 | 说明 |
| - | - | - |
| `currency` | string | 余额币种，目前固定为 `USD`。 |
| `account_balance_micros_usd` | integer | PAYG 有效余额与 GTM 余额之和。 |
| `available_balance_micros_usd` | integer | 当前认证 API Key 可用的 PAYG 余额与 GTM 余额之和。 |
| `go_to_market_balance_micros_usd` | integer | GTM 总余额，与 `gtm.balance_micros_usd` 相同。 |
| `gtm` | object | GTM 余额明细，包括试用余额和订阅余额。 |
| `media_promo` | object | 限定提供商的媒体赠额，单独报告，不计入通用可用余额。 |
| `api_key` | object | 当前 API Key 的剩余额度和已使用额度。 |
| `as_of` | string | 该余额快照对应的 UTC 时间。 |

### GTM 字段

| 字段 | 类型 | 说明 |
| - | - | - |
| `active` | boolean | 是否有可用 GTM 资金或存在 GTM 订阅周期。 |
| `balance_micros_usd` | integer | GTM 总余额。 |
| `trial_balance_micros_usd` | integer | 未过期的 GTM 试用余额。 |
| `trial_expires_at` | string | GTM 试用余额的 UTC 到期时间；没有适用的试用到期时间时省略。 |
| `subscription_balance_micros_usd` | integer | GTM 订阅余额。 |
| `subscription_addon_balance_micros_usd` | integer | 加购余额总额，包含可用和冻结部分。 |
| `subscription_addon_available_micros_usd` | integer | 有效付费订阅周期内可使用的加购余额，计入 GTM 余额。 |
| `subscription_addon_frozen_micros_usd` | integer | 没有有效付费订阅周期时冻结的加购余额，不计入可用余额或 GTM 总额。 |
| `expires_at` | string | 当前 GTM 订阅周期的 UTC 到期时间；没有适用订阅周期时省略。 |

### 媒体赠额字段

`media_promo.balance_micros_usd` 仅能用于赠额批次指定的提供商，不计入通用账户余额及可用余额。`next_expires_at` 是最近一批赠额的到期时间，无适用时间时省略。媒体赠额为正，不代表任意 API 请求都可由其支付。

### 余额计算

PAYG 余额是有效 cash、Trial、promo 和 credit 余额之和。已经过期的 Trial 余额
不会计入。

`go_to_market_balance_micros_usd` 是 GTM 余额。该金额也会作为
`gtm.balance_micros_usd` 返回，`gtm` 对象还包含试用、订阅及可用加购余额明细。冻结的加购余额单独展示，不计入这一总额。

`account_balance_micros_usd` 是 PAYG 余额与
`go_to_market_balance_micros_usd` 之和。

对于有限额度 API Key，`available_balance_micros_usd` 等于 PAYG 余额与
`api_key.remaining_micros_usd` 中的较小值，再加上 GTM 余额。对于无限额度 API
Key，它等于 PAYG 余额加 GTM 余额。当 PAYG 余额或 Key 余额为负数时，Key 可用
的 PAYG 部分最低为零。

已过期的 Trial 金额不会计入有效余额。

## 错误

* `401 Unauthorized` — API Key 缺失、无效、已撤销或已过期。
* `403 Forbidden` — 用户已被禁用，或当前请求 IP 不在 Key 的允许列表内。
* `500 Internal Server Error` — 无法读取余额快照。

该接口的错误响应使用字符串类型的 `error` 字段：

```json theme={null}
{
  "error": "invalid api key"
}
```

有关状态码和重试的一般说明，请参阅[错误代码](https://aisa.one/docs/zh/api-reference/errors.md)；有关请求
限制，请参阅[速率限制](https://aisa.one/docs/zh/api-reference/rate-limits.md)。

## 请求规范

* **方法与路径:** GET /credits/balance
* **请求 URL 模板:** `https://api.aisa.one/v1/credits/balance`

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

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

```json theme={null}
{
  "operationId": "accountCreditsBalance",
  "method": "GET",
  "path": "/credits/balance",
  "servers": [
    {
      "url": "https://api.aisa.one/v1"
    }
  ],
  "parameters": [],
  "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 /credits/balance
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:
  /credits/balance:
    get:
      summary: Account Balance
      description: >-
        Return the current account credit balance. Accepts either an API key or
        an OAuth access token. No parameters.
      operationId: accountCreditsBalance
      parameters: []
      responses:
        '200':
          content:
            application/json:
              example:
                account_balance_micros_usd: 3250000
                api_key:
                  remaining_micros_usd: 1000000
                  unlimited: false
                  used_micros_usd: 300000
                as_of: '2026-08-27T10:36:29Z'
                available_balance_micros_usd: 1750000
                currency: USD
                go_to_market_balance_micros_usd: 750000
                gtm:
                  active: true
                  balance_micros_usd: 750000
                  expires_at: '2026-10-31T12:00:00Z'
                  subscription_balance_micros_usd: 500000
                  trial_balance_micros_usd: 250000
                  trial_expires_at: '2026-09-30T12:00:00Z'
              schema:
                properties:
                  account_balance_micros_usd:
                    description: Effective PAYG balance plus the GTM balance, in micro-USD.
                    format: int64
                    type: integer
                  api_key:
                    description: >-
                      Per-key limit view for the calling API key (absent for
                      OAuth callers).
                    properties:
                      remaining_micros_usd:
                        description: >-
                          Remaining per-key allowance in micro-USD (0 when
                          unlimited).
                        format: int64
                        type: integer
                      unlimited:
                        description: True when the key has no per-key spend cap.
                        type: boolean
                      used_micros_usd:
                        description: Amount spent by this key in micro-USD.
                        format: int64
                        type: integer
                    type: object
                  as_of:
                    description: Snapshot timestamp (RFC 3339, UTC).
                    format: date-time
                    type: string
                  available_balance_micros_usd:
                    description: >-
                      PAYG balance available to the authenticated API key plus
                      the GTM balance, in micro-USD. For a limited key this is
                      min(PAYG balance, key remaining balance) + GTM balance.
                    format: int64
                    type: integer
                  currency:
                    description: ISO currency code (always USD).
                    type: string
                  go_to_market_balance_micros_usd:
                    description: >-
                      Total GTM balance in micro-USD. Equal to
                      gtm.balance_micros_usd.
                    format: int64
                    type: integer
                  gtm:
                    description: >-
                      GTM balance details. The total includes GTM trial and
                      subscription balances.
                    properties:
                      active:
                        description: >-
                          True when GTM funds are available or a GTM
                          subscription period exists.
                        type: boolean
                      balance_micros_usd:
                        description: Total GTM balance in micro-USD.
                        format: int64
                        type: integer
                      expires_at:
                        description: >-
                          Current GTM subscription period expiry (RFC 3339,
                          UTC). Omitted when no period applies.
                        format: date-time
                        type: string
                      subscription_balance_micros_usd:
                        description: GTM subscription balance in micro-USD.
                        format: int64
                        type: integer
                      trial_balance_micros_usd:
                        description: Unexpired GTM trial balance in micro-USD.
                        format: int64
                        type: integer
                      trial_expires_at:
                        description: >-
                          GTM trial balance expiry (RFC 3339, UTC). Omitted when
                          no trial expiry applies.
                        format: date-time
                        type: string
                    type: object
                type: object
          description: Current balance snapshot.
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.