管理员

GET /core/v1/admin/channel-health

当前渠道及凭据版本的文本发送健康统计;只读且不影响路由

只读当前渠道配置/凭据版本和指定窗口的文本发送证据,不生成、不改变路由;cooldown_until 只是提示,不代表自动熔断。没有测量时保留 null,不当作零延迟或零成功率。

身份要求

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

接口

curl --request GET 'https://api.oneaster.ai/core/v1/admin/channel-health' \
  --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}

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

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

- window_minutes (query, 可选): {"type":"integer","minimum":1,"maximum":1440,"default":60}

响应

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": {
                  "channel_id": {
                    "type": "string",
                    "pattern": "^[0-9]+$"
                  },
                  "channel_name": {
                    "type": "string"
                  },
                  "channel_type": {
                    "type": "string"
                  },
                  "channel_version": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "credential_version": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "model": {
                    "type": "string"
                  },
                  "channel_enabled": {
                    "type": "boolean"
                  },
                  "model_enabled": {
                    "type": "boolean"
                  },
                  "sample_count": {
                    "type": "string",
                    "pattern": "^[0-9]+$"
                  },
                  "success_count": {
                    "type": "string",
                    "pattern": "^[0-9]+$"
                  },
                  "failure_count": {
                    "type": "string",
                    "pattern": "^[0-9]+$"
                  },
                  "in_flight_count": {
                    "type": "string",
                    "pattern": "^[0-9]+$"
                  },
                  "test_count": {
                    "type": "string",
                    "pattern": "^[0-9]+$"
                  },
                  "generation_count": {
                    "type": "string",
                    "pattern": "^[0-9]+$"
                  },
                  "legacy_count": {
                    "type": "string",
                    "pattern": "^[0-9]+$"
                  },
                  "first_token_sample_count": {
                    "type": "string",
                    "pattern": "^[0-9]+$"
                  },
                  "consecutive_failures": {
                    "type": "string",
                    "pattern": "^[0-9]+$"
                  },
                  "success_rate": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "avg_duration_ms": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "p95_duration_ms": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "avg_first_token_ms": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "avg_headers_ms": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "latest_attempt_at": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "latest_success_at": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "latest_failure_at": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "latest_diagnostic": {
                    "anyOf": [
                      {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "phase": {
                            "enum": [
                              "connecting",
                              "waiting_headers",
                              "upstream_response",
                              "reading_response",
                              "streaming",
                              "settlement"
                            ]
                          },
                          "category": {
                            "enum": [
                              "authentication",
                              "rate_limit",
                              "provider_internal",
                              "model_unavailable",
                              "invalid_request",
                              "provider_unavailable",
                              "http_error",
                              "timeout",
                              "transport_error",
                              "client_cancelled",
                              "invalid_response",
                              "invalid_usage",
                              "stream_interrupted",
                              "settlement_failed",
                              "process_interrupted"
                            ]
                          },
                          "message": {
                            "type": "string",
                            "maxLength": 200
                          },
                          "provider_error_type": {
                            "anyOf": [
                              {
                                "type": "string",
                                "maxLength": 64
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "retry_after_seconds": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 86400
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "phase",
                          "category",
                          "message",
                          "provider_error_type",
                          "retry_after_seconds"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "cooldown_until": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "status": {
                    "enum": [
                      "disabled",
                      "no_data",
                      "healthy",
                      "degraded",
                      "failing"
                    ]
                  }
                },
                "required": [
                  "channel_id",
                  "channel_name",
                  "channel_type",
                  "channel_version",
                  "credential_version",
                  "model",
                  "channel_enabled",
                  "model_enabled",
                  "sample_count",
                  "success_count",
                  "failure_count",
                  "in_flight_count",
                  "test_count",
                  "generation_count",
                  "legacy_count",
                  "first_token_sample_count",
                  "consecutive_failures",
                  "success_rate",
                  "avg_duration_ms",
                  "p95_duration_ms",
                  "avg_first_token_ms",
                  "avg_headers_ms",
                  "latest_attempt_at",
                  "latest_success_at",
                  "latest_failure_at",
                  "latest_diagnostic",
                  "cooldown_until",
                  "status"
                ]
              }
            },
            "total": {
              "type": "string",
              "pattern": "^[0-9]+$"
            },
            "page": {
              "type": "integer",
              "minimum": 0
            },
            "size": {
              "type": "integer",
              "minimum": 0
            },
            "window_minutes": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1440
            },
            "sample_time": {
              "type": "string",
              "format": "date-time"
            }
          },
          "required": [
            "items",
            "total",
            "page",
            "size",
            "window_minutes",
            "sample_time"
          ]
        }
      },
      "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"
      ]
    }
  }
}