账户会话

GET /core/v1/requests

本人请求分页

身份要求

账户会话. 会话/管理写操作不在公共 Playground 执行。

接口

curl --request GET 'https://api.oneaster.ai/core/v1/requests' \
  --header 'Authorization: Bearer '"$ONEASTER_SESSION_TOKEN"

参数

- page (query, 可选): {"type":"integer","minimum":1,"maximum":1000000,"default":1}

- size (query, 可选): {"type":"integer","minimum":1,"maximum":100,"default":20}

- from (query, 可选): {"type":"string","format":"date-time"} 包含起点;RFC3339 UTC,最多微秒精度。

- to (query, 可选): {"type":"string","format":"date-time"} 不包含终点;RFC3339 UTC,最多微秒精度。

- model (query, 可选): {"type":"string","minLength":1,"maxLength":200}

- key_id (query, 可选): {"type":"string","pattern":"^[0-9]+$"}

- state (query, 可选): {"enum":["reserved","forwarding","completed","unknown","rejected"]}

- billing_state (query, 可选): {"enum":["reserved","settled","released"]}

- stream (query, 可选): {"type":"boolean"}

响应

200

本人请求分页

{
  "application/json": {
    "schema": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "success": {
          "const": true
        },
        "data": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "items": {
              "type": "array",
              "items": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "model": {
                    "type": "string"
                  },
                  "state": {
                    "enum": [
                      "reserved",
                      "forwarding",
                      "completed",
                      "unknown",
                      "rejected"
                    ]
                  },
                  "billing_state": {
                    "enum": [
                      "reserved",
                      "settled",
                      "released"
                    ]
                  },
                  "reservation_micro": {
                    "type": "string",
                    "pattern": "^[0-9]+$",
                    "description": "整数账务单位;1 积分 = 10000 单位,1 USD = 100 积分。前端用 BigInt。"
                  },
                  "charge_micro": {
                    "anyOf": [
                      {
                        "type": "string",
                        "pattern": "^[0-9]+$",
                        "description": "整数账务单位;1 积分 = 10000 单位,1 USD = 100 积分。前端用 BigInt。"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "prompt_tokens": {
                    "anyOf": [
                      {
                        "type": "string",
                        "pattern": "^[0-9]+$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "completion_tokens": {
                    "anyOf": [
                      {
                        "type": "string",
                        "pattern": "^[0-9]+$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "cache_read_tokens": {
                    "anyOf": [
                      {
                        "type": "string",
                        "pattern": "^[0-9]+$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "cache_creation_tokens": {
                    "anyOf": [
                      {
                        "type": "string",
                        "pattern": "^[0-9]+$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "price_version": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "metering": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "mode": {
                        "enum": [
                          "model_limit",
                          "utf8_bytes",
                          "cl100k_base",
                          "o200k_base"
                        ]
                      },
                      "margin_bps": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 10000
                      },
                      "extra_tokens": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 65536
                      }
                    },
                    "required": [
                      "mode",
                      "margin_bps",
                      "extra_tokens"
                    ]
                  },
                  "estimated_input_tokens": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "reserved_input_tokens": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "byte_fallback": {
                    "type": "boolean"
                  },
                  "input_price_per_million": {
                    "type": "string",
                    "pattern": "^[0-9]+$",
                    "description": "整数账务单位;1 积分 = 10000 单位,1 USD = 100 积分。前端用 BigInt。"
                  },
                  "output_price_per_million": {
                    "type": "string",
                    "pattern": "^[0-9]+$",
                    "description": "整数账务单位;1 积分 = 10000 单位,1 USD = 100 积分。前端用 BigInt。"
                  },
                  "first_token_ms": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "duration_ms": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "error_code": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "stream": {
                    "type": "boolean"
                  },
                  "created_at": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "updated_at": {
                    "type": "string",
                    "format": "date-time"
                  }
                },
                "required": [
                  "id",
                  "model",
                  "state",
                  "billing_state",
                  "reservation_micro",
                  "charge_micro",
                  "prompt_tokens",
                  "completion_tokens",
                  "cache_read_tokens",
                  "cache_creation_tokens",
                  "price_version",
                  "metering",
                  "estimated_input_tokens",
                  "reserved_input_tokens",
                  "byte_fallback",
                  "input_price_per_million",
                  "output_price_per_million",
                  "first_token_ms",
                  "duration_ms",
                  "error_code",
                  "stream",
                  "created_at",
                  "updated_at"
                ]
              }
            },
            "total": {
              "type": "string",
              "pattern": "^[0-9]+$"
            },
            "page": {
              "type": "integer",
              "minimum": 0
            },
            "size": {
              "type": "integer",
              "minimum": 0
            }
          },
          "required": [
            "items",
            "total",
            "page",
            "size"
          ]
        }
      },
      "required": [
        "success",
        "data"
      ]
    }
  }
}

default

错误代码见 core-api.md;供应商/数据库错误已隐藏。

{
  "application/json": {
    "schema": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "success": {
          "const": false
        },
        "error": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "code": {
              "type": "string"
            },
            "message": {
              "type": "string"
            },
            "type": {
              "const": "oneaster_error"
            }
          },
          "required": [
            "code",
            "message",
            "type"
          ]
        },
        "data": {
          "type": "null"
        }
      },
      "required": [
        "success",
        "error",
        "data"
      ]
    }
  }
}