{"openapi":"3.0.1","info":{"title":"麦芽模型网关","version":"1.0.0"},"servers":[{"url":"/"}],"paths":{"/v1/models":{"get":{"summary":"获取模型列表","deprecated":false,"description":"获取当前可用的模型列表。\n\n根据请求头自动识别返回格式：\n- 包含 `x-api-key` 和 `anthropic-version` 头时返回 Anthropic 格式\n- 包含 `x-goog-api-key` 头或 `key` 查询参数时返回 Gemini 格式\n- 其他情况返回 OpenAI 格式\n","operationId":"listModels","tags":["获取模型列表"],"parameters":[{"name":"key","in":"query","description":"Google API Key (用于 Gemini 格式)","required":false,"schema":{"type":"string"}},{"name":"x-api-key","in":"header","description":"Anthropic API Key (用于 Claude 格式)","required":false,"example":"","schema":{"type":"string"}},{"name":"anthropic-version","in":"header","description":"Anthropic API 版本","required":false,"example":"","schema":{"type":"string","example":"2023-06-01"}},{"name":"x-goog-api-key","in":"header","description":"Google API Key (用于 Gemini 格式)","required":false,"example":"","schema":{"type":"string"}}],"responses":{"200":{"description":"成功获取模型列表","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ModelsResponse"}}},"headers":{}},"401":{"description":"认证失败","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"headers":{}}},"security":[{"BearerAuth":[]}]}},"/v1/chat/completions":{"post":{"summary":"创建聊天对话","deprecated":false,"description":"根据对话历史创建模型响应。支持流式和非流式响应。\n\n兼容 OpenAI Chat Completions API。\n","operationId":"createChatCompletion","tags":["OpenAI格式(Chat)"],"parameters":[],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatCompletionRequest"}}},"required":true},"responses":{"200":{"description":"成功创建响应","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatCompletionResponse"}}},"headers":{}},"400":{"description":"请求参数错误","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"headers":{}},"429":{"description":"请求频率限制","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"headers":{}}},"security":[{"BearerAuth":[]}]}}},"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"使用 Bearer Token 认证。\n格式: `Authorization: Bearer sk-xxxxxx`\n"}},"schemas":{"ModelsResponse":{"type":"object","properties":{"object":{"type":"string","example":"list"},"data":{"type":"array","items":{"$ref":"#/components/schemas/Model"}}}},"Model":{"type":"object","properties":{"id":{"type":"string","description":"模型 ID","example":"gpt-4"},"object":{"type":"string","description":"对象类型","example":"model"},"created":{"type":"integer","description":"创建时间戳"},"owned_by":{"type":"string","description":"模型所有者","example":"openai"}}},"ErrorResponse":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string","description":"错误信息"},"type":{"type":"string","description":"错误类型"},"param":{"type":"string","description":"相关参数","nullable":true},"code":{"type":"string","description":"错误代码","nullable":true}}}}},"ChatCompletionRequest":{"type":"object","required":["model","messages"],"properties":{"model":{"type":"string","description":"模型 ID","example":"gpt-4"},"messages":{"type":"array","items":{"$ref":"#/components/schemas/Message"},"description":"对话消息列表"},"temperature":{"type":"number","minimum":0,"maximum":2,"default":1,"description":"采样温度"},"top_p":{"type":"number","minimum":0,"maximum":1,"default":1,"description":"核采样参数"},"n":{"type":"integer","minimum":1,"default":1,"description":"生成数量"},"stream":{"type":"boolean","default":false,"description":"是否流式响应"},"stream_options":{"type":"object","properties":{"include_usage":{"type":"boolean"}}},"stop":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}],"description":"停止序列"},"max_tokens":{"type":"integer","description":"最大生成 Token 数"},"max_completion_tokens":{"type":"integer","description":"最大补全 Token 数"},"presence_penalty":{"type":"number","minimum":-2,"maximum":2,"default":0},"frequency_penalty":{"type":"number","minimum":-2,"maximum":2,"default":0},"logit_bias":{"type":"object","additionalProperties":{"type":"number"},"properties":{}},"user":{"type":"string"},"tools":{"type":"array","items":{"$ref":"#/components/schemas/Tool"}},"tool_choice":{"oneOf":[{"type":"string","enum":["none","auto","required"]},{"type":"object","properties":{"type":{"type":"string"},"function":{"type":"object","properties":{"name":{"type":"string"}}}}}]},"response_format":{"$ref":"#/components/schemas/ResponseFormat"},"seed":{"type":"integer"},"reasoning_effort":{"type":"string","enum":["low","medium","high"],"description":"推理强度 (用于支持推理的模型)"},"modalities":{"type":"array","items":{"type":"string","enum":["text","audio"]}},"audio":{"type":"object","properties":{"voice":{"type":"string"},"format":{"type":"string"}}}}},"Message":{"type":"object","required":["role","content"],"properties":{"role":{"type":"string","enum":["system","user","assistant","tool","developer"],"description":"消息角色"},"content":{"oneOf":[{"type":"string"},{"type":"array","items":{"$ref":"#/components/schemas/MessageContent"}}],"description":"消息内容"},"name":{"type":"string","description":"发送者名称"},"tool_calls":{"type":"array","items":{"$ref":"#/components/schemas/ToolCall"}},"tool_call_id":{"type":"string","description":"工具调用 ID（用于 tool 角色消息）"},"reasoning_content":{"type":"string","description":"推理内容"}}},"MessageContent":{"type":"object","properties":{"type":{"type":"string","enum":["text","image_url","input_audio","file","video_url"]},"text":{"type":"string"},"image_url":{"type":"object","properties":{"url":{"type":"string","description":"图片 URL 或 base64"},"detail":{"type":"string","enum":["low","high","auto"]}}},"input_audio":{"type":"object","properties":{"data":{"type":"string","description":"Base64 编码的音频数据"},"format":{"type":"string","enum":["wav","mp3"]}}},"file":{"type":"object","properties":{"filename":{"type":"string"},"file_data":{"type":"string"},"file_id":{"type":"string"}}},"video_url":{"type":"object","properties":{"url":{"type":"string"}}}}},"ToolCall":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string","example":"function"},"function":{"type":"object","properties":{"name":{"type":"string"},"arguments":{"type":"string"}}}}},"Tool":{"type":"object","properties":{"type":{"type":"string","example":"function"},"function":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string"},"parameters":{"type":"object","description":"JSON Schema 格式的参数定义","properties":{}}}}}},"ResponseFormat":{"type":"object","properties":{"type":{"type":"string","enum":["text","json_object","json_schema"]},"json_schema":{"type":"object","description":"JSON Schema 定义","properties":{}}}},"ChatCompletionResponse":{"type":"object","properties":{"id":{"type":"string"},"object":{"type":"string","example":"chat.completion"},"created":{"type":"integer"},"model":{"type":"string"},"choices":{"type":"array","items":{"type":"object","properties":{"index":{"type":"integer"},"message":{"$ref":"#/components/schemas/Message"},"finish_reason":{"type":"string","enum":["stop","length","tool_calls","content_filter"]}}}},"usage":{"$ref":"#/components/schemas/Usage"},"system_fingerprint":{"type":"string"}}},"Usage":{"type":"object","properties":{"prompt_tokens":{"type":"integer","description":"提示词 Token 数"},"completion_tokens":{"type":"integer","description":"补全 Token 数"},"total_tokens":{"type":"integer","description":"总 Token 数"},"prompt_tokens_details":{"type":"object","properties":{"cached_tokens":{"type":"integer"},"text_tokens":{"type":"integer"},"audio_tokens":{"type":"integer"},"image_tokens":{"type":"integer"}}},"completion_tokens_details":{"type":"object","properties":{"text_tokens":{"type":"integer"},"audio_tokens":{"type":"integer"},"reasoning_tokens":{"type":"integer"}}}}}}}}