管理员

POST /core/v1/admin/channels

创建加密渠道;多凭据、幂等

身份要求

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

接口

curl --request POST 'https://api.oneaster.ai/core/v1/admin/channels' \
  --header 'Authorization: Bearer '"$ONEASTER_SESSION_TOKEN" \
  --header 'Idempotency-Key: '"$ONEASTER_INTENT" \
  --header 'Content-Type: application/json' \
  --data "$REQUEST_BODY_JSON"

参数

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

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

- Idempotency-Key (header, 必填): {"type":"string","minLength":1,"maxLength":100}

请求 JSON Schema

{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "config": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "base_url": {
          "type": "string"
        },
        "models": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "model": {
                "type": "string"
              },
              "upstream_model": {
                "type": "string"
              }
            },
            "required": [
              "model",
              "upstream_model"
            ]
          }
        },
        "groups": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "priority": {
          "type": "integer",
          "minimum": 0
        },
        "weight": {
          "type": "integer",
          "minimum": 0
        },
        "tag": {
          "type": "string"
        },
        "notes": {
          "type": "string"
        },
        "auto_disable": {
          "type": "boolean"
        },
        "options": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        "headers": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        "parameters": {
          "type": "object",
          "additionalProperties": {
            "type": "number"
          }
        }
      },
      "required": [
        "name",
        "type",
        "base_url",
        "models",
        "groups",
        "priority",
        "weight",
        "tag",
        "notes",
        "auto_disable",
        "options",
        "headers",
        "parameters"
      ]
    },
    "enabled": {
      "type": "boolean"
    },
    "api_keys": {
      "type": "array",
      "minItems": 1,
      "maxItems": 50,
      "items": {
        "type": "string",
        "minLength": 8,
        "maxLength": 8192,
        "writeOnly": true
      }
    },
    "reference": {
      "type": "string"
    }
  },
  "required": [
    "config",
    "enabled",
    "api_keys",
    "reference"
  ]
}

响应

200

返回原幂等操作结果

{
  "application/json": {
    "schema": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "success": {
          "const": true
        },
        "data": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "ids": {
              "type": "array",
              "items": {
                "type": "string",
                "pattern": "^[0-9]+$"
              }
            },
            "version": {
              "type": "integer",
              "minimum": 0
            },
            "reused": {
              "type": "boolean"
            }
          },
          "required": [
            "ids",
            "version",
            "reused"
          ]
        }
      },
      "required": [
        "success",
        "data"
      ]
    }
  }
}

201

创建加密渠道;多凭据、幂等

{
  "application/json": {
    "schema": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "success": {
          "const": true
        },
        "data": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "ids": {
              "type": "array",
              "items": {
                "type": "string",
                "pattern": "^[0-9]+$"
              }
            },
            "version": {
              "type": "integer",
              "minimum": 0
            },
            "reused": {
              "type": "boolean"
            }
          },
          "required": [
            "ids",
            "version",
            "reused"
          ]
        }
      },
      "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"
      ]
    }
  }
}