{"openapi":"3.0.3","info":{"title":"별사막 풀이 API","version":"v1","description":"별사막(saju) 공개 풀이 API입니다.\n\n**기본 주소:** `https://api.saju.yeodam.ai/v1`\n\n이 API에는 인증과 호출 제한이 없습니다. URL을 알면 누구나 호출할 수 있습니다. 결제·원장 엔드포인트는 없습니다. `priceWon`은 주제 안내일 뿐, 서버가 결제를 확인하지 않습니다.\n\n브라우저 CORS는 `https://saju.yeodam.ai`와 로컬 Vite(`http://localhost:5173`, `http://127.0.0.1:5173`)만 허용합니다. 이 문서 사이트 출처에서는 브라우저로 직접 호출할 수 없습니다. 서버나 `curl`에서는 Origin 없이 호출하면 됩니다.\n\n라이브 모델 이름은 코드에 고정되어 있지 않습니다. `GET /v1/health`의 `model` 값이 현재 설정된 모델입니다. 풀이 한 건의 시한은 45초(`READING_DEADLINE_MS=45000`)이며, 넘으면 `504` `upstream_timeout`입니다.\n\n`preview: true`는 무료 미리보기입니다. 없거나 `false`이면 본편 풀이입니다. 본편도 이 API에서는 결제 없이 요청되며, 그때마다 모델 호출 비용이 발생합니다.\n\n같은 Worker에 전환용 별칭 `/api/v1`이 아직 붙어 있습니다. 웹 호스트 `saju.yeodam.ai/api/v1`은 웹/API가 분리되어 404입니다. 정식 경로는 `https://api.saju.yeodam.ai/v1`입니다."},"servers":[{"url":"https://api.saju.yeodam.ai/v1","description":"라이브 (정식)"}],"tags":[{"name":"상태","description":"서비스와 모델 상태"},{"name":"주제","description":"풀이 주제와 안내 가격"},{"name":"풀이","description":"사주 풀이 생성"}],"paths":{"/health":{"get":{"tags":["상태"],"operationId":"getHealth","summary":"상태 확인","description":"`model`은 Worker 환경 변수 `GEMINI_MODEL`을 반영합니다. 코드 기본값은 바뀔 수 있으니 이 응답을 기준으로 하세요. `sample`이 `true`이면 모의 제공자의 예시 풀이입니다.","responses":{"200":{"description":"서비스가 응답합니다.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"},"example":{"ok":true,"service":"byeolsamak","provider":"gemini","model":"gemini-4-hydrogen","sample":false}}}}}}},"/themes":{"get":{"tags":["주제"],"operationId":"getThemes","summary":"풀이 주제 목록","description":"개인 풀이 주제(`themes`)와 궁합(`compatibility`)을 돌려줍니다. `priceWon`은 안내 가격입니다. 미리보기(`preview`)는 0원입니다. 결제는 이 API에 없습니다.","responses":{"200":{"description":"주제 목록","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ThemesResponse"},"example":{"themes":[{"id":"new-year-2027","title":"2027 신년운세","priceWon":990,"months":true},{"id":"christmas-love","title":"이브 연애 일기예보","priceWon":990,"months":false},{"id":"natal","title":"타고난 사주","priceWon":990,"months":false},{"id":"money-work-2027","title":"2027 돈·일","priceWon":990,"months":true},{"id":"love-2027","title":"2027 연애운","priceWon":990,"months":true}],"compatibility":{"path":"/v1/readings/compatibility","title":"궁합","priceWon":990},"preview":{"priceWon":0}}}}}}}},"/readings/compatibility":{"post":{"tags":["풀이"],"operationId":"createCompatibilityReading","summary":"궁합 풀이","description":"두 사람의 명식으로 궁합 풀이를 만듭니다. `preview: true`는 무료 미리보기입니다. 본편은 최대 약 45초가 걸릴 수 있습니다.\n\n요청 본문은 `compatibilityBodySchema`입니다. 공통 `options`는 두 사람에게 같이 적용됩니다.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompatibilityBody"},"examples":{"preview":{"summary":"미리보기 (preview: true)","value":{"preview":true,"personA":{"nickname":"하늘","gender":"female","calendar":"solar","date":"1994-08-17","time":"14:20","birthplace":{"name":"서울","longitude":126.978}},"personB":{"nickname":"도윤","gender":"male","calendar":"solar","date":"1992-03-05","time":"08:40","birthplace":{"name":"부산","longitude":129.0756}}}}}}}},"responses":{"200":{"description":"풀이 결과. `theme`는 `compatibility`입니다.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReadingResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"500":{"$ref":"#/components/responses/Internal"},"502":{"$ref":"#/components/responses/Upstream"},"504":{"$ref":"#/components/responses/Timeout"}}}},"/readings/{theme}":{"post":{"tags":["풀이"],"operationId":"createThemeReading","summary":"주제별 개인 풀이","description":"한 사람의 명식으로 주제 풀이를 만듭니다. `theme`는 `GET /themes`의 `id`여야 합니다. `compatibility`는 이 경로의 주제가 아니라 `POST /readings/compatibility`를 쓰세요.\n\n`preview: true`는 무료 미리보기입니다. `months: true`인 주제의 본편에는 달별 표가 포함될 수 있습니다.","parameters":[{"name":"theme","in":"path","required":true,"schema":{"$ref":"#/components/schemas/ThemeId"},"description":"풀이 주제 id"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReadingBody"},"examples":{"preview":{"summary":"미리보기 (preview: true)","value":{"preview":true,"person":{"nickname":"하늘","gender":"female","calendar":"solar","date":"1994-08-17","time":"14:20","birthplace":{"name":"서울","longitude":126.978}}}},"unknownTime":{"summary":"태어난 시간을 모를 때","value":{"preview":true,"person":{"nickname":"하늘","gender":"female","calendar":"solar","date":"1994-08-17","time":null,"birthplace":{"name":"서울"}},"options":{"trueSolarTime":true,"dayBoundary":"midnight"}}}}}}},"responses":{"200":{"description":"풀이 결과","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReadingResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"description":"없는 주제입니다.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"error":{"code":"unknown_theme","message":"없는 주제입니다: unknown"}}}}},"500":{"$ref":"#/components/responses/Internal"},"502":{"$ref":"#/components/responses/Upstream"},"504":{"$ref":"#/components/responses/Timeout"}}}}},"components":{"schemas":{"ThemeId":{"type":"string","enum":["new-year-2027","christmas-love","natal","money-work-2027","love-2027"]},"Person":{"type":"object","additionalProperties":false,"required":["nickname","gender","calendar","date","time","birthplace"],"properties":{"nickname":{"type":"string","minLength":1,"maxLength":20,"description":"앞뒤 공백은 잘라 냅니다. 꺽쇠(`<>`)와 줄바꿈은 넣을 수 없습니다.","example":"하늘"},"gender":{"type":"string","enum":["male","female"]},"calendar":{"type":"string","enum":["solar","lunar"],"description":"양력 또는 음력. 음력 날짜는 `date`에 음력 연·월·일을 넣습니다."},"isLeapMonth":{"type":"boolean","description":"음력 윤달일 때만 씁니다. 양력에 지정하면 `invalid_chart`입니다."},"date":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$","description":"YYYY-MM-DD. 요청 스키마는 형식만 검사합니다. 엔진은 양력 1908-04-01부터 2027-12-31까지만 계산하며, 범위를 벗어나면 `invalid_chart`입니다.","example":"1994-08-17"},"time":{"oneOf":[{"type":"string","pattern":"^\\d{2}:\\d{2}$","example":"14:20"},{"type":"null"}],"description":"HH:mm. 시간을 모르면 `null`입니다. 이때 엔진은 12:00으로 연·월·일주만 잡고 시주는 비웁니다."},"birthplace":{"$ref":"#/components/schemas/Birthplace"}}},"Birthplace":{"type":"object","additionalProperties":false,"required":["name"],"properties":{"name":{"type":"string","minLength":1,"maxLength":40,"description":"앞뒤 공백은 잘라 냅니다. 꺽쇠와 줄바꿈은 넣을 수 없습니다.","example":"서울"},"longitude":{"type":"number","minimum":-180,"maximum":180,"description":"경도. 없으면 엔진이 서울(126.978)로 잡고 차트 `caveats`에 남깁니다.","example":126.978}}},"ReadingOptions":{"type":"object","additionalProperties":false,"description":"계산 전제. 생략하면 엔진 기본값(진태양시 켜짐, 일 경계 자정)을 씁니다.","properties":{"trueSolarTime":{"type":"boolean","description":"진태양시(출생지 경도 + 균시차). 기본값은 켜짐입니다."},"dayBoundary":{"type":"string","enum":["midnight","jasi","splitJasi"],"description":"일 경계. `midnight`은 자정, `jasi`는 23시부터 다음 날 일주, `splitJasi`는 일주는 당일로 두고 시주 천간만 다음 날 일간으로 봅니다. 기본값은 `midnight`입니다."}}},"ReadingBody":{"type":"object","additionalProperties":false,"required":["person"],"properties":{"person":{"$ref":"#/components/schemas/Person"},"preview":{"type":"boolean","description":"true이면 무료 미리보기입니다. 없거나 false이면 본편입니다."},"options":{"$ref":"#/components/schemas/ReadingOptions"}}},"CompatibilityBody":{"type":"object","additionalProperties":false,"required":["personA","personB"],"properties":{"personA":{"$ref":"#/components/schemas/Person"},"personB":{"$ref":"#/components/schemas/Person"},"preview":{"type":"boolean","description":"true이면 무료 미리보기입니다. 없거나 false이면 본편입니다."},"options":{"$ref":"#/components/schemas/ReadingOptions"}}},"HealthResponse":{"type":"object","required":["ok","service","provider","model","sample"],"properties":{"ok":{"type":"boolean","enum":[true]},"service":{"type":"string","example":"byeolsamak"},"provider":{"type":"string","example":"gemini"},"model":{"type":"string","description":"현재 라이브 모델. 환경 변수에 따라 달라지므로 이 필드를 확인하세요."},"sample":{"type":"boolean"}}},"ThemesResponse":{"type":"object","required":["themes","compatibility","preview"],"properties":{"themes":{"type":"array","items":{"$ref":"#/components/schemas/ThemeSummary"}},"compatibility":{"type":"object","required":["path","title","priceWon"],"properties":{"path":{"type":"string","example":"/v1/readings/compatibility"},"title":{"type":"string","example":"궁합"},"priceWon":{"type":"number","example":990}}},"preview":{"type":"object","required":["priceWon"],"properties":{"priceWon":{"type":"number","example":0}}}}},"ThemeSummary":{"type":"object","required":["id","title","priceWon","months"],"properties":{"id":{"$ref":"#/components/schemas/ThemeId"},"title":{"type":"string"},"priceWon":{"type":"number","example":990},"months":{"type":"boolean","description":"true이면 본편 풀이에 달별 표가 포함될 수 있습니다."}}},"ReadingResponse":{"type":"object","required":["theme","title","preview","cache","attempts","provider","model","sample","charts","reading","usage"],"properties":{"theme":{"type":"string","description":"주제 id, 또는 궁합이면 `compatibility`."},"title":{"type":"string"},"preview":{"type":"boolean"},"cache":{"type":"string","enum":["hit","miss"]},"attempts":{"type":"number","description":"이번 요청에서 모델을 부른 횟수. 캐시 히트면 0입니다."},"provider":{"type":"string"},"model":{"type":"string","description":"이 풀이를 만든 모델 이름."},"sample":{"type":"boolean","description":"모의 제공자의 예시 풀이면 true."},"charts":{"type":"array","minItems":1,"maxItems":2,"items":{"$ref":"#/components/schemas/ChartView"},"description":"화면 계약(`chartViewSchema`)보다 많은 필드(대운, 세운, 월운, 시계 등)가 그대로 실립니다. 계약에 없는 필드는 클라이언트가 무시해도 됩니다."},"reading":{"$ref":"#/components/schemas/ReadingView"},"usage":{"$ref":"#/components/schemas/Usage"}}},"ChartView":{"type":"object","description":"클라이언트가 읽는 최소 차트 모양입니다. 실제 응답의 `pillars`는 `hanja`/`ko` 외에 천간·지지·십신 등 더 많은 필드를 포함할 수 있습니다.","required":["nickname","elements","pillars"],"properties":{"nickname":{"type":"string"},"elements":{"type":"object","additionalProperties":{"type":"number"},"description":"오행 개수. 키는 보통 목, 화, 토, 금, 수입니다."},"pillars":{"type":"object","required":["year","month","day","hour"],"properties":{"year":{"$ref":"#/components/schemas/Pillar"},"month":{"$ref":"#/components/schemas/Pillar"},"day":{"$ref":"#/components/schemas/Pillar"},"hour":{"allOf":[{"$ref":"#/components/schemas/Pillar"}],"nullable":true}}},"caveats":{"type":"array","items":{"type":"string"},"description":"이 사람에게만 해당하는 계산 전제. 화면에 그대로 보여 줄 수 있습니다."},"uncertain":{"type":"array","items":{"type":"string","enum":["year","month","daeun"]},"description":"절입 경계 등으로 단정할 수 없는 값. 비어 있거나 없으면 없습니다."}}},"Pillar":{"type":"object","required":["hanja","ko"],"properties":{"hanja":{"type":"string"},"ko":{"type":"string"}},"additionalProperties":true},"ReadingView":{"type":"object","required":["intro","summary","sections","scores","lucky","outro","factLine"],"properties":{"intro":{"type":"string"},"summary":{"type":"string"},"sections":{"type":"array","items":{"type":"object","required":["id","title","body"],"properties":{"id":{"type":"string"},"title":{"type":"string"},"body":{"type":"string"}}}},"scores":{"type":"array","items":{"type":"object","required":["key","label","score"],"properties":{"key":{"type":"string"},"label":{"type":"string"},"score":{"type":"number"},"note":{"type":"string"}}}},"lucky":{"type":"object","required":["color","direction","number","item"],"properties":{"color":{"type":"string"},"direction":{"type":"string"},"number":{"type":"number"},"item":{"type":"string"}}},"months":{"type":"array","description":"달별 표. `months: true`인 주제의 본편에 주로 포함됩니다.","items":{"type":"object","required":["month","keyword","body","score"],"properties":{"month":{"type":"number"},"keyword":{"type":"string"},"body":{"type":"string"},"score":{"type":"number"}}}},"outro":{"type":"string"},"factLine":{"type":"string"}}},"Usage":{"type":"object","required":["inputTokens","outputTokens","estimatedTokens","estimatedKrw","latencyMs"],"properties":{"inputTokens":{"type":"number"},"outputTokens":{"type":"number","description":"응답 본문 토큰. 생각 토큰은 thoughtsTokens에 따로 있습니다."},"thoughtsTokens":{"type":"number"},"estimatedTokens":{"type":"boolean"},"estimatedKrw":{"type":"number"},"latencyMs":{"type":"number"}}},"ErrorResponse":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","description":"알려진 코드: `unknown_theme`, `invalid_json`, `invalid_input`, `invalid_chart`, `upstream_timeout`, `upstream_error`, `invalid_model_output`, `internal`."},"message":{"type":"string"}}}}}},"responses":{"BadRequest":{"description":"요청이 잘못되었습니다. `invalid_json`(JSON이 아님), `invalid_input`(본문 스키마 검증 실패), `invalid_chart`(명식 계산 실패, 예: 양력에 윤달, 지원 날짜 범위 밖, 잘못된 시각).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"invalid_json":{"value":{"error":{"code":"invalid_json","message":"JSON 본문이 아닙니다."}}},"invalid_input":{"value":{"error":{"code":"invalid_input","message":"person.date: 날짜는 YYYY-MM-DD"}}},"invalid_chart":{"value":{"error":{"code":"invalid_chart","message":"윤달은 음력에서만 지정합니다."}}}}}}},"Upstream":{"description":"모델을 부르거나 출력을 검증하지 못했습니다. `upstream_error` 또는 `invalid_model_output`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"error":{"code":"upstream_error","message":"풀이를 만드는 모델이 응답하지 않았습니다. 잠시 뒤 다시 시도해 주세요."}}}}},"Timeout":{"description":"풀이 시한(기본 45000ms)을 넘겼습니다.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"error":{"code":"upstream_timeout","message":"풀이가 제시간에 오지 않았습니다. 잠시 뒤 다시 시도해 주세요."}}}}},"Internal":{"description":"서버 내부 오류. 상세 문장은 응답에 싣지 않습니다.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"error":{"code":"internal","message":"풀이를 만들지 못했습니다. 잠시 뒤 다시 시도해 주세요."}}}}}}}}