{
  "openapi": "3.0.1",
  "info": {
    "title": "Mintlify Assistant API",
    "description": "用于将 Mintlify 的探索功能集成到你的产品中的 API。",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.mintlify.com/discovery"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v2/assistant/{domain}/message": {
      "post": {
        "summary": "创建 AI 助手消息",
        "description": "针对指定的 domain，从 AI 助手生成一条回复消息。适用于 AI SDK v5 及更高版本。\n\n使用 assistant API 密钥进行身份验证。",
        "parameters": [
          {
            "name": "domain",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "来自你的 `domain.mintlify.site` URL 中的 domain 标识符。你可以在控制台 URL 的末尾找到它。例如，在 `dashboard.mintlify.com/organization/domain` 中，domain 标识符是 `domain`。"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "fp",
                  "messages"
                ],
                "properties": {
                  "fp": {
                    "type": "string",
                    "description": "用于跟踪会话的指纹标识符。对匿名用户使用 `anonymous`，或提供一个唯一的用户标识符。"
                  },
                  "threadId": {
                    "default": null,
                    "type": "string",
                    "description": "一个可选的标识符，用于在多条消息之间保持会话的连续性。提供该值后，系统会将后续消息关联到同一个会话线程。当 `event.type === 'finish'` 时，响应中会在 `event.threadId` 字段返回该 `threadId`。"
                  },
                  "messages": {
                    "type": "array",
                    "default": [
                      {
                        "id": "foobar",
                        "role": "user",
                        "parts": [
                          {
                            "type": "text",
                            "text": "How do I get started"
                          }
                        ]
                      }
                    ],
                    "items": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "description": "消息的唯一标识符。"
                        },
                        "role": {
                          "type": "string",
                          "enum": [
                            "system",
                            "assistant",
                            "user"
                          ],
                          "description": "消息发送者的角色。"
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time",
                          "description": "消息创建时的时间戳。"
                        },
                        "parts": {
                          "type": "array",
                          "items": {
                            "oneOf": [
                              {
                                "type": "object",
                                "description": "文本内容片段。",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "text"
                                    ]
                                  },
                                  "text": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type",
                                  "text"
                                ]
                              },
                              {
                                "type": "object",
                                "description": "包含可选提供方 metadata 的推理内容片段。",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "reasoning"
                                    ]
                                  },
                                  "text": {
                                    "type": "string"
                                  },
                                  "providerMetadata": {
                                    "type": "object",
                                    "description": "可选的、特定于提供方的 metadata。"
                                  }
                                },
                                "required": [
                                  "type",
                                  "text"
                                ]
                              },
                              {
                                "type": "object",
                                "description": "引用来源 URL 的片段。",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "source-url"
                                    ]
                                  },
                                  "sourceId": {
                                    "type": "string"
                                  },
                                  "url": {
                                    "type": "string"
                                  },
                                  "title": {
                                    "type": "string"
                                  },
                                  "providerMetadata": {
                                    "type": "object",
                                    "description": "可选的、特定于提供方的 metadata。"
                                  }
                                },
                                "required": [
                                  "type",
                                  "sourceId",
                                  "url"
                                ]
                              },
                              {
                                "type": "object",
                                "description": "文件附件内容片段。",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "file"
                                    ]
                                  },
                                  "mediaType": {
                                    "type": "string"
                                  },
                                  "url": {
                                    "type": "string"
                                  },
                                  "filename": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type",
                                  "mediaType",
                                  "url"
                                ]
                              },
                              {
                                "type": "object",
                                "description": "标记一个新步骤开始的片段。",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "step-start"
                                    ]
                                  }
                                },
                                "required": [
                                  "type"
                                ]
                              }
                            ]
                          },
                          "description": "消息片段数组。每个片段都有一个类型以及该类型特有的字段。"
                        },
                        "metadata": {
                          "type": "object",
                          "description": "与消息关联的可选 metadata。"
                        }
                      },
                      "required": [
                        "id",
                        "role",
                        "parts"
                      ]
                    },
                    "description": "会话中的消息数组。使用 @ai-sdk/react 包中的 useChat 钩子提供的 handleSubmit 函数来管理消息和流式响应。"
                  },
                  "retrievalPageSize": {
                    "type": "number",
                    "default": 5,
                    "description": "用于生成回答时检索的文档搜索结果数量。数值越高，可用的上下文越多，但可能增加响应时间。推荐值：5。"
                  },
                  "filter": {
                    "type": "object",
                    "default": null,
                    "properties": {
                      "version": {
                        "type": "string",
                        "description": "可选的版本过滤条件。"
                      },
                      "language": {
                        "type": "string",
                        "description": "可选的语言过滤条件。"
                      },
                      "groups": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        },
                        "description": "助手为其作答的用户所属的可选分组。如果省略 `groups`，助手只读取公开内容。在所有页面都需要身份验证的部署上，省略 `groups` 等同于传入空数组。空数组表示一个没有分组的已登录用户：助手还会读取对所有已登录用户开放的页面。传入分组时，它还会读取仅限其中至少一个分组访问的页面。面向已登录读者或特定分组的 `<Visibility>` 部分遵循相同的规则。Mintlify 不会验证分组成员身份，因此你的后端必须为每个用户选择分组。在包含公开页面的受密码保护部署上，传入空数组即可读取未标记为公开的页面。"
                      }
                    },
                    "description": "用于搜索的可选筛选条件。"
                  },
                  "context": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "code",
                            "textSelection"
                          ],
                          "description": "所提供上下文的类型。"
                        },
                        "value": {
                          "type": "string",
                          "description": "代码片段或选中文本的内容。"
                        },
                        "path": {
                          "type": "string",
                          "description": "源文件或页面的可选路径。"
                        },
                        "elementId": {
                          "type": "string",
                          "description": "包含该上下文的 UI 元素的可选标识符。"
                        }
                      },
                      "required": [
                        "type",
                        "value"
                      ]
                    },
                    "description": "提供给 AI 助手的可选上下文信息数组。"
                  },
                  "currentPath": {
                    "type": "string",
                    "description": "用户当前正在查看的页面路径。若提供，AI 助手会利用该上下文给出更相关的回答。最大长度：200 个字符。"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "消息已成功生成",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "description": "与 AI SDK v5 兼容的流式响应。使用 [@ai-sdk/react 中的 useChat 钩子](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat#usechat) 来处理响应流。"
                }
              }
            }
          },
          "400": {
            "description": "请求体无效，例如缺少 `fp` 或 `messages` 字段。响应体会描述具体错误。"
          },
          "401": {
            "description": "API 密钥缺失或无效，或者你的组织未启用 AI 助手。"
          },
          "402": {
            "description": "你的组织已达到本计费周期的额度上限。"
          },
          "403": {
            "description": "你所在的地区不提供 AI 功能、你的 API 密钥无权访问此 domain、你的套餐不包含 assistant API 访问权限，或者你的请求来自不在 API 密钥允许列表中的 IP 地址。"
          },
          "404": {
            "description": "该 domain 不存在文档站点，或者 `threadId` 或 `threadKey` 无效。"
          },
          "413": {
            "description": "对话已达到最大消息数量，或输入内容过长。"
          },
          "429": {
            "description": "你已超出每个组织每小时 10,000 个请求的速率限制。"
          },
          "500": {
            "description": "发生了意外的服务器错误。请重试该请求。如果错误仍然存在，请联系支持团队。"
          }
        }
      }
    },
    "/v1/page/{domain}": {
      "post": {
        "summary": "获取页面内容",
        "description": "通过路径检索特定文档页面的完整文本内容。在搜索之后使用此接口来获取匹配页面的完整内容。\n\n使用 assistant API 密钥进行身份验证。页面内容请求不消耗额度。",
        "parameters": [
          {
            "name": "domain",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "来自你的 `domain.mintlify.site` URL 的域名标识符。可以在你的控制台 URL 末尾找到。例如，`dashboard.mintlify.com/organization/domain` 的域名标识符为 `domain`。"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "path"
                ],
                "properties": {
                  "path": {
                    "type": "string",
                    "description": "要检索内容的页面路径或 slug。对应于 [Search documentation](/zh/api/assistant/search) 端点返回的 `path` 字段。"
                  },
                  "groups": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "你为其读取内容的用户所属的可选分组。如果省略 `groups`，你只能读取公开页面及其公开部分。在所有页面都需要身份验证的部署上，省略 `groups` 等同于传入空数组。空数组表示一个没有分组的已登录用户：你还可以读取对所有已登录用户开放的页面。传入分组时，你还可以读取仅限其中至少一个分组访问的页面。用户无法查看的 `<Visibility>` 部分会从页面中移除。Mintlify 不会验证分组成员身份，因此你的后端必须为每个用户选择分组。在包含公开页面的受密码保护部署上，传入空数组即可读取未标记为公开的页面。"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "页面内容检索成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "path": {
                      "type": "string",
                      "description": "所请求的页面路径。"
                    },
                    "content": {
                      "type": "string",
                      "description": "页面的完整文本内容。"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`path` 缺失或为空，或者 `groups` 不是字符串数组。响应体会描述具体错误。"
          },
          "401": {
            "description": "API 密钥缺失或无效。"
          },
          "403": {
            "description": "你的 API 密钥无权访问此 domain、你的套餐不包含 assistant API 访问权限，或者你的请求来自不在 API 密钥允许列表中的 IP 地址。"
          },
          "404": {
            "description": "该 domain 不存在文档站点、该站点没有搜索索引，或该路径下不存在页面。",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "description": "描述为何无法找到该页面的错误消息。"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "你已超出每个组织每小时 10,000 个请求的速率限制。"
          },
          "500": {
            "description": "发生了意外的服务器错误。请重试该请求。如果错误仍然存在，请联系支持团队。"
          }
        }
      }
    },
    "/v1/search/{domain}": {
      "post": {
        "x-mint": {
          "mcp": {
            "enabled": true
          }
        },
        "summary": "搜索文档",
        "description": "使用语义搜索和关键词搜索来搜索你的文档，并支持可配置的过滤和分页。\n\n使用 assistant API 密钥进行身份验证。搜索请求不消耗额度。",
        "parameters": [
          {
            "name": "domain",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "来自你的 `domain.mintlify.site` URL 的域名标识符。可以在控制台 URL 的末尾找到。例如，`dashboard.mintlify.com/organization/domain` 的域名标识符就是 `domain`。"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "query"
                ],
                "properties": {
                  "query": {
                    "type": "string",
                    "description": "在文档内容中要执行的搜索查询。"
                  },
                  "pageSize": {
                    "type": "integer",
                    "default": 10,
                    "minimum": 1,
                    "maximum": 50,
                    "description": "要返回的搜索结果数量。必须在 1 到 50 之间。若未指定，默认为 10。"
                  },
                  "scoreThreshold": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1,
                    "description": "结果的最低相关性分数。仅返回分数等于或高于此阈值的结果。必须介于 0 和 1 之间。"
                  },
                  "filter": {
                    "type": "object",
                    "description": "用于缩小搜索结果范围的可选过滤参数。",
                    "properties": {
                      "version": {
                        "type": "string",
                        "description": "按文档版本筛选结果。"
                      },
                      "language": {
                        "type": "string",
                        "description": "按内容语言筛选结果。"
                      },
                      "tag": {
                        "type": "string",
                        "description": "按标签筛选结果。"
                      },
                      "groups": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        },
                        "description": "你为其搜索的用户所属的可选分组。如果省略 `groups`，结果只包含公开内容。在所有页面都需要身份验证的部署上，省略 `groups` 等同于传入空数组。空数组表示一个没有分组的已登录用户：结果还会包含对所有已登录用户开放的页面。传入分组时，结果还会包含仅限其中至少一个分组访问的页面。面向已登录读者或特定分组的 `<Visibility>` 部分遵循相同的规则。Mintlify 不会验证分组成员身份，因此你的后端必须为每个用户选择分组。在包含公开页面的受密码保护部署上，传入空数组即可搜索未标记为公开的页面。"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "搜索结果",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "content": {
                        "type": "string",
                        "description": "来自文档中匹配的内容。"
                      },
                      "path": {
                        "type": "string",
                        "description": "源文档所在的路径或 URL。"
                      },
                      "metadata": {
                        "type": "object",
                        "description": "与搜索结果相关的附加 metadata。"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`query` 缺失或不是字符串，或者 `pageSize` 或 `filter` 无效。响应体会描述具体错误。"
          },
          "401": {
            "description": "API 密钥缺失或无效。"
          },
          "403": {
            "description": "你的 API 密钥无权访问此 domain、你的套餐不包含 assistant API 访问权限，或者你的请求来自不在 API 密钥允许列表中的 IP 地址。"
          },
          "404": {
            "description": "该 domain 不存在文档站点，或者搜索未返回任何结果。"
          },
          "429": {
            "description": "你已超出每个组织每小时 10,000 个请求的速率限制。"
          },
          "500": {
            "description": "发生了意外的服务器错误。请重试该请求。如果错误仍然存在，请联系支持团队。"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Authorization 请求头需要携带 Bearer 令牌。请使用 assistant API 密钥。你可以在控制台的 [API 密钥页面](https://dashboard.mintlify.com/settings/organization/api-keys) 中生成一个。在生产环境中，请通过你的后端代理请求，而不是将密钥嵌入到客户端代码中。"
      }
    }
  }
}
