Skip to content

Latest commit

 

History

History
178 lines (141 loc) · 6.93 KB

File metadata and controls

178 lines (141 loc) · 6.93 KB

RouteFit — Pricing Catalog 설계

가격을 하나의 숫자가 아니라 조건이 붙은 가격 규칙(pricing rules) 으로 관리한다. Batch·캐시·롱컨텍스트·우선처리·리전·검색도구·채널·기간에 따라 가격이 달라지기 때문. 관련: assumptions.md · 시드 데이터: ../catalog/pricing.seed.json


1. 왜 단순 가격표가 아닌가

같은 모델이라도 다음에 따라 가격이 달라진다:

  • 처리 모드: Standard / Batch(≈50% 할인) / Flex / Priority
  • 캐시: cached input, 그리고 Anthropic은 cache write ≠ cache read (별도 가격)
  • 컨텍스트 구간: Gemini 3.1 Pro는 입력 >200K 토큰 시 입력 $2→$4, 출력 $12→$18
  • 기간: Sonnet 5의 $2/$10은 2026-08-31까지 출시 기념가, 이후 표준 $3/$15
  • 채널: 같은 Claude라도 Anthropic Direct / AWS Bedrock / Google Vertex 가격이 다를 수 있음
  • 리전: 미국 내 전용 추론은 입력·출력 1.1배 등
  • 추가 사용료: web search / grounding / file search / code execution / 컨테이너 / 캐시 저장시간

→ 그래서 하나의 모델 = 여러 pricing_rule의 배열로 저장한다.


2. 스키마

2.1 모델 기본 정보

provider, model_id, display_name, generation
status: preview | ga | deprecated
modalities: { text_in, image_in, audio_in }   # 입력 지원
context_window, max_output_tokens
description, official_pricing_url

2.2 가격 규칙 (pricing_rules[])

channel: anthropic_direct | openai_direct | google_gemini_api | aws_bedrock | azure_foundry | google_vertex
currency, unit (per_1m_tokens)
mode: standard | batch | flex | priority
condition: { input_tokens_lte, input_tokens_gt, ... }
effective_from, effective_to        # 기간 조건 (ISO date)
input, output
cached_input | cache_write, cache_read
region_multiplier                   # 예: us_dedicated = 1.1

2.3 부가 사용료 & 출처

extras: { web_search, grounding, file_search, code_execution, container, cache_storage, image, audio, video }
source: { type: official|manual, fetched_at, verified_by }

MVP 노출 정책: 기본 화면에는 텍스트·비전 LLM 가격만 노출. 오디오·이미지·비디오 모델은 별도 고급 탭으로 분리.

2.4 예시 — Gemini 3.1 Pro (컨텍스트 구간 조건)

provider: google
model_id: gemini-3.1-pro-preview
channel: google_gemini_api
currency: USD
unit: per_1m_tokens
pricing_rules:
  - mode: standard
    condition: { input_tokens_lte: 200000 }
    input: 2.00
    output: 12.00
    cached_input: 0.20
  - mode: standard
    condition: { input_tokens_gt: 200000 }
    input: 4.00
    output: 18.00
    cached_input: 0.40
  - mode: batch
    condition: { input_tokens_lte: 200000 }
    input: 1.00
    output: 6.00
source: { type: official, fetched_at: 2026-07-13 }

2.5 예시 — Claude Sonnet 5 (기간 조건)

provider: anthropic
model_id: claude-sonnet-5
channel: anthropic_direct
currency: USD
unit: per_1m_tokens
pricing_rules:
  - mode: standard
    effective_from: 2026-07-01
    effective_to: 2026-08-31        # 출시 기념가
    input: 2.00
    output: 10.00
    cache_write: 2.50
    cache_read: 0.20
  - mode: standard
    effective_from: 2026-09-01      # 표준가로 전환
    input: 3.00
    output: 15.00
source: { type: official, fetched_at: 2026-07-13 }

→ 8월과 9월의 예상 비용이 자동으로 달라진다.


3. 채널 분리 (중요)

같은 모델도 구매 채널에 따라 가격이 다르므로 channel 필드는 필수.

Claude ─ anthropic_direct | aws_bedrock | google_vertex
GPT   ─ openai_direct | azure_foundry | aws_bedrock
Gemini─ google_gemini_api | google_vertex

확장 순서: OpenAI Direct → Anthropic Direct → Google Gemini API → AWS Bedrock → Azure Foundry → Google Vertex.


4. 동기화 파이프라인 (빌드타임)

⚠️ 스택 결정에 맞춰 어댑터는 Python이 아니라 Node/TS 스크립트로 구현한다 (GitHub Actions). 런타임은 브라우저.

OpenAI 공식가 ─┐
Anthropic 공식가─┼→ Provider Adapter(TS) → Raw Extraction → Normalized Pricing Rules
Google 공식가 ─┘        → Validation & Diff → Last-known-good Snapshot → 번들 catalog.json
pricing/
├─ adapters/         openai.ts  anthropic.ts  google.ts
├─ schemas/          model.ts  price_rule.ts  source.ts   (zod 등)
├─ snapshots/        openai.json  anthropic.json  google.json
├─ validators/       schema.ts  price_change_detector.ts  model_status.ts
└─ catalog.json      # 앱에 번들되는 최종 산출물

업데이트 흐름: GitHub Actions 매일 실행 → 어댑터 파싱 → 공통 스키마 변환 → 직전과 diff → 변경/신규/삭제 감지 → 자동 배포 대신 Pull Request 생성 → 검토 후 반영. (페이지 구조 변경을 가격 변경으로 오인할 수 있으므로 자동 반영은 위험.)


5. 안전장치

  • Last-known-good: 공식 페이지 파싱 실패해도 직전 검증 스냅샷을 계속 사용.
    { "status": "stale", "last_successful_sync": "2026-07-12T00:00:00Z",
      "message": "Official source parsing failed. Using the last verified snapshot." }
  • 가격 변경 폭 검증 (자동 반영 금지 → 검토 대상): 50%+ 변동 / 가격 0으로 변경 / 입력·출력 위치 뒤바뀜 / 모델 갑자기 사라짐 / 통화·단위 변경.
  • 출처·시점 항상 노출: 결과 화면에 고정 표시.
    Pricing source: <vendor> official API pricing
    Last verified: 2026-07-13 09:00 UTC
    Currency: USD   Exchange rate applied: 1 USD = ₩____
    
    "최신 가격"이라 쓰지 말고 "마지막 확인 시점" 을 명시한다.

6. 비용 계산 연결

입력(월 사용자·1인당 요청·활성일·평균 입출력 토큰·캐시 적중률·Batch 비율)을 받아 공식 가격 기준으로 시나리오 비교:

① 단일 고성능 100% · ② 단일 경량 100% · ③ 경량80%+고성능20% 라우팅 · ④ 경량 선처리+에스컬레이션 · ⑤ Gemini Flash/Pro 혼합 · ⑥ Claude Haiku/Sonnet 혼합 · ⑦ Cross-vendor 라우팅

결과 분해 항목: 기본 입력비 · 캐시 입력비 · 출력비 · 라우터 호출비 · 실패 재호출비 · 검색/도구비 · Batch 절감액 · 월 예상 범위 · 사용자 1명당 월비 · 요청 1건당 평균비.

차별점: "어떤 모델이 제일 싼가?"가 아니라

Official Pricing + Expected Usage + Routing Ratio + Escalation Rate + Cache Hit Rate + Quality Requirement → Recommended LLM Operating Architecture

즉 공식 가격을 조회 데이터가 아니라 운영 의사결정 데이터로 쓴다.


갱신 로그

  • 2026-07-13: 최초 작성. 스키마·채널·동기화(Node 어댑터)·안전장치·비용 연결 정의. 시드 데이터 catalog/pricing.seed.json 생성.