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

# 查询账单

分页查询指定 API KEY 对应的账单列表。

> [!NOTE]
>
> 注意：调用此接口需要通过[API KEY](https://geekai.co/user/api_keys) 进行认证。
>
> 要获取总页数和总记录数，请通过 `/transactions/metadata` 接口返回值中的 `total` 和 `pages` 字段获取，你还可以通过 `page_size` 设置每页记录数来调节总页数。


## OpenAPI

````yaml openapi.yaml GET /transactions
openapi: 3.1.0
info:
  title: 极客智坊 API文档
  description: 极客智坊 API 消息接口规范文档
  version: 1.0.0
servers:
  - url: https://geekai.co/api/v1
    description: 国内代理入口
  - url: https://geekai.dev/api/v1
    description: 海外代理入口
security:
  - bearerAuth: []
  - apiKeyAuth: []
paths:
  /transactions:
    get:
      tags:
        - API_TRANSACTION
      summary: 查询API账单
      description: 分页查询指定 API KEY 对应的账单列表
      operationId: getApiTransactions
      parameters:
        - $ref: '#/components/parameters/PageParam'
        - $ref: '#/components/parameters/PageSizeParam'
      responses:
        '200':
          description: 成功响应
          content:
            application/json:
              schema:
                type: object
                properties:
                  total:
                    type: integer
                    description: 总记录数
                  page:
                    type: integer
                    description: 当前页码
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        request_id:
                          type: string
                          description: 请求ID
                        model:
                          type: string
                          description: 使用的模型名称
                        amount:
                          type: number
                          description: 本次请求消耗金币值，100金币=1元
                        discount:
                          type: number
                          description: 折扣率，消耗金币=官方价*折扣率
                        channel:
                          type: string
                          description: 代理线路渠道类型枚举值，如低价、均衡、高可用等
                        tokens:
                          type: number
                          description: 使用的总Token数量
                        input_tokens:
                          type: number
                          description: 输入Token数量
                        output_tokens:
                          type: number
                          description: 输出Token数量
                        cache_hit_tokens:
                          type: number
                          description: 缓存命中Token数量
                        cache_write_tokens:
                          type: number
                          description: 缓存写入Token数量
                        billed_units:
                          type: number
                          description: 计费单位数量，适用于按次收费模型，如搜索、画图、视频生成等
                        times:
                          type: number
                          description: 计费倍率，适用于不同分辨率、质量的画图、视频生成等模型，默认为1
                        event:
                          type: string
                          description: 事件类型，表示此次对话的具体操作类型
                        stream:
                          type: boolean
                          description: 是否为流式响应
                        reply_time:
                          type: number
                          description: 响应时间（单位：秒）
                        created_at:
                          type: string
                          format: date-time
                          description: 账单创建时间
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/StandardError'
components:
  parameters:
    PageParam:
      name: page
      in: query
      required: false
      schema:
        type: integer
        minimum: 1
      description: 页码，默认为1
      example: 1
    PageSizeParam:
      name: page_size
      in: query
      required: false
      schema:
        type: integer
        minimum: 1
        maximum: 100
      description: 每页条目数，默认为10
      example: 10
  responses:
    Unauthorized:
      description: 未授权
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                example: unauthorized
              message:
                type: string
                example: Invalid API key or token
    StandardError:
      description: 标准错误响应
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: 错误代码
          example: invalid_request
        message:
          type: string
          description: 错误信息描述
          example: 请求参数不合法
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: API认证token
    apiKeyAuth:
      type: apiKey
      in: header
      name: GeekAI-API-Key
      description: API密钥认证

````

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