{
  "openapi": "3.1.0",
  "info": {
    "title": "Ask Mashrur AI",
    "version": "1.0.0",
    "description": "Answers questions about Mashrur Corporation, its services, and buying construction materials in Bangladesh. Use the contact page for a written quotation."
  },
  "servers": [
    {
      "url": "https://mashrurcorporation.com"
    }
  ],
  "paths": {
    "/api/ask": {
      "post": {
        "operationId": "askMashrur",
        "summary": "Ask a question about Mashrur Corporation",
        "description": "Provide recent conversation history ending with a user message. Requests are limited to 10 per minute per IP. Browser requests must be same-origin.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AskRequest"
              },
              "example": {
                "messages": [
                  {
                    "role": "user",
                    "content": "How do I request a written quotation?"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A streamed UTF-8 plain-text reply. The stream can terminate early if the upstream response fails.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON or message history.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The browser Origin does not match the request origin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "The JSON request body exceeds 96 KiB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "The request Content-Type is not application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "The request rate limit was exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "example": 60
                }
              }
            }
          },
          "502": {
            "description": "The upstream assistant was unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "The assistant or its rate limiter is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AskRequest": {
        "type": "object",
        "required": [
          "messages"
        ],
        "properties": {
          "messages": {
            "type": "array",
            "minItems": 1,
            "maxItems": 12,
            "items": {
              "$ref": "#/components/schemas/Message"
            },
            "description": "Ordered history with a final user message."
          }
        }
      },
      "Message": {
        "type": "object",
        "required": [
          "role",
          "content"
        ],
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "user",
              "assistant"
            ]
          },
          "content": {
            "type": "string",
            "minLength": 1,
            "description": "Trimmed text. The API uses the first 1,200 UTF-16 code units of each message."
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          }
        }
      }
    }
  }
}
