{
  "openapi": "3.1.0",
  "info": {
    "title": "FateSign BaZi Calculator",
    "version": "1.0.0",
    "description": "Calculates a BaZi (Four Pillars) chart with FateSign's calendar engine: time zone and historical daylight saving, True Solar Time from the birthplace, solar-term boundaries, hidden stems, Ten Gods, Twelve Stages, Na Yin, Shen Sha and luck cycles. Birth data is used only to calculate the chart and is not stored or logged.",
    "contact": { "email": "contact@hyperflops.ai", "url": "https://fatesign.com/en/contact/" }
  },
  "servers": [{ "url": "https://fatesign.com" }],
  "paths": {
    "/api/gpt/bazi": {
      "post": {
        "operationId": "calculateBaziChart",
        "summary": "Calculate a BaZi chart",
        "description": "Returns the four pillars, Ten Gods, hidden stems, Five Elements, relations, luck cycles (Da Yun), the annual pillars of the current cycle and the monthly pillars of focus_year. Call it before any BaZi reading; never estimate pillars yourself.",
        "x-openai-isConsequential": false,
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ChartRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The calculated chart, the input that was used (including the matched birthplace) and links to FateSign.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ChartResponse" } } }
          },
          "400": { "description": "A field is missing or invalid; error.message says which.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "401": { "description": "Missing or invalid API key.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "422": { "description": "The birthplace was not found or a value is out of range; ask the user to clarify.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "429": { "description": "Too many requests; wait a minute and retry.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": { "type": "http", "scheme": "bearer" }
    },
    "schemas": {
      "ChartRequest": {
        "type": "object",
        "required": ["gender", "birth_date"],
        "properties": {
          "birth_date": { "type": "string", "description": "Birth date as YYYY-MM-DD. With calendar=lunar this is the lunar year, month and day.", "example": "1990-05-20" },
          "birth_time": { "type": ["string", "null"], "description": "Local clock time at birth, 24-hour HH:MM. null when the user does not know it (the hour pillar is then omitted).", "example": "14:30" },
          "birth_place": { "type": "string", "description": "Birth city and country, e.g. 'Osaka, Japan'. Used for the time zone, daylight saving and True Solar Time. Required unless timezone is given." },
          "timezone": { "type": "string", "description": "IANA time zone such as Asia/Shanghai. Only when the birthplace is unknown; True Solar Time is then not applied." },
          "gender": { "type": "string", "enum": ["male", "female"], "description": "Sets the direction of the luck cycles." },
          "calendar": { "type": "string", "enum": ["solar", "lunar"], "default": "solar", "description": "Use lunar only when the user gives a Chinese lunar-calendar date." },
          "lunar_leap_month": { "type": "boolean", "default": false, "description": "True when a lunar date falls in a leap month." },
          "lang": { "type": "string", "enum": ["en", "zh", "zh-hant", "ja", "ko"], "default": "en", "description": "Language of the labels in the result. Match the user's language." },
          "focus_year": { "type": "integer", "description": "Year for the annual and monthly pillars. Defaults to the current year." }
        }
      },
      "ChartResponse": {
        "type": "object",
        "properties": {
          "source": { "type": "string" },
          "input_used": { "type": "object", "description": "The input as calculated, including the matched birthplace. Tell the user if the place differs from what they meant." },
          "chart": { "type": "object", "description": "time (with True Solar Time steps), lunar, solar_terms, day_master, pillars (year, month, day, hour), extra, season, five_elements, relations, luck (da_yun, liu_nian, liu_yue) and warnings." },
          "links": { "type": "object", "description": "FateSign URLs: calculator (full interactive chart), app (ongoing AI readings), compatibility_love and compatibility_business (two-person compatibility reports), glossary." }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": { "code": { "type": "string" }, "message": { "type": "string" } }
          }
        }
      }
    }
  },
  "security": [{ "apiKey": [] }]
}
