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

> ## Agent Instructions
> Public hosts only: console https://omnimux.ai/dashboard · API https://api.omnimux.ai · docs https://docs.omnimux.ai.
> Gateway auth is Authorization: Bearer sk-… on https://api.omnimux.ai/v1 (OpenAI-compatible Chat Completions and related paths).
> Discover pages from /llms.txt; full site dump /llms-full.txt; product skill /skill.md; docs search MCP /mcp. Prefer .md page URLs for Markdown.
> Default docs locale is en; zh mirrors the same relative paths. Do not invent model ids not present on live pricing or the complete API pages.

# 导出本人用量日志

> 导出已认证用户本人可见日志；逐行 JSON 末尾须有成功结果。

* 这是账户管理的用户接口，使用用户访问令牌或网站登录会话；`sk-` 网关生成密钥不适用。个人访问令牌必须具备 `usage:read` 权限，详见[安全与密钥](https://docs.omnimux.ai/zh/faqs/security.md)。
* 只导出当前已认证账户本人的可见日志，采用与本人日志列表相同的可见范围。传入其他用户名或渠道条件不会获得他人记录。
* 普通用户导出由管理员设置控制。每账户同一时间只允许一个导出；繁忙、超范围、关闭导出等业务拒绝可能仍返回 **HTTP 200**，必须读取 `success`。

## 如何确认导出完整？

成功响应类型为 `application/x-ndjson`，每行一个日志对象，**最后一行**是结果对象，例如 `{"success":true,"message":"","data":{"count":1}}`。最后一行的数量不包含结果对象本身。没有匹配日志时也会有数量为 0 的成功结果。

只有读到最后一行 `success: true`，且记录数量与 `data.count` 一致，才能确认完整。中途失败可能在流末返回 `success: false`；断网、取消或缺少结果末行时，已收到的数据只能视为部分结果。不能因收到 200 或若干条记录就认定完成。

## 时间跨度与记录字段

最大跨度由系统设置决定，默认 365 天；负数时间戳、起点晚于有效终点、不合法的筛选模式和超出跨度都会在输出流之前拒绝；更长范围请拆成允许的时间段。该限制不是日志保存期限，也不会自动删除记录。省略起点时，从有效终点向前取最大跨度；省略终点时使用当前时间。

导出记录采用本人列表的显示顺序。`id` 为本次导出的显示序号，不是数据库记录编号，也不能用来跨次增量同步。`quota` 是内部原始额度：`quota ÷ 500000 = USD`，`1 USD = 10 积分`；不要直接把它叫作积分。内部管理信息仍按本人列表规则隐藏。

此读取接口不发起生成，也不因导出本身扣取生成费用。管理员跨账户导出不属于本页合同。

```json 200 NDJSON theme={null}
{"id":1,"user_id":42,"created_at":1791979200,"type":2,"content":"","username":"example-user","token_name":"example-key","model_name":"","quota":500,"prompt_tokens":10,"completion_tokens":5,"use_time":1,"is_stream":false,"channel":0,"channel_name":"","token_id":1,"group":"","ip":"","request_id":"example-request-id","other":"{}"}
{"success":true,"message":"","data":{"count":1}}
```

```json 401 theme={null}
{
  "success": false,
  "code": "AUTH_UNAUTHORIZED",
  "message": "Invalid user credential"
}
```

```json 403 theme={null}
{
  "success": false,
  "code": "ACCESS_TOKEN_SCOPE_DENIED",
  "message": "Permission denied"
}
```

```json 500 theme={null}
{
  "success": false,
  "code": "AUTH_INTERNAL_ERROR",
  "message": "Internal authentication error"
}
```


## OpenAPI

````yaml openapi/ops/account/zh/usage-log-export.json GET /api/log/self/export
openapi: 3.1.0
info:
  title: 导出本人用量日志
  version: 1.0.0
  description: 导出已认证用户本人可见日志；逐行 JSON 末尾须有成功结果。
servers:
  - url: https://omnimux.ai
security: []
paths:
  /api/log/self/export:
    get:
      summary: 导出本人用量日志
      description: 导出已认证用户本人可见日志；逐行 JSON 末尾须有成功结果。
      operationId: exportOwnUsageLogs
      parameters:
        - name: type
          in: query
          required: false
          description: 日志类型，0 表示所有类型。
          schema:
            type: integer
        - name: start_timestamp
          in: query
          required: false
          description: 起点，Unix 秒。省略时按有效终点向前取系统允许的最大跨度。
          schema:
            type: integer
            minimum: 0
        - name: end_timestamp
          in: query
          required: false
          description: 终点，Unix 秒。省略时使用当前时间；跨度检查不会把未来时间算在当前时间之后。
          schema:
            type: integer
            minimum: 0
        - name: model_name
          in: query
          required: false
          description: 模型名称筛选。
          schema:
            type: string
        - name: token_name
          in: query
          required: false
          description: 网关密钥名称筛选。
          schema:
            type: string
        - name: group
          in: query
          required: false
          description: 请求分组筛选。
          schema:
            type: string
        - name: request_id
          in: query
          required: false
          description: 网关请求编号筛选。
          schema:
            type: string
        - name: upstream_request_id
          in: query
          required: false
          description: 上游请求编号筛选。
          schema:
            type: string
      responses:
        '200':
          description: 导出流，或开始输出前的业务拒绝。收到 200 本身不代表完成。
          headers:
            Cache-Control:
              schema:
                type: string
              example: no-store
          content:
            application/x-ndjson:
              schema:
                type: string
                description: >-
                  每行一个日志对象；最后一行是 success/message/data.count 结果。中途失败可输出
                  success:false；缺失末行也不完整。
              example: >
                {"id":1,"user_id":42,"created_at":1791979200,"type":2,"content":"","username":"example-user","token_name":"example-key","model_name":"","quota":500,"prompt_tokens":10,"completion_tokens":5,"use_time":1,"is_stream":false,"channel":0,"channel_name":"","token_id":1,"group":"","ip":"","request_id":"example-request-id","other":"{}"}

                {"success":true,"message":"","data":{"count":1}}
            application/json:
              schema:
                $ref: '#/components/schemas/ExportResult'
              example:
                success: false
                message: Another log export is running. Try again after it finishes.
        '401':
          description: 身份凭证失效或缺失。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthError'
              example:
                success: false
                code: AUTH_UNAUTHORIZED
                message: Invalid user credential
        '403':
          description: 凭证无对应权限。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthError'
              example:
                success: false
                code: ACCESS_TOKEN_SCOPE_DENIED
                message: Permission denied
        '500':
          description: 身份认证内部错误。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthError'
              example:
                success: false
                code: AUTH_INTERNAL_ERROR
                message: Internal authentication error
      security:
        - UserAccessToken: []
components:
  schemas:
    ExportResult:
      type: object
      required:
        - success
        - message
      properties:
        success:
          type: boolean
        message:
          type: string
        message_key:
          type: string
          description: 本地化提示键，可能存在。
        message_params:
          type: object
          additionalProperties: true
        data:
          type: object
          properties:
            count:
              type: integer
              minimum: 0
    AuthError:
      type: object
      required:
        - success
        - message
      properties:
        success:
          type: boolean
          const: false
        code:
          type: string
        message:
          type: string
  securitySchemes:
    UserAccessToken:
      type: http
      scheme: bearer
      bearerFormat: user access token
      description: 具有 usage:read 权限的用户接口访问令牌，不是 sk- 网关生成密钥。也可使用网站登录会话。

````

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