Skip to content
Request
Response

日志管理

日志接口用于查询和管理 API 调用日志。

接口地址

GET https://ai-tokenhub.com/v1/admin/logs
GET https://ai-tokenhub.com/v1/admin/logs/{id}

查询参数

参数类型说明
start_timestring开始时间 (ISO 8601)
end_timestring结束时间 (ISO 8601)
api_key_idstringAPI Key ID
modelstring模型名称
statusstring状态 (success/error)
pageinteger页码
page_sizeinteger每页数量 (最大100)

获取日志列表

bash
curl "https://ai-tokenhub.com/v1/admin/logs?page=1&page_size=50" \
  -H "Authorization: Bearer YOUR_API_KEY"

响应示例

json
{
  "object": "list",
  "data": [
    {
      "id": "log_xxx",
      "api_key_id": "key_xxx",
      "api_key_name": "Production Key",
      "model": "gpt-4o",
      "request_tokens": 100,
      "response_tokens": 50,
      "status": "success",
      "latency": 1200,
      "ip": "203.0.113.1",
      "created_at": "2024-01-01T12:00:00Z"
    }
  ],
  "meta": {
    "total": 1000,
    "page": 1,
    "page_size": 50,
    "total_pages": 20
  }
}

获取单条日志详情

bash
curl https://ai-tokenhub.com/v1/admin/logs/log_xxx \
  -H "Authorization: Bearer YOUR_API_KEY"

日志详情

json
{
  "id": "log_xxx",
  "api_key_id": "key_xxx",
  "model": "gpt-4o",
  "request": {
    "messages": [...],
    "temperature": 0.7,
    "max_tokens": 1000
  },
  "response": {
    "choices": [...],
    "usage": {
      "prompt_tokens": 100,
      "completion_tokens": 50,
      "total_tokens": 150
    }
  },
  "status": "success",
  "error_code": null,
  "error_message": null,
  "latency": 1200,
  "ip": "203.0.113.1",
  "user_agent": "Mozilla/5.0...",
  "created_at": "2024-01-01T12:00:00Z"
}

字段说明

字段类型说明
idstring日志唯一标识
api_key_idstring使用的 API Key ID
api_key_namestringAPI Key 名称
modelstring调用的模型
request_tokensinteger请求 token 数
response_tokensinteger响应 token 数
statusstring调用状态
latencyinteger延迟 (毫秒)
ipstring请求来源 IP