{
  "openapi": "3.1.0",
  "info": {
    "title": "302API 公开接口参考",
    "version": "2026-11-24",
    "description": "本站实现范围及常用字段子集，不代表全部厂商能力。价格和能力以控制台及接入文档为准。 图片模型按文本、图片、缓存分项计费；思考输出不重复相加。计费依据实际 usage，缺失或矛盾明细待核对。 Both https://api.xinchengapi.com and https://api.xinchengapi.com/v1 are permanently supported. Native /v1/messages remains available."
  },
  "servers": [
    {
      "url": "https://api.xinchengapi.com",
      "description": "Unified address; permanently supported"
    },
    {
      "url": "https://api.xinchengapi.com/v1",
      "description": "Standard OpenAI-compatible address; permanently supported"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/models": {
      "get": {
        "operationId": "listModels",
        "summary": "查询可见模型；仍执行鉴权额度限流检查",
        "responses": {
          "200": {
            "description": "成功；请检查内容与usage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelsResponse"
                }
              }
            },
            "headers": {
              "X-RateLimit-Limit-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。账户所有Key共享的当前RPM上限"
              },
              "X-RateLimit-Remaining-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。当前分钟窗口剩余请求数"
              },
              "X-RateLimit-Reset-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。当前分钟窗口重置倒计时，例如12s"
              }
            }
          },
          "400": {
            "description": "参数或接口不匹配",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "密钥无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "余额或Key额度不足",
            "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"
                }
              }
            }
          },
          "405": {
            "description": "方法错误",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "图片幂等键冲突、处理中或结果无法取回",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "限流或当日额度耗尽；按error.code区分",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "仅频率限制可能提供，单位秒；不保证所有429都有。",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Limit-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。账户所有Key共享的当前RPM上限"
              },
              "X-RateLimit-Remaining-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。当前分钟窗口剩余请求数"
              },
              "X-RateLimit-Reset-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。当前分钟窗口重置倒计时，例如12s"
              }
            }
          },
          "502": {
            "description": "结果异常或图片待核对；不自动重试",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "服务未就绪",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "其他错误；代理或网络错误不保证JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/chat/completions": {
      "post": {
        "operationId": "chat_completions",
        "summary": "chat/completions",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "成功；请检查内容与usage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatResponse"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "Chat Completions SSE 事件流。Gemini 生图如有文字会先返回，含图片的事件在流末尾交付。"
                }
              }
            },
            "headers": {
              "X-RateLimit-Limit-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。账户所有Key共享的当前RPM上限"
              },
              "X-RateLimit-Remaining-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。当前分钟窗口剩余请求数"
              },
              "X-RateLimit-Reset-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。当前分钟窗口重置倒计时，例如12s"
              },
              "X-302API-Effective-Max-Tokens": {
                "schema": {
                  "type": "string"
                },
                "description": "网关对本次请求设定输出预算时的实际输出上限"
              },
              "X-302API-Replay-Available": {
                "schema": {
                  "type": "string"
                },
                "description": "带幂等键的首次非流式图片结果是否已暂存"
              },
              "X-302API-Idempotent-Replayed": {
                "schema": {
                  "type": "string"
                },
                "description": "true 表示返回了原图片结果"
              },
              "X-302API-Original-Request-ID": {
                "schema": {
                  "type": "string"
                },
                "description": "取回结果时的原图片请求编号"
              }
            }
          },
          "400": {
            "description": "参数或接口不匹配",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "密钥无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "余额或Key额度不足",
            "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"
                }
              }
            }
          },
          "405": {
            "description": "方法错误",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "图片幂等键冲突、处理中或结果无法取回",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "原任务仍在处理时的等待秒数"
              },
              "X-302API-Original-Request-ID": {
                "schema": {
                  "type": "string"
                },
                "description": "关联的原图片请求编号"
              }
            }
          },
          "429": {
            "description": "限流或当日额度耗尽；按error.code区分",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "仅频率限制可能提供，单位秒；不保证所有429都有。",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Limit-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。账户所有Key共享的当前RPM上限"
              },
              "X-RateLimit-Remaining-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。当前分钟窗口剩余请求数"
              },
              "X-RateLimit-Reset-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。当前分钟窗口重置倒计时，例如12s"
              }
            }
          },
          "502": {
            "description": "结果异常或图片待核对；不自动重试",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "服务未就绪",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "待核账单暂缓或预算计划临时不可用时的建议等待秒数"
              }
            }
          },
          "default": {
            "description": "其他错误；代理或网络错误不保证JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 128
            },
            "description": "图片任务去重，作用域为API Key；同一键与相同参数的成功图片结果可在15分钟内取回（加密暂存，单次最多16 MiB且受容量限制）；流式取回返回text/event-stream，仅包含最终图片和结束信息。普通文本不保证支持。"
          }
        ]
      }
    },
    "/responses": {
      "post": {
        "operationId": "responses",
        "summary": "responses",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResponsesRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "成功；请检查内容与usage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponsesResponse"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "Responses API 的 SSE 事件流，事件格式见 Responses 接口说明。"
                }
              }
            },
            "headers": {
              "X-RateLimit-Limit-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。账户所有Key共享的当前RPM上限"
              },
              "X-RateLimit-Remaining-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。当前分钟窗口剩余请求数"
              },
              "X-RateLimit-Reset-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。当前分钟窗口重置倒计时，例如12s"
              },
              "X-302API-Effective-Max-Tokens": {
                "schema": {
                  "type": "string"
                },
                "description": "网关对本次请求设定输出预算时的实际输出上限"
              }
            }
          },
          "400": {
            "description": "参数或接口不匹配",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "密钥无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "余额或Key额度不足",
            "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"
                }
              }
            }
          },
          "405": {
            "description": "方法错误",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "图片幂等键冲突、处理中或结果无法取回",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "限流或当日额度耗尽；按error.code区分",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "仅频率限制可能提供，单位秒；不保证所有429都有。",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Limit-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。账户所有Key共享的当前RPM上限"
              },
              "X-RateLimit-Remaining-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。当前分钟窗口剩余请求数"
              },
              "X-RateLimit-Reset-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。当前分钟窗口重置倒计时，例如12s"
              }
            }
          },
          "502": {
            "description": "结果异常或图片待核对；不自动重试",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "服务未就绪",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "待核账单暂缓或预算计划临时不可用时的建议等待秒数"
              }
            }
          },
          "default": {
            "description": "其他错误；代理或网络错误不保证JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "description": "创建文本响应，支持在售 GPT-6、GPT-6.1 和 GPT-6.2 系列文本模型。具体型号见接入文档的模型接口表。"
      }
    },
    "/images/generations": {
      "post": {
        "operationId": "images_generations",
        "summary": "images/generations",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImageRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "成功；请检查内容与usage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImageResponse"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "GPT 图片 SSE 事件流；可通过 partial_images 请求 0 到 3 张预览图，每次流式请求生成 1 张最终图片。"
                }
              }
            },
            "headers": {
              "X-302API-Request-ID": {
                "schema": {
                  "type": "string"
                },
                "description": "本站图片请求编号"
              },
              "X-RateLimit-Limit-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。账户所有Key共享的当前RPM上限"
              },
              "X-RateLimit-Remaining-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。当前分钟窗口剩余请求数"
              },
              "X-RateLimit-Reset-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。当前分钟窗口重置倒计时，例如12s"
              },
              "X-302API-Replay-Available": {
                "schema": {
                  "type": "string"
                },
                "description": "带幂等键的首次非流式图片结果是否已暂存"
              },
              "X-302API-Idempotent-Replayed": {
                "schema": {
                  "type": "string"
                },
                "description": "true 表示返回了原图片结果"
              },
              "X-302API-Original-Request-ID": {
                "schema": {
                  "type": "string"
                },
                "description": "取回结果时的原图片请求编号"
              }
            }
          },
          "400": {
            "description": "参数或接口不匹配",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "密钥无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "余额或Key额度不足",
            "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"
                }
              }
            }
          },
          "405": {
            "description": "方法错误",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "图片幂等键冲突、处理中或结果无法取回",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "原任务仍在处理时的等待秒数"
              },
              "X-302API-Original-Request-ID": {
                "schema": {
                  "type": "string"
                },
                "description": "关联的原图片请求编号"
              }
            }
          },
          "429": {
            "description": "限流或当日额度耗尽；按error.code区分",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "仅频率限制可能提供，单位秒；不保证所有429都有。",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Limit-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。账户所有Key共享的当前RPM上限"
              },
              "X-RateLimit-Remaining-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。当前分钟窗口剩余请求数"
              },
              "X-RateLimit-Reset-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。当前分钟窗口重置倒计时，例如12s"
              }
            }
          },
          "502": {
            "description": "结果异常或图片待核对；不自动重试",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "服务未就绪",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "待核账单暂缓或预算计划临时不可用时的建议等待秒数"
              }
            }
          },
          "default": {
            "description": "其他错误；代理或网络错误不保证JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 128
            },
            "description": "图片任务去重，作用域为API Key；同一键与相同参数的成功图片结果可在15分钟内取回（加密暂存，单次最多16 MiB且受容量限制）；流式取回返回text/event-stream，仅包含最终图片和结束信息。普通文本不保证支持。"
          }
        ]
      }
    },
    "/images/edits": {
      "post": {
        "operationId": "images_edits",
        "summary": "images/edits",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/ImageEditRequest"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImageEditJSONRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "成功；请检查内容与usage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImageResponse"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "GPT 图片 SSE 事件流；可通过 partial_images 请求 0 到 3 张预览图，每次流式请求生成 1 张最终图片。"
                }
              }
            },
            "headers": {
              "X-302API-Request-ID": {
                "schema": {
                  "type": "string"
                },
                "description": "本站图片请求编号"
              },
              "X-RateLimit-Limit-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。账户所有Key共享的当前RPM上限"
              },
              "X-RateLimit-Remaining-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。当前分钟窗口剩余请求数"
              },
              "X-RateLimit-Reset-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。当前分钟窗口重置倒计时，例如12s"
              },
              "X-302API-Replay-Available": {
                "schema": {
                  "type": "string"
                },
                "description": "带幂等键的首次非流式图片结果是否已暂存"
              },
              "X-302API-Idempotent-Replayed": {
                "schema": {
                  "type": "string"
                },
                "description": "true 表示返回了原图片结果"
              },
              "X-302API-Original-Request-ID": {
                "schema": {
                  "type": "string"
                },
                "description": "取回结果时的原图片请求编号"
              }
            }
          },
          "400": {
            "description": "参数或接口不匹配",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "密钥无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "余额或Key额度不足",
            "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"
                }
              }
            }
          },
          "405": {
            "description": "方法错误",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "图片幂等键冲突、处理中或结果无法取回",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "原任务仍在处理时的等待秒数"
              },
              "X-302API-Original-Request-ID": {
                "schema": {
                  "type": "string"
                },
                "description": "关联的原图片请求编号"
              }
            }
          },
          "429": {
            "description": "限流或当日额度耗尽；按error.code区分",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "仅频率限制可能提供，单位秒；不保证所有429都有。",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Limit-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。账户所有Key共享的当前RPM上限"
              },
              "X-RateLimit-Remaining-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。当前分钟窗口剩余请求数"
              },
              "X-RateLimit-Reset-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。当前分钟窗口重置倒计时，例如12s"
              }
            }
          },
          "502": {
            "description": "结果异常或图片待核对；不自动重试",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "服务未就绪",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "待核账单暂缓或预算计划临时不可用时的建议等待秒数"
              }
            }
          },
          "default": {
            "description": "其他错误；代理或网络错误不保证JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 128
            },
            "description": "图片任务去重，作用域为API Key；同一键与相同参数的成功图片结果可在15分钟内取回（加密暂存，单次最多16 MiB且受容量限制）；流式取回返回text/event-stream，仅包含最终图片和结束信息。普通文本不保证支持。"
          }
        ]
      }
    },
    "/messages": {
      "post": {
        "summary": "Claude native Messages",
        "description": "下列在售 Claude 模型的Anthropic原生接口，共用本站Key和余额；max_tokens必填。beta按白名单转发，其余移除；count_tokens未开放。必要采样/思考参数会兼容处理，详见接入文档。",
        "security": [
          {
            "AnthropicKey": []
          }
        ],
        "parameters": [
          {
            "name": "anthropic-version",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "2023-06-01"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "max_tokens",
                  "messages"
                ],
                "properties": {
                  "model": {
                    "type": "string",
                    "enum": [
                      "claude-fable-5-2",
                      "claude-fable-5-1",
                      "claude-haiku-5-5",
                      "claude-sonnet-5-5",
                      "claude-opus-5-5"
                    ]
                  },
                  "max_tokens": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "messages": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "role",
                        "content"
                      ],
                      "properties": {
                        "role": {
                          "type": "string",
                          "enum": [
                            "user",
                            "assistant"
                          ]
                        },
                        "content": {
                          "oneOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type"
                                ],
                                "additionalProperties": true
                              }
                            }
                          ]
                        }
                      }
                    },
                    "minItems": 1
                  },
                  "stream": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Anthropic message JSON or SSE stream",
            "headers": {
              "X-RateLimit-Limit-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。账户所有Key共享的当前RPM上限"
              },
              "X-RateLimit-Remaining-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。当前分钟窗口剩余请求数"
              },
              "X-RateLimit-Reset-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。当前分钟窗口重置倒计时，例如12s"
              },
              "X-302API-Effective-Max-Tokens": {
                "schema": {
                  "type": "string"
                },
                "description": "网关对本次请求设定输出预算时的实际输出上限"
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Authentication failed"
          },
          "429": {
            "description": "Rate limited",
            "headers": {
              "X-RateLimit-Limit-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。账户所有Key共享的当前RPM上限"
              },
              "X-RateLimit-Remaining-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。当前分钟窗口剩余请求数"
              },
              "X-RateLimit-Reset-Requests": {
                "schema": {
                  "type": "string"
                },
                "description": "进入本站 RPM 计数时返回。当前分钟窗口重置倒计时，例如12s"
              }
            }
          },
          "503": {
            "description": "服务暂不可用或待核账单暂缓调用",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "待核账单暂缓或预算计划临时不可用时的建议等待秒数"
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      },
      "AnthropicKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string"
              },
              "type": {
                "type": "string"
              },
              "code": {
                "type": "string"
              }
            },
            "required": [
              "message",
              "type"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "Usage": {
        "type": "object",
        "properties": {
          "prompt_tokens": {
            "type": "integer",
            "minimum": 0
          },
          "completion_tokens": {
            "type": "integer",
            "minimum": 0
          },
          "input_tokens": {
            "type": "integer",
            "minimum": 0
          },
          "output_tokens": {
            "type": "integer",
            "minimum": 0
          },
          "total_tokens": {
            "type": "integer",
            "minimum": 0
          },
          "prompt_tokens_details": {
            "type": "object"
          },
          "input_tokens_details": {
            "type": "object"
          },
          "output_tokens_details": {
            "type": "object"
          },
          "completion_tokens_details": {
            "type": "object"
          }
        },
        "required": [],
        "description": "不同端点字段不同；子项不重复加总。缺失不代表零费用。"
      },
      "ChatRequest": {
        "type": "object",
        "properties": {
          "model": {
            "type": "string"
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "role": {
                  "type": "string"
                },
                "content": {
                  "oneOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  ]
                }
              },
              "required": [
                "role",
                "content"
              ]
            },
            "minItems": 1
          },
          "stream": {
            "type": "boolean",
            "default": false
          },
          "max_completion_tokens": {
            "type": "integer",
            "minimum": 1,
            "description": "可选输出上限。缺省时当前按8192估算预占，可能按实际预算注入输出上限，见X-302API-Effective-Max-Tokens，模型自身限制仍适用。新旧Chat字段同时提供时优先max_completion_tokens。"
          },
          "max_tokens": {
            "type": "integer",
            "minimum": 1,
            "description": "可选输出上限。缺省时当前按8192估算预占，可能按实际预算注入输出上限，见X-302API-Effective-Max-Tokens，模型自身限制仍适用。新旧Chat字段同时提供时优先max_completion_tokens。"
          },
          "stream_options": {
            "type": "object",
            "properties": {
              "include_usage": {
                "type": "boolean"
              }
            },
            "required": []
          },
          "modalities": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Gemini生图仅[text,image]。"
          },
          "user": {
            "type": "string"
          }
        },
        "required": [
          "model",
          "messages"
        ],
        "description": "文本参数子集；其他字段不承诺支持。Gemini 图片支持流式和非流式；max_tokens可省略，填写时须为正整数，上限由所选模型及厂商接口校验。支持自动转换的 GPT-6 型号在携带 function tools 或工具历史时使用 Responses 并返回 Chat 格式；gpt-6.1-terra 的工具调用请直接使用 Responses；仅n=1、function工具，effort支持low/medium/high/xhigh/max，默认medium，none/minimal转low。普通Chat移除reasoning_effort及不支持的采样字段。客户端应保留工具调用ID和结果，详见/docs#compatibility。"
      },
      "ResponsesRequest": {
        "type": "object",
        "properties": {
          "model": {
            "type": "string",
            "examples": [
              "gpt-6.2-astra",
              "gpt-6.2-sol",
              "gpt-6.1-terra",
              "gpt-6.1-sol",
              "gpt-6-astra",
              "gpt-6-sol",
              "gpt-6-luna"
            ]
          },
          "input": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            ]
          },
          "stream": {
            "type": "boolean",
            "default": false
          },
          "max_output_tokens": {
            "type": "integer",
            "minimum": 1,
            "description": "可选输出上限。缺省时当前按8192估算预占，可能按实际预算注入输出上限，见X-302API-Effective-Max-Tokens，模型自身限制仍适用。推理Token属于输出预算。"
          }
        },
        "required": [
          "model",
          "input"
        ],
        "description": "使用 input 提交文本或消息历史。可用型号见接入文档的模型接口表；请勿发送 Chat 专用的 stream_options。"
      },
      "ImageRequest": {
        "type": "object",
        "properties": {
          "model": {
            "type": "string",
            "enum": [
              "gpt-image-2.5-flare",
              "gpt-image-2.5-sunburst",
              "gpt-image-2.6-flare",
              "gpt-image-2.6-sunburst"
            ]
          },
          "prompt": {
            "type": "string",
            "minLength": 1
          },
          "size": {
            "type": "string",
            "examples": [
              "auto",
              "1024x1024",
              "1536x1024",
              "1024x1536"
            ],
            "description": "未指定时由模型选择；具体尺寸以模型服务为准。"
          },
          "quality": {
            "type": "string",
            "enum": [
              "auto",
              "low",
              "medium",
              "high"
            ]
          },
          "n": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10,
            "default": 1
          },
          "stream": {
            "type": "boolean",
            "default": false,
            "description": "设为 true 时返回 SSE，每次仅可请求一张图片。"
          },
          "output_format": {
            "type": "string",
            "enum": [
              "png",
              "jpeg",
              "webp"
            ]
          },
          "partial_images": {
            "type": "integer",
            "minimum": 0,
            "maximum": 3,
            "description": "流式预览图数量。"
          },
          "user": {
            "type": "string"
          },
          "background": {
            "type": "string",
            "enum": [
              "auto",
              "opaque",
              "transparent"
            ],
            "description": "透明背景需配合 png 或 webp 格式。"
          }
        },
        "required": [
          "model",
          "prompt"
        ],
        "description": "JSON请求体大小由模型服务校验；prompt不可仅空白。新增档位验证状态见文档。",
        "allOf": [
          {
            "if": {
              "properties": {
                "stream": {
                  "const": true
                }
              },
              "required": [
                "stream"
              ]
            },
            "then": {
              "properties": {
                "n": {
                  "const": 1
                }
              }
            }
          }
        ]
      },
      "ImageEditRequest": {
        "type": "object",
        "properties": {
          "model": {
            "type": "string",
            "enum": [
              "gpt-image-2.5-flare",
              "gpt-image-2.5-sunburst",
              "gpt-image-2.6-flare",
              "gpt-image-2.6-sunburst"
            ]
          },
          "prompt": {
            "type": "string",
            "minLength": 1
          },
          "size": {
            "type": "string",
            "examples": [
              "auto",
              "1024x1024",
              "1536x1024",
              "1024x1536"
            ],
            "description": "未指定时由模型选择；具体尺寸以模型服务为准。"
          },
          "quality": {
            "type": "string",
            "enum": [
              "auto",
              "low",
              "medium",
              "high"
            ]
          },
          "n": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10,
            "default": 1
          },
          "stream": {
            "type": "boolean",
            "default": false,
            "description": "设为 true 时返回 SSE，每次仅可请求一张图片。"
          },
          "output_format": {
            "type": "string",
            "enum": [
              "png",
              "jpeg",
              "webp"
            ]
          },
          "partial_images": {
            "type": "integer",
            "minimum": 0,
            "maximum": 3,
            "description": "流式预览图数量。"
          },
          "user": {
            "type": "string"
          },
          "image": {
            "type": "string",
            "format": "binary",
            "description": "PNG、JPEG 或 WebP 图片文件。多张可重复提交 image 字段，总计最多 16 张。"
          },
          "mask": {
            "type": "string",
            "format": "binary",
            "description": "可选蒙版，尚未逐模型验证。"
          },
          "background": {
            "type": "string",
            "enum": [
              "auto",
              "opaque",
              "transparent"
            ],
            "description": "透明背景需配合 png 或 webp 格式。"
          }
        },
        "required": [
          "model",
          "prompt",
          "image"
        ],
        "description": "multipart 上传文件，推荐字段 image。size 和 quality 可选。",
        "allOf": [
          {
            "if": {
              "properties": {
                "stream": {
                  "const": true
                }
              },
              "required": [
                "stream"
              ]
            },
            "then": {
              "properties": {
                "n": {
                  "const": 1
                }
              }
            }
          }
        ]
      },
      "ChatResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "choices": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "index": {
                  "type": "integer"
                },
                "message": {
                  "type": "object",
                  "properties": {
                    "role": {
                      "type": "string"
                    },
                    "content": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        },
                        {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string"
                              },
                              "text": {
                                "type": "string"
                              },
                              "image_url": {
                                "type": "object",
                                "properties": {
                                  "url": {
                                    "type": "string",
                                    "description": "可能为data:image/...;base64,...，不要当作可直接访问的HTTP地址。"
                                  }
                                },
                                "required": [
                                  "url"
                                ]
                              }
                            },
                            "required": []
                          }
                        }
                      ]
                    },
                    "images": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "image_url": {
                            "type": "object",
                            "properties": {
                              "url": {
                                "type": "string",
                                "description": "可能为data:image/...;base64,...，不要当作可直接访问的HTTP地址。"
                              }
                            },
                            "required": [
                              "url"
                            ]
                          }
                        },
                        "required": [
                          "image_url"
                        ]
                      }
                    },
                    "tool_calls": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  },
                  "required": [
                    "role"
                  ]
                },
                "finish_reason": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "required": [
                "index",
                "message"
              ]
            }
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          }
        },
        "required": [
          "choices"
        ],
        "description": "Gemini图片内容布局可能不同，参考文档提取器；不保证仅文本content。"
      },
      "ResponsesResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "output": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "type": {
                  "type": "string"
                },
                "role": {
                  "type": "string"
                },
                "status": {
                  "type": "string"
                },
                "content": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string"
                      },
                      "text": {
                        "type": "string"
                      },
                      "annotations": {
                        "type": "array",
                        "items": {
                          "type": "object"
                        }
                      }
                    },
                    "required": [
                      "type"
                    ]
                  }
                }
              },
              "required": [
                "type"
              ]
            }
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          }
        },
        "required": [
          "output"
        ]
      },
      "ImageResponse": {
        "type": "object",
        "properties": {
          "created": {
            "type": "integer"
          },
          "data": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "properties": {
                "b64_json": {
                  "type": "string"
                }
              },
              "required": [
                "b64_json"
              ]
            }
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          }
        },
        "required": [
          "data",
          "usage"
        ]
      },
      "ModelsResponse": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "enum": [
              "list"
            ]
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "object": {
                  "type": "string"
                },
                "created": {
                  "type": "integer"
                },
                "owned_by": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "object",
                "created",
                "owned_by"
              ]
            }
          }
        },
        "required": [
          "object",
          "data"
        ]
      },
      "ImageEditJSONRequest": {
        "type": "object",
        "properties": {
          "model": {
            "type": "string",
            "enum": [
              "gpt-image-2.5-flare",
              "gpt-image-2.5-sunburst",
              "gpt-image-2.6-flare",
              "gpt-image-2.6-sunburst"
            ]
          },
          "prompt": {
            "type": "string",
            "minLength": 1
          },
          "size": {
            "type": "string",
            "examples": [
              "auto",
              "1024x1024",
              "1536x1024",
              "1024x1536"
            ],
            "description": "未指定时由模型选择；具体尺寸以模型服务为准。"
          },
          "quality": {
            "type": "string",
            "enum": [
              "auto",
              "low",
              "medium",
              "high"
            ]
          },
          "n": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10,
            "default": 1
          },
          "stream": {
            "type": "boolean",
            "default": false,
            "description": "设为 true 时返回 SSE，每次仅可请求一张图片。"
          },
          "output_format": {
            "type": "string",
            "enum": [
              "png",
              "jpeg",
              "webp"
            ]
          },
          "partial_images": {
            "type": "integer",
            "minimum": 0,
            "maximum": 3,
            "description": "流式预览图数量。"
          },
          "user": {
            "type": "string"
          },
          "background": {
            "type": "string",
            "enum": [
              "auto",
              "opaque",
              "transparent"
            ],
            "description": "透明背景需配合 png 或 webp 格式。"
          },
          "images": {
            "type": "array",
            "minItems": 1,
            "maxItems": 16,
            "items": {
              "type": "object",
              "properties": {
                "image_url": {
                  "type": "string",
                  "description": "图片 URL 或 data URI。"
                },
                "file_id": {
                  "type": "string"
                }
              },
              "anyOf": [
                {
                  "required": [
                    "image_url"
                  ]
                },
                {
                  "required": [
                    "file_id"
                  ]
                }
              ]
            }
          }
        },
        "required": [
          "model",
          "prompt",
          "images"
        ],
        "description": "JSON 编辑请求，使用 images 数组指定输入图片。",
        "allOf": [
          {
            "if": {
              "properties": {
                "stream": {
                  "const": true
                }
              },
              "required": [
                "stream"
              ]
            },
            "then": {
              "properties": {
                "n": {
                  "const": 1
                }
              }
            }
          }
        ]
      }
    }
  }
}
