{
  "openapi": "3.1.0",
  "info": {
    "title": "文本 API 文档",
    "version": "1.2.0",
    "description": "本站公开接口。GET /v1/models 仅返回模型广场当前展示且当前 API Key 有权限调用的公开 ID。视频、文本、图片按分类独立说明。使用本站域名和本站 Key。"
  },
  "servers": [
    {
      "url": "https://www.v6k.top",
      "description": "本站域名，不含 /v1；下列 paths 已包含 /v1。自部署时替换域名。"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Text",
      "description": "聊天和 Responses"
    },
    {
      "name": "Models",
      "description": "模型广场公开模型 ID"
    }
  ],
  "paths": {
    "/v1/models": {
      "get": {
        "tags": ["Models"],
        "operationId": "listModels",
        "summary": "查询当前令牌可用模型",
        "responses": {
          "200": {
            "description": "模型列表",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "object": {
                            "type": "string"
                          },
                          "owned_by": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "参数错误、配置问题、额度不足或任务未完成",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "密钥无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "请求错误，检查HTTP状态与错误体",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "无权限",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "任务或路由不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "请求错误，检查HTTP状态与错误体",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "请求限流",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "请求错误，检查HTTP状态与错误体",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "服务暂不可用",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "服务繁忙",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "请求超时",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/chat/completions": {
      "post": {
        "summary": "聊天接口",
        "description": "使用对应类型的本站公开模型。结果在当前响应返回，不使用视频任务轮询。 策影文本按输入、输出及可选缓存读取 Token 定价，每百万 Token 展示价格。缓存单独定价时从输入总量扣除缓存命中量，避免重复计费。未配置缓存定价时全部输入按输入单价结算。策影仅通过此聊天入口接入文本；输出上限未填写时默认 4096。stream=true 为上游完成后的 SSE 兼容响应。",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["model", "messages"],
                "properties": {
                  "model": {
                    "type": "string"
                  },
                  "messages": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "object",
                      "required": ["role", "content"],
                      "properties": {
                        "role": {
                          "type": "string"
                        },
                        "content": {
                          "oneOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "array",
                              "items": {
                                "type": "object"
                              }
                            }
                          ]
                        }
                      }
                    }
                  },
                  "stream": {
                    "type": "boolean"
                  },
                  "max_tokens": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 1073741823,
                    "description": "最大输出 Token 数；与 max_completion_tokens 按模型支持情况选择，策影在两者都省略时默认 4096"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "对应接口结果；检查响应字段"
          },
          "400": {
            "description": "参数错误"
          },
          "401": {
            "description": "鉴权失败"
          },
          "403": {
            "description": "权限不足或额度不足"
          },
          "502": {
            "description": "处理失败"
          }
        },
        "tags": ["Text"]
      }
    },
    "/v1/responses": {
      "post": {
        "tags": ["Text"],
        "summary": "文本 Responses（需模型支持）",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["model", "input"],
                "properties": {
                  "model": {
                    "type": "string",
                    "description": "从模型广场或 GET /v1/models 原样复制公开模型 ID"
                  },
                  "input": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "object"
                        }
                      }
                    ]
                  },
                  "stream": {
                    "type": "boolean",
                    "default": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "返回 response 对象，结果位于 output；stream=true 返回 SSE"
          },
          "400": {
            "description": "参数错误"
          },
          "401": {
            "description": "Key 无效"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "填写本站签发的 API 令牌"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string"
              },
              "type": {
                "type": "string"
              },
              "code": {
                "type": ["string", "null"]
              }
            }
          },
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "data": {
            "description": "兼容旧版任务错误响应的可选数据"
          }
        },
        "description": "本站统一错误，不包含服务商地址、服务商模型 ID 或密钥"
      }
    }
  }
}
