{
  "openapi": "3.0.3",
  "info": {
    "title": "盛航云 · 大模型 API",
    "version": "1.0.0",
    "description": "OpenAI 兼容的大模型聚合接口。每个模型对应一个上游，model 字段填调用名（如 glm-5.3、qwen3.5-plus），一个 API Key 调全部模型，按 tokens 计费、单价见模型列表。",
    "contact": {
      "name": "盛航云",
      "url": "https://yun.nmgshenghang.cn"
    }
  },
  "servers": [
    {
      "url": "https://yun.nmgshenghang.cn/v1",
      "description": "生产环境"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "控制台创建的 API Key，形如 sk-shsl-..."
      }
    },
    "schemas": {
      "ChatRequest": {
        "type": "object",
        "required": [
          "model",
          "messages"
        ],
        "properties": {
          "model": {
            "type": "string",
            "enum": [
              "deepseek-v4.1-flash-1017",
              "deepseek-v4-flash-0731",
              "deepseek-v4.1-flash",
              "glm-5.1",
              "glm-5.2",
              "glm-5.3-flashx",
              "kimi-k2.5",
              "minimax-m2.7",
              "glm-5.3",
              "glm-5.3-flash",
              "kimi-k2.6",
              "kimi-k2.7-code",
              "kimi-k3",
              "minimax-m3",
              "qwen3.5-plus",
              "qwen3.6-flash",
              "qwen3.6-plus",
              "qwen3.7-max",
              "qwen3.7-plus"
            ],
            "description": "模型名。下列任选一个：deepseek-v4.1-flash-1017 / deepseek-v4-flash-0731 / deepseek-v4.1-flash / glm-5.1 / glm-5.2 / glm-5.3-flashx / kimi-k2.5 / minimax-m2.7 / glm-5.3 / glm-5.3-flash / kimi-k2.6 / kimi-k2.7-code / kimi-k3 / minimax-m3 / qwen3.5-plus / qwen3.6-flash / qwen3.6-plus / qwen3.7-max / qwen3.7-plus"
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "role",
                "content"
              ],
              "properties": {
                "role": {
                  "type": "string",
                  "enum": [
                    "system",
                    "user",
                    "assistant",
                    "tool"
                  ]
                },
                "content": {
                  "description": "字符串；多模态时可传 [{type:\"text\"}, {type:\"image_url\"}]",
                  "oneOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  ]
                }
              }
            }
          },
          "temperature": {
            "type": "number",
            "minimum": 0,
            "maximum": 2,
            "default": 1
          },
          "top_p": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "max_tokens": {
            "type": "integer",
            "minimum": 1
          },
          "stream": {
            "type": "boolean",
            "default": false,
            "description": "true 时返回 SSE 流"
          },
          "stop": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            ]
          },
          "tools": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "OpenAI function calling 格式"
          },
          "tool_choice": {},
          "response_format": {
            "type": "object",
            "description": "例如 {\"type\":\"json_object\"}"
          }
        }
      },
      "ImageRequest": {
        "type": "object",
        "required": [
          "model",
          "prompt"
        ],
        "properties": {
          "model": {
            "type": "string",
            "enum": [
              "doubao-seedream-5.0-pro",
              "qwen-image-3.0",
              "qwen-image-3.0-pro",
              "qwen-image-2.0-pro"
            ],
            "description": "模型名。下列任选一个：doubao-seedream-5.0-pro / qwen-image-3.0 / qwen-image-3.0-pro / qwen-image-2.0-pro"
          },
          "prompt": {
            "type": "string"
          },
          "n": {
            "type": "integer",
            "minimum": 1,
            "maximum": 4,
            "default": 1
          },
          "size": {
            "type": "string",
            "default": "1024x1024",
            "description": "1024x1024 / 1024*1024 均可"
          }
        }
      },
      "VideoRequest": {
        "type": "object",
        "required": [
          "model",
          "prompt"
        ],
        "properties": {
          "model": {
            "type": "string",
            "enum": [
              "minimax-h3",
              "minimax-h3-max"
            ],
            "description": "模型名。下列任选一个：minimax-h3 / minimax-h3-max"
          },
          "prompt": {
            "type": "string"
          },
          "duration": {
            "type": "integer",
            "description": "秒数，例如 5 / 6 / 10"
          },
          "ratio": {
            "type": "string",
            "enum": [
              "16:9",
              "4:3",
              "1:1",
              "3:4",
              "9:16",
              "21:9"
            ],
            "default": "16:9"
          },
          "resolution": {
            "type": "string",
            "enum": [
              "480P",
              "768P"
            ],
            "default": "768P"
          }
        }
      },
      "AudioRequest": {
        "type": "object",
        "required": [
          "model",
          "input",
          "voice"
        ],
        "properties": {
          "model": {
            "type": "string",
            "enum": [
              "cosyvoice-v3.5-flash"
            ],
            "description": "模型名。下列任选一个：cosyvoice-v3.5-flash"
          },
          "input": {
            "type": "string",
            "description": "待合成文本"
          },
          "voice": {
            "type": "string",
            "description": "音色 ID（cosyvoice 无系统音色，需先在控制台创建）"
          },
          "response_format": {
            "type": "string",
            "enum": [
              "mp3",
              "pcm",
              "wav",
              "opus"
            ],
            "default": "mp3"
          },
          "speed": {
            "type": "number",
            "minimum": 0.5,
            "maximum": 2,
            "default": 1
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string"
              },
              "type": {
                "type": "string"
              },
              "code": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  },
  "paths": {
    "/chat/completions": {
      "post": {
        "summary": "对话补全（支持流式、工具调用、多模态）",
        "operationId": "createChatCompletion",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "普通 JSON；stream=true 时为 text/event-stream"
          },
          "401": {
            "description": "Key 无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "余额不足"
          },
          "404": {
            "description": "模型不存在"
          },
          "429": {
            "description": "限流"
          },
          "502": {
            "description": "上游异常，稍后重试或改用同档位其他模型"
          }
        }
      }
    },
    "/embeddings": {
      "post": {
        "summary": "文本向量",
        "operationId": "createEmbeddings",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "input"
                ],
                "properties": {
                  "model": {
                    "type": "string",
                    "example": "bge-m3"
                  },
                  "input": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "向量结果"
          }
        }
      }
    },
    "/images/generations": {
      "post": {
        "summary": "图像生成（按张计费）",
        "operationId": "createImage",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImageRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "返回 data[].url 与 usage"
          }
        }
      }
    },
    "/videos": {
      "post": {
        "summary": "视频生成：创建任务（按秒计费，异步）",
        "operationId": "createVideo",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VideoRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "返回 task id 与 poll_url"
          }
        }
      }
    },
    "/videos/{id}": {
      "get": {
        "summary": "视频生成：查询任务",
        "operationId": "getVideo",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "status 与 video_url"
          }
        }
      }
    },
    "/audio/speech": {
      "post": {
        "summary": "语音合成（按万字符计费）",
        "operationId": "createSpeech",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AudioRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "返回音频 url"
          }
        }
      }
    },
    "/models": {
      "get": {
        "summary": "可用模型列表",
        "operationId": "listModels",
        "responses": {
          "200": {
            "description": "模型数组"
          }
        }
      }
    },
    "/me": {
      "get": {
        "summary": "我的余额与额度",
        "operationId": "getMe",
        "responses": {
          "200": {
            "description": "余额信息"
          }
        }
      }
    }
  }
}